diff options
author | Erik Johnston <erik@matrix.org> | 2014-12-10 18:00:57 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-12-10 18:00:57 +0000 |
commit | 4d6af0dde3c8489928312060b7d2c69181a8dc41 (patch) | |
tree | f7f9e50810988f1342a1d120b465a538617facc9 /tests/storage/test_stream.py | |
parent | .from_string() no longer takes a HS (diff) | |
download | synapse-4d6af0dde3c8489928312060b7d2c69181a8dc41.tar.xz |
Fix some tests
Diffstat (limited to 'tests/storage/test_stream.py')
-rw-r--r-- | tests/storage/test_stream.py | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/tests/storage/test_stream.py b/tests/storage/test_stream.py index 5038546aee..cba65bb9f0 100644 --- a/tests/storage/test_stream.py +++ b/tests/storage/test_stream.py @@ -21,7 +21,9 @@ from synapse.server import HomeServer from synapse.api.constants import Membership from synapse.api.events.room import RoomMemberEvent, MessageEvent -from tests.utils import SQLiteMemoryDbPool +from tests.utils import SQLiteMemoryDbPool, MockKey + +from mock import Mock class StreamStoreTestCase(unittest.TestCase): @@ -31,13 +33,21 @@ class StreamStoreTestCase(unittest.TestCase): db_pool = SQLiteMemoryDbPool() yield db_pool.prepare() + self.mock_config = Mock() + self.mock_config.signing_key = [MockKey()] + hs = HomeServer( "test", db_pool=db_pool, + config=self.mock_config, + resource_for_federation=Mock(), + http_client=None, ) self.store = hs.get_datastore() - self.event_factory = hs.get_event_factory() + self.event_builder_factory = hs.get_event_builder_factory() + self.handlers = hs.get_handlers() + self.message_handler = self.handlers.message_handler self.u_alice = hs.parse_userid("@alice:test") self.u_bob = hs.parse_userid("@bob:test") @@ -51,55 +61,40 @@ class StreamStoreTestCase(unittest.TestCase): def inject_room_member(self, room, user, membership, replaces_state=None): self.depth += 1 - event = self.event_factory.create_event( - etype=RoomMemberEvent.TYPE, - user_id=user.to_string(), - state_key=user.to_string(), - room_id=room.to_string(), - membership=membership, - content={"membership": membership}, - depth=self.depth, - prev_events=[], - ) - - event.state_events = None - event.hashes = {} - event.prev_state = [] - event.auth_events = [] - - if replaces_state: - event.prev_state = [(replaces_state, "hash")] - event.replaces_state = replaces_state + builder = self.event_builder_factory.new({ + "type": RoomMemberEvent.TYPE, + "sender": user.to_string(), + "state_key": user.to_string(), + "room_id": room.to_string(), + "content": {"membership": membership}, + }) - # Have to create a join event using the eventfactory - yield self.store.persist_event( - event + event, context = yield self.message_handler._create_new_client_event( + builder ) + yield self.store.persist_event(event, context) + defer.returnValue(event) @defer.inlineCallbacks def inject_message(self, room, user, body): self.depth += 1 - event = self.event_factory.create_event( - etype=MessageEvent.TYPE, - user_id=user.to_string(), - room_id=room.to_string(), - content={"body": body, "msgtype": u"message"}, - depth=self.depth, - prev_events=[], - ) - - event.state_events = None - event.hashes = {} - event.auth_events = [] + builder = self.event_builder_factory.new({ + "type": MessageEvent.TYPE, + "sender": user.to_string(), + "state_key": user.to_string(), + "room_id": room.to_string(), + "content": {"body": body, "msgtype": u"message"}, + }) - # Have to create a join event using the eventfactory - yield self.store.persist_event( - event + event, context = yield self.message_handler._create_new_client_event( + builder ) + yield self.store.persist_event(event, context) + @defer.inlineCallbacks def test_event_stream_get_other(self): # Both bob and alice joins the room |