From 479679d47c3277c8c1f41610f2aab2062203876a Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 15 Apr 2022 20:28:58 -0600 Subject: [PATCH] tests: update for new media repo structure Signed-off-by: Sumner Evans --- tests/replication/test_multi_media_repo.py | 4 +++- tests/rest/admin/test_admin.py | 4 ++-- tests/rest/admin/test_media.py | 12 ++++++------ tests/rest/admin/test_statistics.py | 2 +- tests/rest/admin/test_user.py | 4 ++-- tests/rest/media/v1/test_media_storage.py | 8 ++++---- tests/rest/media/v1/test_url_preview.py | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/replication/test_multi_media_repo.py b/tests/replication/test_multi_media_repo.py index 13aa5eb51aa5..7c4f594115d7 100644 --- a/tests/replication/test_multi_media_repo.py +++ b/tests/replication/test_multi_media_repo.py @@ -65,7 +65,9 @@ def _get_media_req( The channel for the *client* request and the *outbound* request for the media which the caller should respond to. """ - resource = hs.get_media_repository_resource().children[b"download"] + resource = ( + hs.get_media_repository_resource().children[b"r0"].children[b"download"] + ) channel = make_request( self.reactor, FakeSite(resource, self.reactor), diff --git a/tests/rest/admin/test_admin.py b/tests/rest/admin/test_admin.py index 82ac5991e6e4..f914b6d7e4d6 100644 --- a/tests/rest/admin/test_admin.py +++ b/tests/rest/admin/test_admin.py @@ -61,8 +61,8 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase): def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # Allow for uploading and downloading to/from the media repo self.media_repo = hs.get_media_repository_resource() - self.download_resource = self.media_repo.children[b"download"] - self.upload_resource = self.media_repo.children[b"upload"] + self.download_resource = self.media_repo.children[b"v3"].children[b"download"] + self.upload_resource = self.media_repo.children[b"v3"].children[b"upload"] def _ensure_quarantined( self, admin_user_tok: str, server_and_media_id: str diff --git a/tests/rest/admin/test_media.py b/tests/rest/admin/test_media.py index e909e444ac1b..d66931b569ff 100644 --- a/tests/rest/admin/test_media.py +++ b/tests/rest/admin/test_media.py @@ -123,8 +123,8 @@ def test_delete_media(self) -> None: Tests that delete a media is successfully """ - download_resource = self.media_repo.children[b"download"] - upload_resource = self.media_repo.children[b"upload"] + download_resource = self.media_repo.children[b"v3"].children[b"download"] + upload_resource = self.media_repo.children[b"v3"].children[b"upload"] # Upload some media into the room response = self.helper.upload_media( @@ -562,7 +562,7 @@ def _create_media(self) -> str: """ Create a media and return media_id and server_and_media_id """ - upload_resource = self.media_repo.children[b"upload"] + upload_resource = self.media_repo.children[b"v3"].children[b"upload"] # Upload some media into the room response = self.helper.upload_media( @@ -586,7 +586,7 @@ def _access_media( """ Try to access a media and check the result """ - download_resource = self.media_repo.children[b"download"] + download_resource = self.media_repo.children[b"v3"].children[b"download"] media_id = server_and_media_id.split("/")[1] local_path = self.filepaths.local_media_filepath(media_id) @@ -641,7 +641,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.admin_user_tok = self.login("admin", "pass") # Create media - upload_resource = media_repo.children[b"upload"] + upload_resource = media_repo.children[b"v3"].children[b"upload"] # Upload some media into the room response = self.helper.upload_media( @@ -778,7 +778,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.admin_user_tok = self.login("admin", "pass") # Create media - upload_resource = media_repo.children[b"upload"] + upload_resource = media_repo.children[b"v3"].children[b"upload"] # Upload some media into the room response = self.helper.upload_media( diff --git a/tests/rest/admin/test_statistics.py b/tests/rest/admin/test_statistics.py index 7cb8ec57bad9..497872b0c68f 100644 --- a/tests/rest/admin/test_statistics.py +++ b/tests/rest/admin/test_statistics.py @@ -511,7 +511,7 @@ def _create_media(self, user_token: str, number_media: int) -> None: user_token: Access token of the user number_media: Number of media to be created for the user """ - upload_resource = self.media_repo.children[b"upload"] + upload_resource = self.media_repo.children[b"v3"].children[b"upload"] for _ in range(number_media): # Upload some media into the room self.helper.upload_media( diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py index 0cdf1dec4042..1349e92db062 100644 --- a/tests/rest/admin/test_user.py +++ b/tests/rest/admin/test_user.py @@ -3243,8 +3243,8 @@ def _create_media_and_access( Returns: The ID of the newly created media. """ - upload_resource = self.media_repo.children[b"upload"] - download_resource = self.media_repo.children[b"download"] + upload_resource = self.media_repo.children[b"v3"].children[b"upload"] + download_resource = self.media_repo.children[b"v3"].children[b"download"] # Upload some media into the room response = self.helper.upload_media( diff --git a/tests/rest/media/v1/test_media_storage.py b/tests/rest/media/v1/test_media_storage.py index 7204b2dfe075..952a9202727c 100644 --- a/tests/rest/media/v1/test_media_storage.py +++ b/tests/rest/media/v1/test_media_storage.py @@ -253,8 +253,8 @@ def write_to(r): def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: media_resource = hs.get_media_repository_resource() - self.download_resource = media_resource.children[b"download"] - self.thumbnail_resource = media_resource.children[b"thumbnail"] + self.download_resource = media_resource.children[b"v3"].children[b"download"] + self.thumbnail_resource = media_resource.children[b"v3"].children[b"thumbnail"] self.store = hs.get_datastores().main self.media_repo = hs.get_media_repository() @@ -605,8 +605,8 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # Allow for uploading and downloading to/from the media repo self.media_repo = hs.get_media_repository_resource() - self.download_resource = self.media_repo.children[b"download"] - self.upload_resource = self.media_repo.children[b"upload"] + self.download_resource = self.media_repo.children[b"v3"].children[b"download"] + self.upload_resource = self.media_repo.children[b"v3"].children[b"upload"] load_legacy_spam_checkers(hs) diff --git a/tests/rest/media/v1/test_url_preview.py b/tests/rest/media/v1/test_url_preview.py index 3b24d0ace622..dcde20651f9a 100644 --- a/tests/rest/media/v1/test_url_preview.py +++ b/tests/rest/media/v1/test_url_preview.py @@ -120,7 +120,7 @@ def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer: def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: self.media_repo = hs.get_media_repository_resource() - self.preview_url = self.media_repo.children[b"preview_url"] + self.preview_url = self.media_repo.children[b"v3"].children[b"preview_url"] self.lookups: Dict[str, Any] = {}