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

Commit

Permalink
Make is_public Optional[bool] for create_room_as test util (#10951) (#…
Browse files Browse the repository at this point in the history
…10963)

Signed-off-by: Andrew Ferrazzutti <[email protected]>
  • Loading branch information
AndrewFerr authored Oct 4, 2021
1 parent 730b40d commit 30f0240
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.d/10963.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the test utility function `create_room_as` so that `is_public=True` will explicitly set the `visibility` parameter of room creation requests to `public`. Contributed by @AndrewFerr.
13 changes: 7 additions & 6 deletions tests/rest/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RestHelper:
def create_room_as(
self,
room_creator: Optional[str] = None,
is_public: bool = True,
is_public: Optional[bool] = None,
room_version: Optional[str] = None,
tok: Optional[str] = None,
expect_code: int = 200,
Expand All @@ -62,9 +62,10 @@ def create_room_as(
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".
is_public: If True, the `visibility` parameter will be set to
"public". If False, it will be set to "private". If left
unspecified, the server will set it to an appropriate default
(which should be "private" as per the CS spec).
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.
Expand All @@ -77,8 +78,8 @@ def create_room_as(
self.auth_user_id = room_creator
path = "/_matrix/client/r0/createRoom"
content = extra_content or {}
if not is_public:
content["visibility"] = "private"
if is_public is not None:
content["visibility"] = "public" if is_public else "private"
if room_version:
content["room_version"] = room_version
if tok:
Expand Down

0 comments on commit 30f0240

Please sign in to comment.