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

Commit

Permalink
Add a test for upgrading a room with a custom room type
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed May 19, 2022
1 parent 29600f1 commit 6b2dd48
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/rest/client/test_upgrade_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,33 @@ def test_space(self) -> None:
self.assertIn((EventTypes.SpaceChild, self.room_id), state_ids)
# The child that was removed should not be copied over.
self.assertNotIn((EventTypes.SpaceChild, old_room_id), state_ids)

def test_custom_room_type(self) -> None:
"""Test upgrading a room that has a custom room type set."""
test_room_type = "com.example.my_custom_room_type"

# Create a room with a custom room type.
room_id = self.helper.create_room_as(
self.creator,
tok=self.creator_token,
extra_content={
"creation_content": {EventContentFields.ROOM_TYPE: test_room_type}
},
)

# Upgrade the room!
channel = self._upgrade_room(room_id=room_id)
self.assertEqual(200, channel.code, channel.result)
self.assertIn("replacement_room", channel.json_body)

new_room_id = channel.json_body["replacement_room"]

state_ids = self.get_success(self.store.get_current_state_ids(new_room_id))

# Ensure the new room is the same type as the old room.
create_event = self.get_success(
self.store.get_event(state_ids[(EventTypes.Create, "")])
)
self.assertEqual(
create_event.content.get(EventContentFields.ROOM_TYPE), test_room_type
)

0 comments on commit 6b2dd48

Please sign in to comment.