From 35aeaeffdecab8e99967545bce867e9794a11939 Mon Sep 17 00:00:00 2001 From: Sean Quah Date: Fri, 6 May 2022 22:59:35 +0100 Subject: [PATCH] Add tests for `/rooms//state` cancellation Signed-off-by: Sean Quah --- tests/rest/client/test_rooms.py | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index 7869f3f7d437..1d1af1f18a1a 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -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."""