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.

fix(tests): narrow broad status-code tautologies in test_metrics_routes.py (#4147)

LearningCircuitd9a093c4a155
diff --git a/tests/web/routes/test_metrics_routes.py b/tests/web/routes/test_metrics_routes.py
index ee6ce4dd84..2164a99a80 100644
--- a/tests/web/routes/test_metrics_routes.py
+++ b/tests/web/routes/test_metrics_routes.py
@@ -16,7 +16,7 @@ class TestMetricsDashboard:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/")
- assert response.status_code in [401, 302]
+ assert response.status_code == 302, response.status_code
def test_returns_page_when_authenticated(self, authenticated_client):
"""Should return metrics page when authenticated."""
@@ -30,7 +30,7 @@ class TestContextOverflowPage:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/context-overflow")
- assert response.status_code in [401, 302]
+ assert response.status_code == 302, response.status_code
def test_returns_page_when_authenticated(self, authenticated_client):
"""Should return context overflow page when authenticated."""
@@ -46,14 +46,14 @@ class TestApiMetrics:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/metrics")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_metrics_when_authenticated(self, authenticated_client):
"""Should return metrics when authenticated."""
# This endpoint has many dependencies. Test that it returns valid response.
response = authenticated_client.get(f"{METRICS_PREFIX}/api/metrics")
# May return 200 (success) or 500 (deps not mocked) - both acceptable
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert data["status"] == "success"
@@ -65,7 +65,7 @@ class TestApiMetrics:
f"{METRICS_PREFIX}/api/metrics?period=7d"
)
# May return 200 (success) or 500 (deps not mocked) - both acceptable
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert data["period"] == "7d"
@@ -77,7 +77,7 @@ class TestApiRateLimitingMetrics:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/rate-limiting")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_rate_limiting_data(self, authenticated_client):
"""Should return rate limiting metrics."""
@@ -109,7 +109,7 @@ class TestApiCurrentRateLimits:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/rate-limiting/current")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_current_limits(self, authenticated_client):
"""Should return current rate limits."""
@@ -140,7 +140,7 @@ class TestApiResearchMetrics:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/metrics/research/test-id")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_research_metrics(self, authenticated_client):
"""Should return metrics for specific research."""
@@ -173,7 +173,7 @@ class TestApiResearchLinkMetrics:
response = client.get(
f"{METRICS_PREFIX}/api/metrics/research/test-id/links"
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_empty_for_no_resources(self, authenticated_client):
"""Should return empty data when no resources exist."""
@@ -208,7 +208,7 @@ class TestApiGetResearchRating:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/ratings/test-id")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_null_for_no_rating(self, authenticated_client):
"""Should return null rating when none exists."""
@@ -276,7 +276,7 @@ class TestApiSaveResearchRating:
response = client.post(
f"{METRICS_PREFIX}/api/ratings/test-id", json={"rating": 5}
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_validates_rating_range(self, authenticated_client):
"""Should validate rating is between 1 and 5."""
@@ -330,7 +330,7 @@ class TestStarReviewsPage:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/star-reviews")
- assert response.status_code in [401, 302]
+ assert response.status_code == 302, response.status_code
def test_returns_page_when_authenticated(self, authenticated_client):
"""Should return star reviews page when authenticated."""
@@ -344,7 +344,7 @@ class TestCostAnalyticsPage:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/costs")
- assert response.status_code in [401, 302]
+ assert response.status_code == 302, response.status_code
def test_returns_page_when_authenticated(self, authenticated_client):
"""Should return cost analytics page when authenticated."""
@@ -358,7 +358,7 @@ class TestLinkAnalyticsPage:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/links")
- assert response.status_code in [401, 302]
+ assert response.status_code == 302, response.status_code
def test_returns_page_when_authenticated(self, authenticated_client):
"""Should return link analytics page when authenticated."""
@@ -372,7 +372,7 @@ class TestApiLinkAnalytics:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/link-analytics")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_link_analytics(self, authenticated_client):
"""Should return link analytics data."""
@@ -403,13 +403,13 @@ class TestApiPricing:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/pricing")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_pricing_data(self, authenticated_client):
"""Should return pricing data."""
response = authenticated_client.get(f"{METRICS_PREFIX}/api/pricing")
# May return 200 (success) or 500 (deps not available) - both acceptable
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert data["status"] == "success"
@@ -422,7 +422,7 @@ class TestApiModelPricing:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/pricing/gpt-4")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_model_pricing(self, authenticated_client):
"""Should return pricing for specific model."""
@@ -430,7 +430,7 @@ class TestApiModelPricing:
f"{METRICS_PREFIX}/api/pricing/gpt-4"
)
# May return 200 (success) or 500 (deps not available) - both acceptable
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert data["status"] == "success"
@@ -450,7 +450,7 @@ class TestApiCostCalculation:
"completion_tokens": 50,
},
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_requires_model_name(self, authenticated_client):
"""Should require model_name."""
@@ -471,7 +471,7 @@ class TestApiCostCalculation:
},
)
# May return 200 (success) or 500 (deps not available) - both acceptable
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert data["status"] == "success"
@@ -484,7 +484,7 @@ class TestApiResearchCosts:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/research-costs/test-id")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_no_data_message(self, authenticated_client):
"""Should return message when no token usage data."""
@@ -519,7 +519,7 @@ class TestApiCostAnalytics:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/cost-analytics")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_cost_analytics(self, authenticated_client):
"""Should return cost analytics data."""
@@ -554,7 +554,7 @@ class TestApiDomainClassifications:
def test_requires_authentication(self, client):
"""Should require authentication."""
response = client.get(f"{METRICS_PREFIX}/api/domain-classifications")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_classifications(self, authenticated_client):
"""Should return domain classifications."""
@@ -583,7 +583,7 @@ class TestApiClassificationsSummary:
response = client.get(
f"{METRICS_PREFIX}/api/domain-classifications/summary"
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_summary(self, authenticated_client):
"""Should return classifications summary."""
@@ -616,7 +616,7 @@ class TestApiClassifyDomains:
f"{METRICS_PREFIX}/api/domain-classifications/classify",
json={"domain": "example.com"},
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_requires_domain_or_batch(self, authenticated_client):
"""Should require domain or batch mode."""
@@ -634,7 +634,7 @@ class TestApiClassificationProgress:
response = client.get(
f"{METRICS_PREFIX}/api/domain-classifications/progress"
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_progress(self, authenticated_client):
"""Should return classification progress."""
@@ -642,7 +642,7 @@ class TestApiClassificationProgress:
f"{METRICS_PREFIX}/api/domain-classifications/progress"
)
# May return 200 (success) or 500 (deps not available) - both acceptable
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert data["status"] == "success"
@@ -710,7 +710,7 @@ class TestApiResearchJournals:
response = client.get(
f"{METRICS_PREFIX}/api/journals/research/some-uuid"
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_returns_404_for_unknown_research_id(self, authenticated_client):
"""A research_id that doesn't belong to this user must return 404
@@ -725,7 +725,7 @@ class TestApiResearchJournals:
# accepted only if the per-user DB tables don't exist yet in
# the freshly-provisioned test account (the endpoint returns
# an empty payload in that case via the inspector check).
- assert response.status_code in [200, 404, 500]
+ assert response.status_code == 404, response.status_code
if response.status_code == 200:
data = response.get_json()
# Empty-table fast path returns the empty-response shape.
@@ -807,7 +807,7 @@ class TestApiJournalQuality:
def test_requires_authentication(self, client):
response = client.get(f"{METRICS_PREFIX}/api/journals")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
@staticmethod
def _mock_ref_db():
@@ -1032,7 +1032,7 @@ class TestApiJournalDataStatus:
def test_requires_authentication(self, client):
response = client.get(f"{METRICS_PREFIX}/api/journal-data/status")
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_authenticated_returns_dict(self, authenticated_client):
response = authenticated_client.get(
@@ -1040,7 +1040,7 @@ class TestApiJournalDataStatus:
)
# 200 with a JSON dict shape, or 500 if the downloader module
# isn't importable in this environment.
- assert response.status_code in [200, 500]
+ assert response.status_code == 200, response.status_code
if response.status_code == 200:
data = response.get_json()
assert isinstance(data, dict)
@@ -1056,7 +1056,7 @@ class TestApiJournalDataDownload:
f"{METRICS_PREFIX}/api/journal-data/download",
json={"force": False},
)
- assert response.status_code in [401, 302]
+ assert response.status_code == 401, response.status_code
def test_authenticated_post_is_handled(self, authenticated_client):
"""A single authenticated POST either succeeds or is rejected