Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test: remove obsolete route rate-limit fixture (#6366)

Morax2c1aeff0f444
diff --git a/tests/test_rate_limiter_storage_reset.py b/tests/test_rate_limiter_storage_reset.py
new file mode 100644
index 0000000000..1110956e32
--- /dev/null
+++ b/tests/test_rate_limiter_storage_reset.py
@@ -0,0 +1,42 @@
+"""Regression coverage for shared rate-limit storage isolation."""
+
+from inspect import unwrap
+
+import pytest
+from limits import parse
+
+from local_deep_research.web.dependencies import rate_limit
+from tests import conftest as shared_fixtures
+
+
[email protected]("enabled", [True, False], ids=["enabled", "disabled"])
+def test_shared_fixture_resets_storage_without_changing_enforcement(
+ monkeypatch: pytest.MonkeyPatch, enabled: bool
+) -> None:
+ """Both fixture phases clear storage without changing enforcement settings."""
+ limiter = rate_limit.limiter
+ monkeypatch.setattr(limiter, "enabled", enabled)
+ rate = parse("1 per hour")
+ scope = "route-fixture-reset-regression"
+ limiter.reset()
+ reset_fixture = unwrap(shared_fixtures.reset_all_singletons)()
+
+ try:
+ assert limiter._limiter.hit(rate, scope)
+ assert not limiter._limiter.hit(rate, scope)
+
+ next(reset_fixture)
+
+ assert limiter._limiter.hit(rate, scope)
+ assert not limiter._limiter.hit(rate, scope)
+ assert limiter.enabled is enabled
+
+ with pytest.raises(StopIteration):
+ next(reset_fixture)
+
+ assert limiter._limiter.hit(rate, scope)
+ assert not limiter._limiter.hit(rate, scope)
+ assert limiter.enabled is enabled
+ finally:
+ reset_fixture.close()
+ limiter.reset()
diff --git a/tests/web/routes/conftest.py b/tests/web/routes/conftest.py
deleted file mode 100644
index 70accd09f7..0000000000
--- a/tests/web/routes/conftest.py
+++ /dev/null
@@ -1,34 +0,0 @@
-"""Shared fixtures for web route tests.
-
-The Flask-Limiter ``limiter`` is a module-level singleton whose in-memory
-storage is attached once at ``create_app()`` time and never reset between
-tests. Without intervention the per-scope request counters (notably the
-shared ``settings`` scope, "30 per minute") accumulate across every test
-in the process that hits a rate-limited route — so unrelated tests that
-make their 31st settings request in a 60-second window get an unexpected
-HTTP 429 instead of the status they assert. The failing set is
-non-deterministic because it depends on how many sibling requests landed
-in the trailing window.
-
-Resetting the storage before each test gives every test a clean bucket
-without disabling enforcement, so rate-limiting tests
-(test_settings_routes_rate_limiting.py) still exercise real limits from a
-known-clean starting point.
-"""
-
-import pytest
-
-
[email protected](autouse=True)
-def _reset_rate_limiter_storage():
- """Clear the global limiter's storage before each route test."""
- try:
- from local_deep_research.security.rate_limiter import limiter
-
- storage = getattr(limiter, "_storage", None)
- if storage is not None and hasattr(storage, "reset"):
- storage.reset()
- except Exception:
- # Limiter not importable / no storage yet → nothing to reset.
- pass
- yield