mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
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.
|
||||
"""
|
||||
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:
|
||||
return not obj.get_puppet(session)
|
||||
session = accessed_obj.session
|
||||
except AttributeError:
|
||||
try:
|
||||
return not obj.account.get_puppet(session)
|
||||
except AttributeError:
|
||||
pass
|
||||
return False
|
||||
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:
|
||||
return not account.get_puppet(session)
|
||||
except TypeError:
|
||||
return not session.get_puppet()
|
||||
|
||||
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", "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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue