Made unittests work with changed Session apis. Resolves #808.

This commit is contained in:
Griatch 2015-11-15 19:51:41 +01:00
parent efefe3e5ff
commit 45f973fdb6
8 changed files with 60 additions and 38 deletions

View file

@ -318,8 +318,11 @@ class Command(with_metaclass(CommandMeta, object)):
"""
from_obj = from_obj or self.caller
to_obj = to_obj or from_obj
if not session or to_obj == self.caller:
session = to_obj.sessions.get()
if not session:
if to_obj == self.caller:
session = self.session
else:
session = to_obj.sessions.get()
to_obj.msg(msg, from_obj=from_obj, session=session, **kwargs)
# Common Command hooks

View file

@ -1870,7 +1870,7 @@ class CmdExamine(ObjManipCommand):
string += "\n{wAliases{n: %s" % (", ".join(utils.make_iter(str(obj.aliases))))
if hasattr(obj, "sessions") and obj.sessions:
string += "\n{wsession(s){n: %s" % (", ".join(str(sess.sessid)
for sess in obj.sessions))
for sess in obj.sessions.all()))
if hasattr(obj, "has_player") and obj.has_player:
string += "\n{wPlayer{n: {c%s{n" % obj.player.name
perms = obj.player.permissions.all()

View file

@ -276,7 +276,7 @@ class CmdSessions(MuxPlayerCommand):
def func(self):
"Implement function"
player = self.player
sessions = player.get_all_sessions()
sessions = player.sessions.all()
table = prettytable.PrettyTable(["{wsessid",
"{wprotocol",
@ -284,9 +284,8 @@ class CmdSessions(MuxPlayerCommand):
"{wpuppet/character",
"{wlocation"])
for sess in sorted(sessions, key=lambda x: x.sessid):
sessid = sess.sessid
char = player.get_puppet(sessid)
table.add_row([str(sessid), str(sess.protocol_key),
char = player.get_puppet(sess)
table.add_row([str(sess.sessid), str(sess.protocol_key),
type(sess.address) == tuple and sess.address[0] or sess.address,
char and str(char) or "None",
char and str(char.location) or "N/A"])
@ -602,7 +601,7 @@ class CmdQuell(MuxPlayerCommand):
def _recache_locks(self, player):
"Helper method to reset the lockhandler on an already puppeted object"
if self.session:
char = session.puppet
char = self.session.puppet
if char:
# we are already puppeting an object. We need to reset
# the lock caches (otherwise the superuser status change