Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
96df3123
Unverified
Commit
96df3123
authored
2 years ago
by
Andrew Morgan
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a unit test for copying over arbitrary room types when upgrading a room (#12792)
parent
177b884a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/12792.feature
+1
-0
1 addition, 0 deletions
changelog.d/12792.feature
synapse/handlers/room.py
+1
-1
1 addition, 1 deletion
synapse/handlers/room.py
tests/rest/client/test_upgrade_room.py
+31
-1
31 additions, 1 deletion
tests/rest/client/test_upgrade_room.py
with
33 additions
and
2 deletions
changelog.d/12792.feature
0 → 100644
+
1
−
0
View file @
96df3123
Implement [MSC3818
:
Copy room type on upgrade](https
:
//github.com/matrix-org/matrix-spec-proposals/pull/3818).
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/handlers/room.py
+
1
−
1
View file @
96df3123
...
@@ -427,7 +427,7 @@ class RoomCreationHandler:
...
@@ -427,7 +427,7 @@ class RoomCreationHandler:
requester: the user requesting the upgrade
requester: the user requesting the upgrade
old_room_id : the id of the room to be replaced
old_room_id : the id of the room to be replaced
new_room_id: the id to give the new room (should already have been
new_room_id: the id to give the new room (should already have been
created with _ge
m
erate_room_id())
created with _ge
n
erate_room_id())
new_room_version: the new room version to use
new_room_version: the new room version to use
tombstone_event_id: the ID of the tombstone event in the old room.
tombstone_event_id: the ID of the tombstone event in the old room.
"""
"""
...
...
This diff is collapsed.
Click to expand it.
tests/rest/client/test_upgrade_room.py
+
31
−
1
View file @
96df3123
...
@@ -76,7 +76,7 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
...
@@ -76,7 +76,7 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
"""
"""
Upgrading a room should work fine.
Upgrading a room should work fine.
"""
"""
# T
H
e user isn't in the room.
# T
h
e user isn't in the room.
roomless
=
self
.
register_user
(
"
roomless
"
,
"
pass
"
)
roomless
=
self
.
register_user
(
"
roomless
"
,
"
pass
"
)
roomless_token
=
self
.
login
(
roomless
,
"
pass
"
)
roomless_token
=
self
.
login
(
roomless
,
"
pass
"
)
...
@@ -263,3 +263,33 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
...
@@ -263,3 +263,33 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
self
.
assertIn
((
EventTypes
.
SpaceChild
,
self
.
room_id
),
state_ids
)
self
.
assertIn
((
EventTypes
.
SpaceChild
,
self
.
room_id
),
state_ids
)
# The child that was removed should not be copied over.
# The child that was removed should not be copied over.
self
.
assertNotIn
((
EventTypes
.
SpaceChild
,
old_room_id
),
state_ids
)
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment