sadpandajoe commented on code in PR #39914:
URL: https://github.com/apache/superset/pull/39914#discussion_r3508325320


##########
tests/unit_tests/utils/slack_test.py:
##########
@@ -216,3 +226,192 @@ def test_handle_pagination_multiple_pages(self, mocker):
             {"name": "general", "id": "C12345"},
             {"name": "random", "id": "C67890"},
         ]
+
+
+# ---------------------------------------------------------------------------
+# should_use_v2_api: drives the v1→v2 auto-upgrade decision and emits
+# DeprecationWarning + logger.warning for both no-flag and missing-scope cases.
+# ---------------------------------------------------------------------------
+
+
[email protected](autouse=True)
+def _reset_v1_warning_caches():

Review Comment:
   The `_reset_v1_warning_caches` autouse fixture is intentionally left 
unannotated. Test modules are covered by the `[[tool.mypy.overrides]] module = 
"tests.*"` block in pyproject.toml (`disallow_untyped_defs = false`, 
`check_untyped_defs = false`), so a return annotation is not required and 
mypy/ruff already pass on this branch. Skipping to keep it consistent with the 
other fixtures in this file.



##########
tests/unit_tests/utils/slack_test.py:
##########
@@ -216,3 +226,192 @@ def test_handle_pagination_multiple_pages(self, mocker):
             {"name": "general", "id": "C12345"},
             {"name": "random", "id": "C67890"},
         ]
+
+
+# ---------------------------------------------------------------------------
+# should_use_v2_api: drives the v1→v2 auto-upgrade decision and emits
+# DeprecationWarning + logger.warning for both no-flag and missing-scope cases.
+# ---------------------------------------------------------------------------
+
+
[email protected](autouse=True)
+def _reset_v1_warning_caches():
+    """Each test sees fresh once-per-process warning state.
+
+    The deprecation emitters are wrapped in `functools.cache` to give
+    thread-safe one-shot semantics in production. Tests need them to fire
+    again, so we clear the cache before and after each case.
+    """
+    _emit_v1_flag_off_deprecation.cache_clear()
+    _emit_v1_scope_missing_deprecation.cache_clear()
+    yield
+    _emit_v1_flag_off_deprecation.cache_clear()
+    _emit_v1_scope_missing_deprecation.cache_clear()
+
+
+class TestShouldUseV2Api:

Review Comment:
   No docstring is needed on `TestShouldUseV2Api`: the explanatory 
section-comment block directly above the class (lines 302-305) already 
documents what this group of tests covers, and the `tests.*` mypy override plus 
ruff config don't require class docstrings in test modules. Skipping.



##########
tests/unit_tests/utils/slack_test.py:
##########
@@ -216,3 +226,192 @@ def test_handle_pagination_multiple_pages(self, mocker):
             {"name": "general", "id": "C12345"},
             {"name": "random", "id": "C67890"},
         ]
+
+
+# ---------------------------------------------------------------------------
+# should_use_v2_api: drives the v1→v2 auto-upgrade decision and emits
+# DeprecationWarning + logger.warning for both no-flag and missing-scope cases.
+# ---------------------------------------------------------------------------
+
+
[email protected](autouse=True)
+def _reset_v1_warning_caches():
+    """Each test sees fresh once-per-process warning state.
+
+    The deprecation emitters are wrapped in `functools.cache` to give
+    thread-safe one-shot semantics in production. Tests need them to fire
+    again, so we clear the cache before and after each case.
+    """
+    _emit_v1_flag_off_deprecation.cache_clear()
+    _emit_v1_scope_missing_deprecation.cache_clear()
+    yield
+    _emit_v1_flag_off_deprecation.cache_clear()
+    _emit_v1_scope_missing_deprecation.cache_clear()
+
+
+class TestShouldUseV2Api:
+    def test_returns_true_when_flag_on_and_scopes_present(self, mocker):

Review Comment:
   `test_returns_true_when_flag_on_and_scopes_present` is deliberately left 
untyped (`mocker`, `-> None`). The `[[tool.mypy.overrides]] module = "tests.*"` 
block in pyproject.toml relaxes 
`disallow_untyped_defs`/`disallow_untyped_calls`, so no hints or explicit 
`None` return are required and mypy/ruff already pass. Skipping to match the 
rest of the test methods here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to