diff options
author | Erik Johnston <erik@matrix.org> | 2018-08-09 14:33:49 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-08-09 14:58:49 +0100 |
commit | 3e19beb941f3f797262b051d47227018898bb36f (patch) | |
tree | 95b6f79073e75c594be032dc86dbb52791ba6f08 /tests/utils.py | |
parent | Add fast path in state res for zero prev events (diff) | |
download | synapse-3e19beb941f3f797262b051d47227018898bb36f.tar.xz |
Fix tests
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py index 3f17304934..8930a3a230 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -21,6 +21,7 @@ from six.moves.urllib import parse as urlparse from twisted.internet import defer, reactor +from synapse.api.constants import EventTypes from synapse.api.errors import CodeMessageException, cs_error from synapse.federation.transport import server from synapse.http.server import HttpServer @@ -445,3 +446,32 @@ class DeferredMockCallable(object): "call(%s)" % _format_call(c[0], c[1]) for c in calls ]) ) + + +@defer.inlineCallbacks +def create_room(hs, room_id, creator_id): + """Creates and persist a creation event for the given room + + Args: + hs + room_id (str) + creator_id (str) + """ + + store = hs.get_datastore() + event_builder_factory = hs.get_event_builder_factory() + event_creation_handler = hs.get_event_creation_handler() + + builder = event_builder_factory.new({ + "type": EventTypes.Create, + "state_key": "", + "sender": creator_id, + "room_id": room_id, + "content": {}, + }) + + event, context = yield event_creation_handler.create_new_client_event( + builder + ) + + yield store.persist_event(event, context) |