|
12 | 12 | ) |
13 | 13 | settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default")) |
14 | 14 |
|
15 | | -import pytest |
16 | | -from fastapi.testclient import TestClient |
17 | | -from qdrant_client import QdrantClient |
| 15 | +import pytest # noqa: E402 |
| 16 | +from fastapi.testclient import TestClient # noqa: E402 |
| 17 | +from qdrant_client import QdrantClient # noqa: E402 |
18 | 18 |
|
19 | | -from rag_engine.api.app import create_app |
20 | | -from rag_engine.services.gdpr import GDPRService |
21 | | -from rag_engine.storage.bm25_store import BM25Store |
22 | | -from rag_engine.storage.knowledge_graph import KnowledgeGraphStore |
23 | | -from rag_engine.storage.qdrant_store import QdrantStore |
| 19 | +from rag_engine.api.app import create_app # noqa: E402 |
| 20 | +from rag_engine.api.routes.rate_limit import limiter # noqa: E402 |
| 21 | +from rag_engine.services.gdpr import GDPRService # noqa: E402 |
| 22 | +from rag_engine.storage.bm25_store import BM25Store # noqa: E402 |
| 23 | +from rag_engine.storage.knowledge_graph import KnowledgeGraphStore # noqa: E402 |
| 24 | +from rag_engine.storage.qdrant_store import QdrantStore # noqa: E402 |
24 | 25 |
|
25 | 26 | TEST_API_KEY = "test-api-key" |
26 | 27 |
|
@@ -65,8 +66,15 @@ def gdpr_service( |
65 | 66 | return GDPRService(bm25_store, graph_store, qdrant_store) |
66 | 67 |
|
67 | 68 |
|
| 69 | +@pytest.fixture(autouse=True) |
| 70 | +def _fresh_rate_limiter(): |
| 71 | + """Reset the rate limiter before each test to avoid cross-test 429 errors.""" |
| 72 | + limiter.reset() |
| 73 | + yield |
| 74 | + |
| 75 | + |
68 | 76 | @pytest.fixture |
69 | 77 | def test_client() -> TestClient: |
70 | | - """FastAPI test client.""" |
| 78 | + """FastAPI test client with a fresh rate limiter.""" |
71 | 79 | app = create_app() |
72 | 80 | return TestClient(app) |
0 commit comments