summary refs log tree commit diff
path: root/tests/rest
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-04-22 18:29:56 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-04-22 18:29:56 +0100
commitf22d69bcf311b073aaae1f8a01e043dcba1812e3 (patch)
treedc4c2f3edbb5d1a1dbae8de21f7a86f96f20658d /tests/rest
parentMerge commit '2547d9d4d' into anoa/dinsic_release_1_31_0 (diff)
parentMerge remote-tracking branch 'origin/develop' into jaywink/admin-forward-extr... (diff)
downloadsynapse-f22d69bcf311b073aaae1f8a01e043dcba1812e3.tar.xz
Merge commit 'fdf834694' into anoa/dinsic_release_1_31_0
Diffstat (limited to 'tests/rest')
-rw-r--r--tests/rest/media/v1/test_media_storage.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/rest/media/v1/test_media_storage.py b/tests/rest/media/v1/test_media_storage.py

index ae2b32b131..a6c6985173 100644 --- a/tests/rest/media/v1/test_media_storage.py +++ b/tests/rest/media/v1/test_media_storage.py
@@ -202,7 +202,6 @@ class MediaRepoTests(unittest.HomeserverTestCase): config = self.default_config() config["media_store_path"] = self.media_store_path - config["thumbnail_requirements"] = {} config["max_image_pixels"] = 2000000 provider_config = { @@ -313,15 +312,39 @@ class MediaRepoTests(unittest.HomeserverTestCase): self.assertEqual(headers.getRawHeaders(b"Content-Disposition"), None) def test_thumbnail_crop(self): + """Test that a cropped remote thumbnail is available.""" self._test_thumbnail( "crop", self.test_image.expected_cropped, self.test_image.expected_found ) def test_thumbnail_scale(self): + """Test that a scaled remote thumbnail is available.""" self._test_thumbnail( "scale", self.test_image.expected_scaled, self.test_image.expected_found ) + def test_invalid_type(self): + """An invalid thumbnail type is never available.""" + self._test_thumbnail("invalid", None, False) + + @unittest.override_config( + {"thumbnail_sizes": [{"width": 32, "height": 32, "method": "scale"}]} + ) + def test_no_thumbnail_crop(self): + """ + Override the config to generate only scaled thumbnails, but request a cropped one. + """ + self._test_thumbnail("crop", None, False) + + @unittest.override_config( + {"thumbnail_sizes": [{"width": 32, "height": 32, "method": "crop"}]} + ) + def test_no_thumbnail_scale(self): + """ + Override the config to generate only cropped thumbnails, but request a scaled one. + """ + self._test_thumbnail("scale", None, False) + def _test_thumbnail(self, method, expected_body, expected_found): params = "?width=32&height=32&method=" + method channel = make_request(