Update unit tests for better postgres support

This commit is contained in:
Griatch 2019-03-21 22:35:58 +01:00
parent a9460cffad
commit 1d0d6bc7cf
3 changed files with 35 additions and 28 deletions

View file

@ -730,10 +730,11 @@ class TestMail(CommandTest):
self.call(mail.CmdMail(), "2", "'2' is not a valid mail id.", caller=self.account) self.call(mail.CmdMail(), "2", "'2' is not a valid mail id.", caller=self.account)
self.call(mail.CmdMail(), "test", "'test' is not a valid mail id.") self.call(mail.CmdMail(), "test", "'test' is not a valid mail id.")
self.call(mail.CmdMail(), "", "There are no messages in your inbox.", caller=self.account) self.call(mail.CmdMail(), "", "There are no messages in your inbox.", caller=self.account)
self.call(mail.CmdMail(), "Char=Message 1", "You have received a new @mail from Char|You sent your message.", caller=self.char1) self.call(mail.CmdMail(), "Char=Message 1",
"You have received a new @mail from Char|You sent your message.", caller=self.char1)
self.call(mail.CmdMail(), "Char=Message 2", "You sent your message.", caller=self.char2) self.call(mail.CmdMail(), "Char=Message 2", "You sent your message.", caller=self.char2)
self.call(mail.CmdMail(), "TestAccount2=Message 2", self.call(mail.CmdMail(), "TestAccount2=Message 2",
"You have received a new @mail from TestAccount2(account 2)|You sent your message.", caller=self.account2) "You have received a new @mail from TestAccount2", caller=self.account2)
self.call(mail.CmdMail(), "TestAccount=Message 1", "You sent your message.", caller=self.account2) self.call(mail.CmdMail(), "TestAccount=Message 1", "You sent your message.", caller=self.account2)
self.call(mail.CmdMail(), "TestAccount=Message 2", "You sent your message.", caller=self.account2) self.call(mail.CmdMail(), "TestAccount=Message 2", "You sent your message.", caller=self.account2)
self.call(mail.CmdMail(), "", "| ID: From: Subject:", caller=self.account) self.call(mail.CmdMail(), "", "| ID: From: Subject:", caller=self.account)
@ -1762,13 +1763,16 @@ class TestPuzzles(CommandTest):
super(TestPuzzles, self).setUp() super(TestPuzzles, self).setUp()
self.steel = create_object( self.steel = create_object(
self.object_typeclass, self.object_typeclass,
key='steel', location=self.char1.location) key='steel',
location=self.char1.location)
self.flint = create_object( self.flint = create_object(
self.object_typeclass, self.object_typeclass,
key='flint', location=self.char1.location) key='flint',
location=self.char1.location)
self.fire = create_object( self.fire = create_object(
self.object_typeclass, self.object_typeclass,
key='fire', location=self.char1.location) key='fire',
location=self.char1.location)
self.steel.tags.add('tag-steel') self.steel.tags.add('tag-steel')
self.steel.tags.add('tag-steel', category='tagcat') self.steel.tags.add('tag-steel', category='tagcat')
self.flint.tags.add('tag-flint') self.flint.tags.add('tag-flint')

View file

