|
@@ -1,5 +1,7 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
+import pathlib
|
|
|
+from typing import Generator
|
|
|
from unittest import mock
|
|
|
|
|
|
import pytest
|
|
@@ -9,13 +11,14 @@ from sentry.utils import assets
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
-def reset_cache():
|
|
|
- assets._frontend_versions.cache_clear()
|
|
|
+def reset_cache() -> Generator[None, None, None]:
|
|
|
+ # https://github.com/python/mypy/issues/5107
|
|
|
+ assets._frontend_versions.cache_clear() # type: ignore[attr-defined]
|
|
|
yield
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
-def self_hosted(tmp_path):
|
|
|
+def self_hosted(tmp_path: pathlib.Path) -> Generator[None, None, None]:
|
|
|
with mock.patch.object(settings, "STATIC_FRONTEND_APP_URL", "/_static/dist/"):
|
|
|
conf_dir = tmp_path.joinpath("conf")
|
|
|
conf_dir.mkdir()
|
|
@@ -24,7 +27,7 @@ def self_hosted(tmp_path):
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
-def getsentry_no_configmap(tmp_path):
|
|
|
+def getsentry_no_configmap(tmp_path: pathlib.Path) -> Generator[None, None, None]:
|
|
|
# shouldn't actually happen -- but make sure it still works!
|
|
|
with mock.patch.object(
|
|
|
settings, "STATIC_FRONTEND_APP_URL", "https://static.example.com/_static/dist/"
|
|
@@ -36,7 +39,7 @@ def getsentry_no_configmap(tmp_path):
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
-def getsentry(tmp_path):
|
|
|
+def getsentry(tmp_path: pathlib.Path) -> Generator[None, None, None]:
|
|
|
with mock.patch.object(
|
|
|
settings, "STATIC_FRONTEND_APP_URL", "https://static.example.com/_static/dist/"
|
|
|
):
|
|
@@ -51,19 +54,19 @@ def getsentry(tmp_path):
|
|
|
|
|
|
|
|
|
@pytest.mark.usefixtures("self_hosted")
|
|
|
-def test_frontend_app_asset_url_self_hosted():
|
|
|
+def test_frontend_app_asset_url_self_hosted() -> None:
|
|
|
ret = assets.get_frontend_app_asset_url("sentry", "entrypoints/app.js")
|
|
|
assert ret == "/_static/dist/sentry/entrypoints/app.js"
|
|
|
|
|
|
|
|
|
@pytest.mark.usefixtures("getsentry_no_configmap")
|
|
|
-def test_frontend_app_asset_url_getsentry_no_configmap():
|
|
|
+def test_frontend_app_asset_url_getsentry_no_configmap() -> None:
|
|
|
ret = assets.get_frontend_app_asset_url("sentry", "entrypoints/app.js")
|
|
|
assert ret == "https://static.example.com/_static/dist/sentry/entrypoints/app.js"
|
|
|
|
|
|
|
|
|
@pytest.mark.usefixtures("getsentry")
|
|
|
-def test_frontend_app_asset_url_getsentry():
|
|
|
+def test_frontend_app_asset_url_getsentry() -> None:
|
|
|
ret = assets.get_frontend_app_asset_url("sentry", "entrypoints/app.js")
|
|
|
assert (
|
|
|
ret == "https://static.example.com/_static/dist/sentry/entrypoints-hashed/app-deadbeef.js"
|