summary refs log tree commit diff
path: root/tests/handlers/test_federation.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2014-12-18 15:15:22 +0000
committerDavid Baker <dave@matrix.org>2014-12-18 15:15:22 +0000
commitb56730bb6e549e6b22c95858cae50e091de96844 (patch)
tree0eb011bc6b32a44df8c343ffedbc15e2ddd046e9 /tests/handlers/test_federation.py
parentschema version is now 10 (diff)
parentUpdate README.rst (diff)
downloadsynapse-b56730bb6e549e6b22c95858cae50e091de96844.tar.xz
Merge branch 'develop' into pushers
Conflicts:
	synapse/api/errors.py
	synapse/server.py
	synapse/storage/__init__.py
Diffstat (limited to 'tests/handlers/test_federation.py')
-rw-r--r--tests/handlers/test_federation.py55
1 files changed, 29 insertions, 26 deletions
diff --git a/tests/handlers/test_federation.py b/tests/handlers/test_federation.py
index 33016c16ef..ed21defd13 100644
--- a/tests/handlers/test_federation.py
+++ b/tests/handlers/test_federation.py
@@ -16,11 +16,8 @@
 from twisted.internet import defer
 from tests import unittest
 
-from synapse.api.events.room import (
-    MessageEvent,
-)
-
-from synapse.api.events import SynapseEvent
+from synapse.api.constants import EventTypes
+from synapse.events import FrozenEvent
 from synapse.handlers.federation import FederationHandler
 from synapse.server import HomeServer
 
@@ -37,7 +34,7 @@ class FederationTestCase(unittest.TestCase):
         self.mock_config.signing_key = [MockKey()]
 
         self.state_handler = NonCallableMock(spec_set=[
-            "annotate_event_with_state",
+            "compute_event_context",
         ])
 
         self.auth = NonCallableMock(spec_set=[
@@ -53,6 +50,8 @@ class FederationTestCase(unittest.TestCase):
                 "persist_event",
                 "store_room",
                 "get_room",
+                "get_destination_retry_timings",
+                "set_destination_retry_timings",
             ]),
             resource_for_federation=NonCallableMock(),
             http_client=NonCallableMock(spec_set=[]),
@@ -76,43 +75,47 @@ class FederationTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def test_msg(self):
-        pdu = SynapseEvent(
-            type=MessageEvent.TYPE,
-            room_id="foo",
-            content={"msgtype": u"fooo"},
-            origin_server_ts=0,
-            event_id="$a:b",
-            user_id="@a:b",
-            origin="b",
-            auth_events=[],
-            hashes={"sha256":"AcLrgtUIqqwaGoHhrEvYG1YLDIsVPYJdSRGhkp3jJp8"},
-        )
+        pdu = FrozenEvent({
+            "type": EventTypes.Message,
+            "room_id": "foo",
+            "content": {"msgtype": u"fooo"},
+            "origin_server_ts": 0,
+            "event_id": "$a:b",
+            "user_id":"@a:b",
+            "origin": "b",
+            "auth_events": [],
+            "hashes": {"sha256":"AcLrgtUIqqwaGoHhrEvYG1YLDIsVPYJdSRGhkp3jJp8"},
+        })
 
         self.datastore.persist_event.return_value = defer.succeed(None)
         self.datastore.get_room.return_value = defer.succeed(True)
         self.auth.check_host_in_room.return_value = defer.succeed(True)
 
         def annotate(ev, old_state=None):
-            ev.old_state_events = []
-            return defer.succeed(False)
-        self.state_handler.annotate_event_with_state.side_effect = annotate
+            context = Mock()
+            context.current_state = {}
+            context.auth_events = {}
+            return defer.succeed(context)
+        self.state_handler.compute_event_context.side_effect = annotate
 
         yield self.handlers.federation_handler.on_receive_pdu(
             "fo", pdu, False
         )
 
         self.datastore.persist_event.assert_called_once_with(
-            ANY, is_new_state=False, backfilled=False, current_state=None
+            ANY,
+            is_new_state=True,
+            backfilled=False,
+            current_state=None,
+            context=ANY,
         )
 
-        self.state_handler.annotate_event_with_state.assert_called_once_with(
-            ANY,
-            old_state=None,
+        self.state_handler.compute_event_context.assert_called_once_with(
+            ANY, old_state=None,
         )
 
         self.auth.check.assert_called_once_with(ANY, auth_events={})
 
         self.notifier.on_new_room_event.assert_called_once_with(
-            ANY,
-            extra_users=[]
+            ANY, extra_users=[]
         )