@ -134,8 +134,8 @@ class TestUtils(EvenniaTest):
('oldtest', 'to_keep', None, ''), ('oldtest', 'to_keep', None, ''),
('test', 'testval', None, '')], ('test', 'testval', None, '')],
'key': 'Obj', 'key': 'Obj',
'home': '#1', 'home': Something,
'location': '#1', 'location': Something,
'locks': 'call:true();control:perm(Developer);delete:perm(Admin);' 'locks': 'call:true();control:perm(Developer);delete:perm(Admin);'
'edit:perm(Admin);examine:perm(Builder);get:all();' 'edit:perm(Admin);examine:perm(Builder);get:all();'
'puppet:pperm(Developer);tell:perm(Admin);view:all()', 'puppet:pperm(Developer);tell:perm(Admin);view:all()',
@ -149,9 +149,9 @@ class TestUtils(EvenniaTest):
self.assertEqual(old_prot, self.assertEqual(old_prot,
{'attrs': [('oldtest', 'to_keep', None, ''), {'attrs': [('oldtest', 'to_keep', None, ''),
('fooattr', 'fooattrval', None, '')], ('fooattr', 'fooattrval', None, '')],
'home': '#1', 'home': Something,
'key': 'Obj', 'key': 'Obj',
'location': '#1', 'location': Something,
'locks': 'call:true();control:perm(Developer);delete:perm(Admin);' 'locks': 'call:true();control:perm(Developer);delete:perm(Admin);'
'edit:perm(Admin);examine:perm(Builder);get:all();' 'edit:perm(Admin);examine:perm(Builder);get:all();'
'puppet:pperm(Developer);tell:perm(Admin);view:all()', 'puppet:pperm(Developer);tell:perm(Admin);view:all()',
@ -166,11 +166,11 @@ class TestUtils(EvenniaTest):
self.assertEqual( self.assertEqual(
pdiff, pdiff,
{'home': ('#1', '#1', 'KEEP'), {'home': (Something, Something, 'KEEP'),
'prototype_locks': ('spawn:all();edit:all()', 'prototype_locks': ('spawn:all();edit:all()',
'spawn:all();edit:all()', 'KEEP'), 'spawn:all();edit:all()', 'KEEP'),
'prototype_key': (Something, Something, 'UPDATE'), 'prototype_key': (Something, Something, 'UPDATE'),
'location': ('#1', '#1', 'KEEP'), 'location': (Something, Something, 'KEEP'),
'locks': ('call:true();control:perm(Developer);delete:perm(Admin);' 'locks': ('call:true();control:perm(Developer);delete:perm(Admin);'
'edit:perm(Admin);examine:perm(Builder);get:all();' 'edit:perm(Admin);examine:perm(Builder);get:all();'
'puppet:pperm(Developer);tell:perm(Admin);view:all()', 'puppet:pperm(Developer);tell:perm(Admin);view:all()',
@ -340,13 +340,14 @@ class TestProtFuncs(EvenniaTest):
# no object search # no object search
odbref = self.obj1.dbref
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("obj(#1)", session=self.session), 'obj(#1)') self.assertEqual(protlib.protfunc_parser("obj({})".format(odbref), session=self.session), 'obj({})'.format(odbref))
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("dbref(#1)", session=self.session), 'dbref(#1)') self.assertEqual(protlib.protfunc_parser("dbref({})".format(odbref), session=self.session), 'dbref({})'.format(odbref))
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
@ -354,7 +355,7 @@ class TestProtFuncs(EvenniaTest):
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("#1", session=self.session), '#1') self.assertEqual(protlib.protfunc_parser(odbref, session=self.session), odbref)
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
@ -362,7 +363,7 @@ class TestProtFuncs(EvenniaTest):
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("nothing(#1)", session=self.session), 'nothing(#1)') self.assertEqual(protlib.protfunc_parser("nothing({})".format(odbref), session=self.session), 'nothing({})'.format(odbref))
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
@ -374,7 +375,7 @@ class TestProtFuncs(EvenniaTest):
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("objlist(#1)", session=self.session), 'objlist(#1)') self.assertEqual(protlib.protfunc_parser("objlist({})".format(odbref), session=self.session), 'objlist({})'.format(odbref))
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
@ -385,22 +386,24 @@ class TestProtFuncs(EvenniaTest):
# obj search happens # obj search happens
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("$objlist(#1)", session=self.session), ['#1']) self.assertEqual(protlib.protfunc_parser("$objlist({})".format(odbref), session=self.session), [odbref])
mocked__obj_search.assert_called_once() mocked__obj_search.assert_called_once()
assert ('#1',) == mocked__obj_search.call_args[0] assert (odbref,) == mocked__obj_search.call_args[0]
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("$obj(#1)", session=self.session), '#1') self.assertEqual(protlib.protfunc_parser("$obj({})".format(odbref), session=self.session), odbref)
mocked__obj_search.assert_called_once() mocked__obj_search.assert_called_once()
assert ('#1',) == mocked__obj_search.call_args[0] assert (odbref,) == mocked__obj_search.call_args[0]
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("$dbref(#1)", session=self.session), '#1') self.assertEqual(protlib.protfunc_parser("$dbref({})".format(odbref), session=self.session), odbref)
mocked__obj_search.assert_called_once() mocked__obj_search.assert_called_once()
assert ('#1',) == mocked__obj_search.call_args[0] assert (odbref,) == mocked__obj_search.call_args[0]
cdbref = self.char1.dbref
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("$obj(Char)", session=self.session), '#6') self.assertEqual(protlib.protfunc_parser("$obj(Char)", session=self.session), cdbref)
mocked__obj_search.assert_called_once() mocked__obj_search.assert_called_once()
assert ('Char',) == mocked__obj_search.call_args[0] assert ('Char',) == mocked__obj_search.call_args[0]
@ -408,7 +411,7 @@ class TestProtFuncs(EvenniaTest):
# bad invocation # bad invocation
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
self.assertEqual(protlib.protfunc_parser("$badfunc(#1)", session=self.session), '<UNKNOWN>') self.assertEqual(protlib.protfunc_parser("$badfunc(#112345)", session=self.session), '<UNKNOWN>')
mocked__obj_search.assert_not_called() mocked__obj_search.assert_not_called()
with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search: with mock.patch("evennia.prototypes.protfuncs._obj_search", wraps=protofuncs._obj_search) as mocked__obj_search:
@ -417,11 +420,11 @@ class TestProtFuncs(EvenniaTest):
self.assertEqual(protlib.value_to_obj( self.assertEqual(protlib.value_to_obj(
protlib.protfunc_parser("#6", session=self.session)), self.char1) protlib.protfunc_parser(cdbref, session=self.session)), self.char1)
self.assertEqual(protlib.value_to_obj_or_any( self.assertEqual(protlib.value_to_obj_or_any(
protlib.protfunc_parser("#6", session=self.session)), self.char1) protlib.protfunc_parser(cdbref, session=self.session)), self.char1)
self.assertEqual(protlib.value_to_obj_or_any( self.assertEqual(protlib.value_to_obj_or_any(
protlib.protfunc_parser("[1,2,3,'#6',5]", session=self.session)), protlib.protfunc_parser("[1,2,3,'{}',5]".format(cdbref), session=self.session)),
[1, 2, 3, self.char1, 5]) [1, 2, 3, self.char1, 5])

View file

@ -44,7 +44,7 @@ class TestTypedObjectManager(EvenniaTest):
self.obj2.tags.add("tag4") self.obj2.tags.add("tag4")
self.obj2.tags.add("tag2c") self.obj2.tags.add("tag2c")
self.assertEqual(self._manager("get_by_tag", "tag1"), [self.obj1]) self.assertEqual(self._manager("get_by_tag", "tag1"), [self.obj1])
self.assertEqual(self._manager("get_by_tag", "tag2"), [self.obj1, self.obj2]) self.assertEqual(set(self._manager("get_by_tag", "tag2")), set([self.obj1, self.obj2]))
self.assertEqual(self._manager("get_by_tag", "tag2a"), [self.obj2]) self.assertEqual(self._manager("get_by_tag", "tag2a"), [self.obj2])
self.assertEqual(self._manager("get_by_tag", "tag3 with spaces"), [self.obj2]) self.assertEqual(self._manager("get_by_tag", "tag3 with spaces"), [self.obj2])
self.assertEqual(self._manager("get_by_tag", ["tag2a", "tag2b"]), [self.obj2]) self.assertEqual(self._manager("get_by_tag", ["tag2a", "tag2b"]), [self.obj2])