7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
104 lines
3.6 KiB
Python
104 lines
3.6 KiB
Python
"""
|
|
Basic API tests - only test endpoints that should respond quickly.
|
|
Focus on verifying the API is working without doing actual research.
|
|
"""
|
|
|
|
import pytest
|
|
from flask import json
|
|
|
|
|
|
class TestBasicAPI:
|
|
"""Test basic API functionality."""
|
|
|
|
def test_health_check(self, authenticated_client):
|
|
"""Test health check endpoint."""
|
|
response = authenticated_client.get("/api/v1/health")
|
|
assert response.status_code == 200
|
|
data = json.loads(response.data)
|
|
assert data["status"] == "ok"
|
|
assert "timestamp" in data
|
|
|
|
def test_api_documentation(self, authenticated_client):
|
|
"""Test API documentation endpoint."""
|
|
response = authenticated_client.get("/api/v1/")
|
|
assert response.status_code == 200
|
|
data = json.loads(response.data)
|
|
assert data["api_version"] == "v1"
|
|
assert "endpoints" in data
|
|
assert len(data["endpoints"]) >= 3
|
|
|
|
def test_error_handling(self, authenticated_client):
|
|
"""Test error handling for malformed requests."""
|
|
# Test missing query parameter
|
|
response = authenticated_client.post(
|
|
"/api/v1/quick_summary",
|
|
json={},
|
|
content_type="application/json",
|
|
)
|
|
assert response.status_code == 400
|
|
data = json.loads(response.data)
|
|
assert "error" in data
|
|
assert "required" in data["error"].lower()
|
|
|
|
# Test missing collection_name
|
|
response = authenticated_client.post(
|
|
"/api/v1/analyze_documents",
|
|
json={"query": "test"},
|
|
content_type="application/json",
|
|
)
|
|
assert response.status_code == 400
|
|
data = json.loads(response.data)
|
|
assert "error" in data
|
|
|
|
@pytest.mark.requires_llm
|
|
def test_api_structure(
|
|
self, authenticated_client, setup_database_for_all_tests
|
|
):
|
|
"""Test that API accepts properly formatted requests."""
|
|
payload = {
|
|
"query": "test",
|
|
"search_tool": "wikipedia",
|
|
"iterations": 1,
|
|
"temperature": 0.7,
|
|
}
|
|
|
|
print(
|
|
f"\n[DEBUG] Sending request to /api/v1/quick_summary with payload: {payload}"
|
|
)
|
|
|
|
# Send request with proper format
|
|
response = authenticated_client.post(
|
|
"/api/v1/quick_summary",
|
|
json=payload,
|
|
content_type="application/json",
|
|
)
|
|
|
|
print(f"[DEBUG] Response status code: {response.status_code}")
|
|
print(
|
|
f"[DEBUG] Response data: {response.data.decode()[:500]}"
|
|
) # First 500 chars
|
|
|
|
if response.status_code == 500:
|
|
# Print full error details for debugging
|
|
try:
|
|
error_data = json.loads(response.data)
|
|
print(f"[DEBUG] Error response JSON: {error_data}")
|
|
except Exception:
|
|
print(f"[DEBUG] Raw error response: {response.data.decode()}")
|
|
|
|
# The API should accept the request format
|
|
# It might return 200 with processing started, or 400 if there's a validation error
|
|
assert response.status_code in [200, 202, 400]
|
|
|
|
if response.status_code == 400:
|
|
# Check that error message is informative
|
|
data = json.loads(response.data)
|
|
assert "error" in data
|
|
|
|
def test_unauthenticated_access(self, client):
|
|
"""Test that unauthenticated requests are rejected."""
|
|
response = client.get("/api/v1/health")
|
|
# API endpoints might allow unauthenticated access for health checks
|
|
# or might redirect to login
|
|
assert response.status_code in [200, 302, 401]
|