Tests for is_ooc lockfunc
This commit is contained in:
parent
d69589ec99
commit
31b09754a1
2 changed files with 22 additions and 7 deletions
|
|
@ -482,15 +482,19 @@ def is_ooc(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
only when out of character.
|
only when out of character.
|
||||||
"""
|
"""
|
||||||
obj = accessed_obj.obj if hasattr(accessed_obj, "obj") else accessed_obj
|
obj = accessed_obj.obj if hasattr(accessed_obj, "obj") else accessed_obj
|
||||||
session = obj.session if hasattr(obj, "session") else obj
|
account = obj.account if hasattr(obj, "account") else obj
|
||||||
|
if not account:
|
||||||
|
return True
|
||||||
try:
|
try:
|
||||||
return not obj.get_puppet(session)
|
session = accessed_obj.session
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
session = account.sessions.get()[0] # note-this doesn't work well
|
||||||
|
# for high multisession mode. We may need
|
||||||
|
# to change to sessiondb to resolve this
|
||||||
try:
|
try:
|
||||||
return not obj.account.get_puppet(session)
|
return not account.get_puppet(session)
|
||||||
except AttributeError:
|
except TypeError:
|
||||||
pass
|
return not session.get_puppet()
|
||||||
return False
|
|
||||||
|
|
||||||
def objtag(accessing_obj, accessed_obj, *args, **kwargs):
|
def objtag(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,17 @@ class TestLockfuncs(BaseEvenniaTest):
|
||||||
self.assertEqual(False, lockfuncs.serversetting(None, None, "TESTVAL", "[1, 2, 4]"))
|
self.assertEqual(False, lockfuncs.serversetting(None, None, "TESTVAL", "[1, 2, 4]"))
|
||||||
self.assertEqual(False, lockfuncs.serversetting(None, None, "TESTVAL", "123"))
|
self.assertEqual(False, lockfuncs.serversetting(None, None, "TESTVAL", "123"))
|
||||||
|
|
||||||
|
def test_is_ooc__char(self):
|
||||||
|
self.assertEqual(False, lockfuncs.is_ooc(self.char1, self.char1))
|
||||||
|
|
||||||
|
def test_is_ooc__session(self):
|
||||||
|
self.assertEqual(False, lockfuncs.is_ooc(self.session, self.char1))
|
||||||
|
|
||||||
|
def test_is_ooc__account(self):
|
||||||
|
self.assertEqual(False, lockfuncs.is_ooc(self.account, self.char1))
|
||||||
|
self.account.unpuppet_all()
|
||||||
|
self.assertEqual(True, lockfuncs.is_ooc(self.account, self.char1))
|
||||||
|
|
||||||
|
|
||||||
class TestPermissionCheck(BaseEvenniaTest):
|
class TestPermissionCheck(BaseEvenniaTest):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue