Various minor fixes to unit-test structure around typing notifications

This commit is contained in:
Paul "LeoNerd" Evans 2015-04-15 23:32:11 +01:00
parent 0268d40281
commit 04c7f3576e
2 changed files with 11 additions and 2 deletions

View File

@ -126,6 +126,13 @@ class TypingNotificationsTestCase(unittest.TestCase):
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_joined_rooms_for_user(user):
if user in self.room_members:
return defer.succeed([self.room_id])
else:
return defer.succeed([])
self.room_member_handler.get_joined_rooms_for_user = get_joined_rooms_for_user
@defer.inlineCallbacks @defer.inlineCallbacks
def fetch_room_distributions_into(room_id, localusers=None, def fetch_room_distributions_into(room_id, localusers=None,
remotedomains=None, ignore_user=None): remotedomains=None, ignore_user=None):

View File

@ -34,6 +34,8 @@ class RoomTypingTestCase(RestTestCase):
""" Tests /rooms/$room_id/typing/$user_id REST API. """ """ Tests /rooms/$room_id/typing/$user_id REST API. """
user_id = "@sid:red" user_id = "@sid:red"
user = UserID.from_string(user_id)
@defer.inlineCallbacks @defer.inlineCallbacks
def setUp(self): def setUp(self):
self.clock = MockClock() self.clock = MockClock()
@ -75,7 +77,7 @@ class RoomTypingTestCase(RestTestCase):
def get_room_members(room_id): def get_room_members(room_id):
if room_id == self.room_id: if room_id == self.room_id:
return defer.succeed([UserID.from_string(self.user_id)]) return defer.succeed([self.user])
else: else:
return defer.succeed([]) return defer.succeed([])
@ -115,7 +117,7 @@ class RoomTypingTestCase(RestTestCase):
self.assertEquals(200, code) self.assertEquals(200, code)
self.assertEquals(self.event_source.get_current_key(), 1) self.assertEquals(self.event_source.get_current_key(), 1)
events = yield self.event_source.get_new_events_for_user(self.user_id, 0, None) events = yield self.event_source.get_new_events_for_user(self.user, 0, None)
self.assertEquals( self.assertEquals(
events[0], events[0],
[ [