This commit is contained in:
Half-Shot
2026-02-13 11:56:48 +00:00
parent 517c340f2d
commit e361978637
2 changed files with 10 additions and 5 deletions
+3 -1
View File
@@ -499,7 +499,9 @@ class AppServiceHandlerTestCase(unittest.TestCase):
service.url = "mock_service_url"
return service
def _mkservice_url_preview(self, is_in_namespace=True, is_exclusive=False) -> Mock:
def _mkservice_url_preview(
self, is_in_namespace: bool = True, is_exclusive: bool = False
) -> Mock:
"""
Create a new mock representing an ApplicationService that is or is not interested
in any preview urls.
+7 -4
View File
@@ -130,7 +130,8 @@ class URLPreviewTests(unittest.HomeserverTestCase):
"""
Tests that previews fail if the appservice returns an empty response and is exclusive.
"""
query_preview_url = self.url_previewer.as_services.query_preview_url = (
# We assign to a method, which mypy doesn't like.
query_preview_url = self.url_previewer.as_services.query_preview_url = ( # type: ignore[method-assign]
AsyncMock()
)
query_preview_url.return_value = ApplicationServiceUrlPreviewResult(
@@ -147,7 +148,8 @@ class URLPreviewTests(unittest.HomeserverTestCase):
"""
Tests that previews succeed with an appservice provided result.
"""
query_preview_url = self.url_previewer.as_services.query_preview_url = (
# We assign to a method, which mypy doesn't like.
query_preview_url = self.url_previewer.as_services.query_preview_url = ( # type: ignore[method-assign]
AsyncMock()
)
query_preview_url.return_value = ApplicationServiceUrlPreviewResult(
@@ -166,9 +168,10 @@ class URLPreviewTests(unittest.HomeserverTestCase):
"""
Tests that previews fall through to the homeserver when the empty result is non-exclusive.
"""
do_preview_mock = self.url_previewer._do_preview = AsyncMock()
# We assign to a method, which mypy doesn't like.
do_preview_mock = self.url_previewer._do_preview = AsyncMock() # type: ignore[method-assign]
do_preview_mock.return_value = b"HS provided bytes"
query_preview_url = self.url_previewer.as_services.query_preview_url = (
query_preview_url = self.url_previewer.as_services.query_preview_url = ( # type: ignore[method-assign]
AsyncMock()
)
query_preview_url.return_value = ApplicationServiceUrlPreviewResult(