Browse Source

ref: type test_assets (#51409)

<!-- Describe your PR here. -->
anthony sottile 1 year ago
parent
commit
d08340a888
2 changed files with 11 additions and 9 deletions
  1. 0 1
      pyproject.toml
  2. 11 8
      tests/sentry/utils/test_assets.py

+ 0 - 1
pyproject.toml

@@ -1652,7 +1652,6 @@ module = [
     "tests.sentry.utils.locking.backends.test_redis",
     "tests.sentry.utils.suspect_resolutions.test_get_suspect_resolutions",
     "tests.sentry.utils.suspect_resolutions.test_metric_correlation",
-    "tests.sentry.utils.test_assets",
     "tests.sentry.utils.test_audit",
     "tests.sentry.utils.test_auth",
     "tests.sentry.utils.test_committers",

+ 11 - 8
tests/sentry/utils/test_assets.py

@@ -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"