Fix the presence tests

This commit is contained in:
Mark Haines 2015-05-20 13:22:18 +01:00
parent e01b825cc9
commit 8eca5bd50a
2 changed files with 6 additions and 10 deletions

View File

@ -624,6 +624,7 @@ class PresencePushTestCase(MockedDatastorePresenceTestCase):
""" """
PRESENCE_LIST = { PRESENCE_LIST = {
'apple': [ "@banana:test", "@clementine:test" ], 'apple': [ "@banana:test", "@clementine:test" ],
'banana': [ "@apple:test" ],
} }
@defer.inlineCallbacks @defer.inlineCallbacks
@ -836,12 +837,7 @@ class PresencePushTestCase(MockedDatastorePresenceTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_recv_remote(self): def test_recv_remote(self):
# TODO(paul): Gut-wrenching self.room_members = [self.u_apple, self.u_banana, self.u_potato]
potato_set = self.handler._remote_recvmap.setdefault(self.u_potato,
set())
potato_set.add(self.u_apple)
self.room_members = [self.u_banana, self.u_potato]
self.assertEquals(self.event_source.get_current_key(), 0) self.assertEquals(self.event_source.get_current_key(), 0)
@ -886,11 +882,8 @@ class PresencePushTestCase(MockedDatastorePresenceTestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_recv_remote_offline(self): def test_recv_remote_offline(self):
""" Various tests relating to SYN-261 """ """ Various tests relating to SYN-261 """
potato_set = self.handler._remote_recvmap.setdefault(self.u_potato,
set())
potato_set.add(self.u_apple)
self.room_members = [self.u_banana, self.u_potato] self.room_members = [self.u_apple, self.u_banana, self.u_potato]
self.assertEquals(self.event_source.get_current_key(), 0) self.assertEquals(self.event_source.get_current_key(), 0)

View File

@ -295,6 +295,9 @@ class PresenceEventStreamTestCase(unittest.TestCase):
else: else:
return [] return []
hs.handlers.room_member_handler.get_joined_rooms_for_user = get_rooms_for_user hs.handlers.room_member_handler.get_joined_rooms_for_user = get_rooms_for_user
hs.handlers.room_member_handler.get_room_members = (
lambda r: self.room_members if r == "a-room" else []
)
self.mock_datastore = hs.get_datastore() self.mock_datastore = hs.get_datastore()
self.mock_datastore.get_app_service_by_token = Mock(return_value=None) self.mock_datastore.get_app_service_by_token = Mock(return_value=None)