Abstract out the room ID from presence tests, so it's stored in self

This commit is contained in:
Paul "LeoNerd" Evans 2015-01-21 20:01:57 +00:00
parent dbe71e670c
commit 73315ce9de
1 changed files with 10 additions and 8 deletions

View File

@ -113,17 +113,18 @@ class PresenceTestCase(unittest.TestCase):
self.handler = hs.get_handlers().presence_handler self.handler = hs.get_handlers().presence_handler
self.room_id = "a-room"
self.room_members = [] self.room_members = []
def get_rooms_for_user(user): def get_rooms_for_user(user):
if user in self.room_members: if user in self.room_members:
return defer.succeed(["a-room"]) return defer.succeed([self.room_id])
else: else:
return defer.succeed([]) return defer.succeed([])
room_member_handler.get_rooms_for_user = get_rooms_for_user room_member_handler.get_rooms_for_user = get_rooms_for_user
def get_room_members(room_id): def get_room_members(room_id):
if room_id == "a-room": if room_id == self.room_id:
return defer.succeed(self.room_members) return defer.succeed(self.room_members)
else: else:
return defer.succeed([]) return defer.succeed([])
@ -529,24 +530,25 @@ class PresencePushTestCase(unittest.TestCase):
]) ])
self.room_member_handler = hs.handlers.room_member_handler self.room_member_handler = hs.handlers.room_member_handler
self.room_id = "a-room"
self.room_members = [] self.room_members = []
def get_rooms_for_user(user): def get_rooms_for_user(user):
if user in self.room_members: if user in self.room_members:
return defer.succeed(["a-room"]) return defer.succeed([self.room_id])
else: else:
return defer.succeed([]) return defer.succeed([])
self.room_member_handler.get_rooms_for_user = get_rooms_for_user self.room_member_handler.get_rooms_for_user = get_rooms_for_user
def get_room_members(room_id): def get_room_members(room_id):
if room_id == "a-room": if room_id == self.room_id:
return defer.succeed(self.room_members) return defer.succeed(self.room_members)
else: else:
return defer.succeed([]) return defer.succeed([])
self.room_member_handler.get_room_members = get_room_members self.room_member_handler.get_room_members = get_room_members
def get_room_hosts(room_id): def get_room_hosts(room_id):
if room_id == "a-room": if room_id == self.room_id:
hosts = set([u.domain for u in self.room_members]) hosts = set([u.domain for u in self.room_members])
return defer.succeed(hosts) return defer.succeed(hosts)
else: else:
@ -882,7 +884,7 @@ class PresencePushTestCase(unittest.TestCase):
) )
yield self.distributor.fire("user_joined_room", self.u_clementine, yield self.distributor.fire("user_joined_room", self.u_clementine,
"a-room" self.room_id
) )
self.room_members.append(self.u_clementine) self.room_members.append(self.u_clementine)
@ -945,7 +947,7 @@ class PresencePushTestCase(unittest.TestCase):
self.room_members = [self.u_apple, self.u_banana] self.room_members = [self.u_apple, self.u_banana]
yield self.distributor.fire("user_joined_room", self.u_potato, yield self.distributor.fire("user_joined_room", self.u_potato,
"a-room" self.room_id
) )
yield put_json.await_calls() yield put_json.await_calls()
@ -974,7 +976,7 @@ class PresencePushTestCase(unittest.TestCase):
self.room_members.append(self.u_potato) self.room_members.append(self.u_potato)
yield self.distributor.fire("user_joined_room", self.u_clementine, yield self.distributor.fire("user_joined_room", self.u_clementine,
"a-room" self.room_id
) )
put_json.await_calls() put_json.await_calls()