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

Commit

Permalink
Add tests for /rooms/<room_id>/state cancellation
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Quah <[email protected]>
  • Loading branch information
Sean Quah committed May 6, 2022
1 parent 4fe06a0 commit 35aeaef
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/rest/client/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,49 @@ def test_member_event_from_ban(self) -> None:
)


class RoomStateTestCase(RoomBase, EndpointCancellationTestHelperMixin):
"""Tests /rooms/$room_id/state."""

user_id = "@sid1:red"

def test_get_state_cancellation(self) -> None:
"""Test cancellation of a `/rooms/$room_id/state` request."""
room_id = self.helper.create_room_as(self.user_id)
body = self._test_cancellation_at_every_await(
self.reactor,
lambda: self.make_request(
"GET", "/rooms/%s/state" % room_id, await_result=False
),
test_name="test_state_cancellation",
)

self.assertCountEqual(
[state_event["type"] for state_event in body],
{
"m.room.create",
"m.room.power_levels",
"m.room.join_rules",
"m.room.member",
"m.room.history_visibility",
},
)

def test_get_state_event_cancellation(self) -> None:
"""Test cancellation of a `/rooms/$room_id/state/$event_type` request."""
room_id = self.helper.create_room_as(self.user_id)
body = self._test_cancellation_at_every_await(
self.reactor,
lambda: self.make_request(
"GET",
"/rooms/%s/state/m.room.member/%s" % (room_id, self.user_id),
await_result=False,
),
test_name="test_state_cancellation",
)

self.assertEqual(body, {"membership": "join"})


class RoomsMemberListTestCase(RoomBase, EndpointCancellationTestHelperMixin):
"""Tests /rooms/$room_id/members/list REST events."""

Expand Down

0 comments on commit 35aeaef

Please sign in to comment.