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

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
Fix test by checking against a sorted room_id array. If there are multiple
rooms with equal order_by values, individual rooms that share this same
value are ordered by room_id. "version", "creator", "encryption"
"federatable", "join_rules", "guest_access", "history_visibility" all
have multiple rooms with the same value, thus need this specifically
ordered id list.
  • Loading branch information
dsonck92 committed Jan 13, 2022
1 parent 942a055 commit 2fdeced
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions tests/rest/admin/test_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,8 @@ def test_list_rooms(self) -> None:
)
room_ids.append(room_id)

room_ids.sort()

# Request the list of rooms
url = "/_synapse/admin/v1/rooms"
channel = self.make_request(
Expand Down Expand Up @@ -1360,6 +1362,10 @@ def _order_test(
room_id_2 = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok)
room_id_3 = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok)

# Also create a list sorted by IDs for properties that are equal (and thus sorted by room_id)
all_ids = [room_id_1, room_id_2, room_id_3]
all_ids.sort()

# Set room names in alphabetical order. room 1 -> A, 2 -> B, 3 -> C
self.helper.send_state(
room_id_1,
Expand Down Expand Up @@ -1413,31 +1419,31 @@ def _order_test(
"joined_local_members", [room_id_1, room_id_2, room_id_3], reverse=True
)

_order_test("version", [room_id_1, room_id_2, room_id_3])
_order_test("version", [room_id_1, room_id_2, room_id_3], reverse=True)
_order_test("version", all_ids)
_order_test("version", all_ids, reverse=True)

_order_test("creator", [room_id_1, room_id_2, room_id_3])
_order_test("creator", [room_id_1, room_id_2, room_id_3], reverse=True)
_order_test("creator", all_ids)
_order_test("creator", all_ids, reverse=True)

_order_test("encryption", [room_id_1, room_id_2, room_id_3])
_order_test("encryption", [room_id_1, room_id_2, room_id_3], reverse=True)
_order_test("encryption", all_ids)
_order_test("encryption", all_ids, reverse=True)

_order_test("federatable", [room_id_1, room_id_2, room_id_3])
_order_test("federatable", [room_id_1, room_id_2, room_id_3], reverse=True)
_order_test("federatable", all_ids)
_order_test("federatable", all_ids, reverse=True)

_order_test("public", [room_id_1, room_id_2, room_id_3])
_order_test("public", all_ids)
# Different sort order of SQlite and PostreSQL
# _order_test("public", [room_id_3, room_id_2, room_id_1], reverse=True)

_order_test("join_rules", [room_id_1, room_id_2, room_id_3])
_order_test("join_rules", [room_id_1, room_id_2, room_id_3], reverse=True)
_order_test("join_rules", all_ids)
_order_test("join_rules", all_ids, reverse=True)

_order_test("guest_access", [room_id_1, room_id_2, room_id_3])
_order_test("guest_access", [room_id_1, room_id_2, room_id_3], reverse=True)
_order_test("guest_access", all_ids)
_order_test("guest_access", all_ids, reverse=True)

_order_test("history_visibility", [room_id_1, room_id_2, room_id_3])
_order_test("history_visibility", all_ids)
_order_test(
"history_visibility", [room_id_1, room_id_2, room_id_3], reverse=True
"history_visibility", all_ids, reverse=True
)

_order_test("state_events", [room_id_3, room_id_2, room_id_1])
Expand Down

0 comments on commit 2fdeced

Please sign in to comment.