Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Allow specifying room version in 'RestHelper.create_room_as' and add …
Browse files Browse the repository at this point in the history
…typing (#8854)

This PR adds a `room_version` argument to the `RestHelper`'s `create_room_as` function for tests. I plan to use this for testing knocking, which currently uses an unstable room version.
  • Loading branch information
anoadragon453 authored Dec 2, 2020
1 parent 4d94965 commit edb3d3f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/8854.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow for specifying a room version when creating a room in unit tests via `RestHelper.create_room_as`.
27 changes: 25 additions & 2 deletions tests/rest/client/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,37 @@ class RestHelper:
auth_user_id = attr.ib()

def create_room_as(
self, room_creator=None, is_public=True, tok=None, expect_code=200,
):
self,
room_creator: str = None,
is_public: bool = True,
room_version: str = None,
tok: str = None,
expect_code: int = 200,
) -> str:
"""
Create a room.
Args:
room_creator: The user ID to create the room with.
is_public: If True, the `visibility` parameter will be set to the
default (public). Otherwise, the `visibility` parameter will be set
to "private".
room_version: The room version to create the room as. Defaults to Synapse's
default room version.
tok: The access token to use in the request.
expect_code: The expected HTTP response code.
Returns:
The ID of the newly created room.
"""
temp_id = self.auth_user_id
self.auth_user_id = room_creator
path = "/_matrix/client/r0/createRoom"
content = {}
if not is_public:
content["visibility"] = "private"
if room_version:
content["room_version"] = room_version
if tok:
path = path + "?access_token=%s" % tok

Expand Down

0 comments on commit edb3d3f

Please sign in to comment.