-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff_tests_conftest.py
More file actions
53 lines (44 loc) · 1.66 KB
/
diff_tests_conftest.py
File metadata and controls
53 lines (44 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
diff --git a/tests/conftest.py b/tests/conftest.py
index 7e1247de..92eeb2d0 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -15,9 +15,14 @@ os.environ["OPENAI_API_KEY"] = "" # Disable LLM for most tests
os.environ["REDIS_URL"] = "" # Disable Redis for most tests
os.environ["METRICS_ENABLED"] = "false"
os.environ["LOGGING_ENABLED"] = "false"
+os.environ["MULTI_TENANT_ENABLED"] = "true"
+os.environ["DEMO_MODE"] = "false"
+os.environ["API_KEY_USAGE_TRACKING_ENABLED"] = "false"
+os.environ["API_KEY_ENFORCE_ROTATION"] = "false"
from app.main import app
from app.db import get_db, Base
+from app.middleware.dashboard_metrics import DashboardMetricsMiddleware
from app.models import Rule
@@ -41,8 +46,9 @@ def test_session(test_engine):
session.close()
# Clean up all tables after each test
- for table in reversed(Base.metadata.sorted_tables):
- test_engine.execute(table.delete())
+ with test_engine.begin() as conn:
+ for table in reversed(Base.metadata.sorted_tables):
+ conn.execute(table.delete())
@pytest.fixture(scope="function")
@@ -55,8 +61,19 @@ def client(test_session):
pass
app.dependency_overrides[get_db] = override_get_db
- yield TestClient(app)
- app.dependency_overrides.clear()
+
+ original_dispatch = DashboardMetricsMiddleware.dispatch
+
+ async def _noop_dispatch(self, request, call_next):
+ return await call_next(request)
+
+ DashboardMetricsMiddleware.dispatch = _noop_dispatch
+
+ try:
+ yield TestClient(app)
+ finally:
+ DashboardMetricsMiddleware.dispatch = original_dispatch
+ app.dependency_overrides.clear()
@pytest.fixture