diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-08-27 13:34:28 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-08-27 14:32:19 +0100 |
commit | a03c7f27a8104d0e32642cb96faf24608dc2e27b (patch) | |
tree | 66e50f91396082e58643e32194fe0322735dcb92 /tests | |
parent | Remove unused populate_previous_pdus (diff) | |
download | synapse-a03c7f27a8104d0e32642cb96faf24608dc2e27b.tar.xz |
Fill out prev_events before calling persist_event
Diffstat (limited to 'tests')
-rw-r--r-- | tests/handlers/test_federation.py | 43 | ||||
-rw-r--r-- | tests/utils.py | 4 |
2 files changed, 29 insertions, 18 deletions
diff --git a/tests/handlers/test_federation.py b/tests/handlers/test_federation.py index a92d825f49..5ad40e484c 100644 --- a/tests/handlers/test_federation.py +++ b/tests/handlers/test_federation.py @@ -22,8 +22,9 @@ from synapse.api.events.room import ( from synapse.api.constants import Membership from synapse.handlers.federation import FederationHandler from synapse.server import HomeServer +from synapse.federation.units import Pdu -from mock import NonCallableMock +from mock import NonCallableMock, ANY import logging @@ -60,37 +61,42 @@ class FederationTestCase(unittest.TestCase): @defer.inlineCallbacks def test_msg(self): - event = self.hs.get_event_factory().create_event( - etype=MessageEvent.TYPE, - msg_id="bob", - room_id="foo", + pdu = Pdu( + pdu_type=MessageEvent.TYPE, + context="foo", content={"msgtype": u"fooo"}, + ts=0, + pdu_id="a", + origin="b", ) store_id = "ASD" self.datastore.persist_event.return_value = defer.succeed(store_id) self.datastore.get_room.return_value = defer.succeed(True) - yield self.handlers.federation_handler.on_receive(event, False, False) + yield self.handlers.federation_handler.on_receive_pdu(pdu, False) - self.datastore.persist_event.assert_called_once_with(event, False) + self.datastore.persist_event.assert_called_once_with(ANY, False) self.notifier.on_new_room_event.assert_called_once_with( - event, store_id) + ANY, store_id) @defer.inlineCallbacks def test_invite_join_target_this(self): room_id = "foo" user_id = "@bob:red" - event = self.hs.get_event_factory().create_event( - etype=InviteJoinEvent.TYPE, + pdu = Pdu( + pdu_type=InviteJoinEvent.TYPE, user_id=user_id, target_host=self.hostname, - room_id=room_id, + context=room_id, content={}, + ts=0, + pdu_id="a", + origin="b", ) - yield self.handlers.federation_handler.on_receive(event, False, False) + yield self.handlers.federation_handler.on_receive_pdu(pdu, False) mem_handler = self.handlers.room_member_handler self.assertEquals(1, mem_handler.change_membership.call_count) @@ -107,15 +113,18 @@ class FederationTestCase(unittest.TestCase): room_id = "foo" user_id = "@bob:red" - event = self.hs.get_event_factory().create_event( - etype=InviteJoinEvent.TYPE, + pdu = Pdu( + pdu_type=InviteJoinEvent.TYPE, user_id=user_id, - target_user_id="@red:not%s" % self.hostname, - room_id=room_id, + state_key="@red:not%s" % self.hostname, + context=room_id, content={}, + ts=0, + pdu_id="a", + origin="b", ) - yield self.handlers.federation_handler.on_receive(event, False, False) + yield self.handlers.federation_handler.on_receive_pdu(pdu, False) mem_handler = self.handlers.room_member_handler self.assertEquals(0, mem_handler.change_membership.call_count) diff --git a/tests/utils.py b/tests/utils.py index aa9608a1ed..6666b06931 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -127,7 +127,9 @@ class MemoryDataStore(object): self.current_state = {} self.events = [] - Snapshot = namedtuple("Snapshot", "room_id user_id membership_state") + class Snapshot(namedtuple("Snapshot", "room_id user_id membership_state")): + def fill_out_prev_events(self, event): + pass def snapshot_room(self, room_id, user_id, state_type=None, state_key=None): return self.Snapshot( |