From b8ed35841d52724f53798efa681874d5edbc907e Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Thu, 11 Aug 2022 21:15:16 -0700 Subject: [PATCH] fix tests to accomodate new structure of DAG after room creation --- tests/handlers/test_sync.py | 9 +++++---- tests/rest/client/test_rooms.py | 4 ++-- tests/test_federation.py | 11 ++++------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/handlers/test_sync.py b/tests/handlers/test_sync.py index e3f38fbcc5..70be9ff9d6 100644 --- a/tests/handlers/test_sync.py +++ b/tests/handlers/test_sync.py @@ -222,9 +222,10 @@ class SyncTestCase(tests.unittest.HomeserverTestCase): ) self.assertEqual(len(alice_sync_result.joined), 1) self.assertEqual(alice_sync_result.joined[0].room_id, room_id) - last_room_creation_event_id = ( - alice_sync_result.joined[0].timeline.events[-1].event_id - ) + last_room_creation_event_ids = [ + alice_sync_result.joined[0].timeline.events[-1].event_id, + alice_sync_result.joined[0].timeline.events[-2].event_id, + ] # Eve, a ne'er-do-well, registers. eve = self.register_user("eve", "password") @@ -250,7 +251,7 @@ class SyncTestCase(tests.unittest.HomeserverTestCase): self.hs.get_datastores().main, "get_prev_events_for_room", new_callable=MagicMock, - return_value=make_awaitable([last_room_creation_event_id]), + return_value=make_awaitable(last_room_creation_event_ids), ) with mocked_get_prev_events: self.helper.join(room_id, eve, tok=eve_token) diff --git a/tests/rest/client/test_rooms.py b/tests/rest/client/test_rooms.py index aa2f578441..7d551c3810 100644 --- a/tests/rest/client/test_rooms.py +++ b/tests/rest/client/test_rooms.py @@ -710,7 +710,7 @@ class RoomsCreateTestCase(RoomBase): self.assertEqual(HTTPStatus.OK, channel.code, channel.result) self.assertTrue("room_id" in channel.json_body) assert channel.resource_usage is not None - self.assertEqual(44, channel.resource_usage.db_txn_count) + self.assertEqual(36, channel.resource_usage.db_txn_count) def test_post_room_initial_state(self) -> None: # POST with initial_state config key, expect new room id @@ -723,7 +723,7 @@ class RoomsCreateTestCase(RoomBase): self.assertEqual(HTTPStatus.OK, channel.code, channel.result) self.assertTrue("room_id" in channel.json_body) assert channel.resource_usage is not None - self.assertEqual(50, channel.resource_usage.db_txn_count) + self.assertEqual(38, channel.resource_usage.db_txn_count) def test_post_room_visibility_key(self) -> None: # POST with visibility config key, expect new room id diff --git a/tests/test_federation.py b/tests/test_federation.py index 779fad1f63..9260de891e 100644 --- a/tests/test_federation.py +++ b/tests/test_federation.py @@ -46,10 +46,9 @@ class MessageAcceptTests(unittest.HomeserverTestCase): user_id = UserID("us", "test") our_user = create_requester(user_id) room_creator = self.homeserver.get_room_creation_handler() + config = {"preset": "public_chat"} self.room_id = self.get_success( - room_creator.create_room( - our_user, room_creator._presets_dict["public_chat"], ratelimit=False - ) + room_creator.create_room(our_user, config, ratelimit=False) )[0]["room_id"] self.store = self.homeserver.get_datastores().main @@ -99,10 +98,8 @@ class MessageAcceptTests(unittest.HomeserverTestCase): ) # Make sure we actually joined the room - self.assertEqual( - self.get_success(self.store.get_latest_event_ids_in_room(self.room_id))[0], - "$join:test.serv", - ) + res = self.get_success(self.store.get_latest_event_ids_in_room(self.room_id)) + assert "$join:test.serv" in res def test_cant_hide_direct_ancestors(self): """