summary refs log tree commit diff
path: root/tests/handlers/test_room.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/handlers/test_room.py')
-rw-r--r--tests/handlers/test_room.py49
1 files changed, 35 insertions, 14 deletions
diff --git a/tests/handlers/test_room.py b/tests/handlers/test_room.py
index fddab8f74f..613f5c307e 100644
--- a/tests/handlers/test_room.py
+++ b/tests/handlers/test_room.py
@@ -45,6 +45,7 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
                 "get_room_member",
                 "get_room",
                 "store_room",
+                "snapshot_room",
             ]),
             resource_for_federation=NonCallableMock(),
             http_client=NonCallableMock(spec_set=[]),
@@ -52,29 +53,36 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
             handlers=NonCallableMock(spec_set=[
                 "room_member_handler",
                 "profile_handler",
+                "federation_handler",
             ]),
             auth=NonCallableMock(spec_set=["check"]),
-            federation=NonCallableMock(spec_set=[
-                "handle_new_event",
-                "get_state_for_room",
-            ]),
             state_handler=NonCallableMock(spec_set=["handle_new_event"]),
         )
 
+        self.federation = NonCallableMock(spec_set=[
+            "handle_new_event",
+            "get_state_for_room",
+        ])
+
         self.datastore = hs.get_datastore()
         self.handlers = hs.get_handlers()
         self.notifier = hs.get_notifier()
-        self.federation = hs.get_federation()
         self.state_handler = hs.get_state_handler()
         self.distributor = hs.get_distributor()
         self.hs = hs
 
+        self.handlers.federation_handler = self.federation
+
         self.distributor.declare("collect_presencelike_data")
 
         self.handlers.room_member_handler = RoomMemberHandler(self.hs)
         self.handlers.profile_handler = ProfileHandler(self.hs)
         self.room_member_handler = self.handlers.room_member_handler
 
+        self.snapshot = Mock()
+        self.datastore.snapshot_room.return_value = self.snapshot
+
+
     @defer.inlineCallbacks
     def test_invite(self):
         room_id = "!foo:red"
@@ -104,8 +112,12 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
         # Actual invocation
         yield self.room_member_handler.change_membership(event)
 
-        self.state_handler.handle_new_event.assert_called_once_with(event)
-        self.federation.handle_new_event.assert_called_once_with(event)
+        self.state_handler.handle_new_event.assert_called_once_with(
+            event, self.snapshot,
+        )
+        self.federation.handle_new_event.assert_called_once_with(
+            event, self.snapshot,
+        )
 
         self.assertEquals(
             set(["blue", "red", "green"]),
@@ -116,7 +128,8 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
             event
         )
         self.notifier.on_new_room_event.assert_called_once_with(
-                event, store_id)
+            event, store_id
+        )
 
         self.assertFalse(self.datastore.get_room.called)
         self.assertFalse(self.datastore.store_room.called)
@@ -148,6 +161,7 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
 
         self.datastore.get_joined_hosts_for_room.side_effect = get_joined
 
+
         store_id = "store_id_fooo"
         self.datastore.persist_event.return_value = defer.succeed(store_id)
         self.datastore.get_room.return_value = defer.succeed(1)  # Not None.
@@ -163,8 +177,12 @@ class RoomMemberHandlerTestCase(unittest.TestCase):
         # Actual invocation
         yield self.room_member_handler.change_membership(event)
 
-        self.state_handler.handle_new_event.assert_called_once_with(event)
-        self.federation.handle_new_event.assert_called_once_with(event)
+        self.state_handler.handle_new_event.assert_called_once_with(
+            event, self.snapshot
+        )
+        self.federation.handle_new_event.assert_called_once_with(
+            event, self.snapshot
+        )
 
         self.assertEquals(
             set(["red", "green"]),
@@ -318,21 +336,24 @@ class RoomCreationTest(unittest.TestCase):
             handlers=NonCallableMock(spec_set=[
                 "room_creation_handler",
                 "room_member_handler",
+                "federation_handler",
             ]),
             auth=NonCallableMock(spec_set=["check"]),
-            federation=NonCallableMock(spec_set=[
-                "handle_new_event",
-            ]),
             state_handler=NonCallableMock(spec_set=["handle_new_event"]),
         )
 
+        self.federation = NonCallableMock(spec_set=[
+            "handle_new_event",
+        ])
+
         self.datastore = hs.get_datastore()
         self.handlers = hs.get_handlers()
         self.notifier = hs.get_notifier()
-        self.federation = hs.get_federation()
         self.state_handler = hs.get_state_handler()
         self.hs = hs
 
+        self.handlers.federation_handler = self.federation
+
         self.handlers.room_creation_handler = RoomCreationHandler(self.hs)
         self.room_creation_handler = self.handlers.room_creation_handler