diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py
index a91d31ce61..ae88ed89aa 100644
--- a/tests/handlers/test_user_directory.py
+++ b/tests/handlers/test_user_directory.py
@@ -94,7 +94,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
# deactivate user
self.get_success(self.store.set_user_deactivated_status(r_user_id, True))
- self.get_success(self.handler.handle_user_deactivated(r_user_id))
+ self.get_success(self.handler.handle_local_user_deactivated(r_user_id))
# profile is not in directory
profile = self.get_success(self.store.get_user_in_directory(r_user_id))
@@ -118,7 +118,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
)
self.store.remove_from_user_dir = Mock(return_value=defer.succeed(None))
- self.get_success(self.handler.handle_user_deactivated(s_user_id))
+ self.get_success(self.handler.handle_local_user_deactivated(s_user_id))
self.store.remove_from_user_dir.not_called()
def test_handle_user_deactivated_regular_user(self):
@@ -127,7 +127,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
self.store.register_user(user_id=r_user_id, password_hash=None)
)
self.store.remove_from_user_dir = Mock(return_value=defer.succeed(None))
- self.get_success(self.handler.handle_user_deactivated(r_user_id))
+ self.get_success(self.handler.handle_local_user_deactivated(r_user_id))
self.store.remove_from_user_dir.called_once_with(r_user_id)
def test_private_room(self):
diff --git a/tests/rest/client/test_upgrade_room.py b/tests/rest/client/test_upgrade_room.py
index 72f976d8e2..a42388b26f 100644
--- a/tests/rest/client/test_upgrade_room.py
+++ b/tests/rest/client/test_upgrade_room.py
@@ -13,9 +13,11 @@
# limitations under the License.
from typing import Optional
+from synapse.api.constants import EventContentFields, EventTypes, RoomTypes
from synapse.config.server import DEFAULT_ROOM_VERSION
from synapse.rest import admin
from synapse.rest.client import login, room, room_upgrade_rest_servlet
+from synapse.server import HomeServer
from tests import unittest
from tests.server import FakeChannel
@@ -29,9 +31,8 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
room_upgrade_rest_servlet.register_servlets,
]
- def prepare(self, reactor, clock, hs):
+ def prepare(self, reactor, clock, hs: "HomeServer"):
self.store = hs.get_datastore()
- self.handler = hs.get_user_directory_handler()
self.creator = self.register_user("creator", "pass")
self.creator_token = self.login(self.creator, "pass")
@@ -42,13 +43,18 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
self.room_id = self.helper.create_room_as(self.creator, tok=self.creator_token)
self.helper.join(self.room_id, self.other, tok=self.other_token)
- def _upgrade_room(self, token: Optional[str] = None) -> FakeChannel:
+ def _upgrade_room(
+ self, token: Optional[str] = None, room_id: Optional[str] = None
+ ) -> FakeChannel:
# We never want a cached response.
self.reactor.advance(5 * 60 + 1)
+ if room_id is None:
+ room_id = self.room_id
+
return self.make_request(
"POST",
- "/_matrix/client/r0/rooms/%s/upgrade" % self.room_id,
+ f"/_matrix/client/r0/rooms/{room_id}/upgrade",
# This will upgrade a room to the same version, but that's fine.
content={"new_version": DEFAULT_ROOM_VERSION},
access_token=token or self.creator_token,
@@ -157,3 +163,56 @@ class UpgradeRoomTest(unittest.HomeserverTestCase):
tok=self.creator_token,
)
self.assertNotIn(self.other, power_levels["users"])
+
+ def test_space(self):
+ """Test upgrading a space."""
+
+ # Create a space.
+ space_id = self.helper.create_room_as(
+ self.creator,
+ tok=self.creator_token,
+ extra_content={
+ "creation_content": {EventContentFields.ROOM_TYPE: RoomTypes.SPACE}
+ },
+ )
+
+ # Add the room as a child room.
+ self.helper.send_state(
+ space_id,
+ event_type=EventTypes.SpaceChild,
+ body={"via": [self.hs.hostname]},
+ tok=self.creator_token,
+ state_key=self.room_id,
+ )
+
+ # Also add a room that was removed.
+ old_room_id = "!notaroom:" + self.hs.hostname
+ self.helper.send_state(
+ space_id,
+ event_type=EventTypes.SpaceChild,
+ body={},
+ tok=self.creator_token,
+ state_key=old_room_id,
+ )
+
+ # Upgrade the room!
+ channel = self._upgrade_room(room_id=space_id)
+ self.assertEquals(200, channel.code, channel.result)
+ self.assertIn("replacement_room", channel.json_body)
+
+ new_space_id = channel.json_body["replacement_room"]
+
+ state_ids = self.get_success(self.store.get_current_state_ids(new_space_id))
+
+ # Ensure the new room is still a space.
+ create_event = self.get_success(
+ self.store.get_event(state_ids[(EventTypes.Create, "")])
+ )
+ self.assertEqual(
+ create_event.content.get(EventContentFields.ROOM_TYPE), RoomTypes.SPACE
+ )
+
+ # The child link should have been copied over.
+ 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)
diff --git a/tests/rest/test_well_known.py b/tests/rest/test_well_known.py
index ac0e427752..b2c0279ba0 100644
--- a/tests/rest/test_well_known.py
+++ b/tests/rest/test_well_known.py
@@ -23,10 +23,13 @@ class WellKnownTests(unittest.HomeserverTestCase):
# replace the JsonResource with a WellKnownResource
return WellKnownResource(self.hs)
+ @unittest.override_config(
+ {
+ "public_baseurl": "https://tesths",
+ "default_identity_server": "https://testis",
+ }
+ )
def test_well_known(self):
- self.hs.config.public_baseurl = "https://tesths"
- self.hs.config.default_identity_server = "https://testis"
-
channel = self.make_request(
"GET", "/.well-known/matrix/client", shorthand=False
)
@@ -35,14 +38,17 @@ class WellKnownTests(unittest.HomeserverTestCase):
self.assertEqual(
channel.json_body,
{
- "m.homeserver": {"base_url": "https://tesths"},
+ "m.homeserver": {"base_url": "https://tesths/"},
"m.identity_server": {"base_url": "https://testis"},
},
)
+ @unittest.override_config(
+ {
+ "public_baseurl": None,
+ }
+ )
def test_well_known_no_public_baseurl(self):
- self.hs.config.public_baseurl = None
-
channel = self.make_request(
"GET", "/.well-known/matrix/client", shorthand=False
)
diff --git a/tests/unittest.py b/tests/unittest.py
index f2c90cc47b..7a6f5954d0 100644
--- a/tests/unittest.py
+++ b/tests/unittest.py
@@ -734,9 +734,9 @@ class TestTransportLayerServer(JsonResource):
FederationRateLimitConfig(
window_size=1,
sleep_limit=1,
- sleep_msec=1,
+ sleep_delay=1,
reject_limit=1000,
- concurrent_requests=1000,
+ concurrent=1000,
),
)
|