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

Commit

Permalink
tests: update paths for new media repo structure
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <[email protected]>
  • Loading branch information
sumnerevans committed May 30, 2022
1 parent 4780a92 commit 381c8c8
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 49 deletions.
4 changes: 3 additions & 1 deletion tests/replication/test_multi_media_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions tests/rest/admin/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/rest/admin/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/admin/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tests/rest/media/v1/test_media_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 381c8c8

Please sign in to comment.