7a0da7932b
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
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
125 lines
3.5 KiB
Python
125 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test API response contracts.
|
|
|
|
These tests verify that API responses have the expected structure.
|
|
Breaking these contracts will break client integrations.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
|
|
class TestResearchStatusValues:
|
|
"""
|
|
Verify that research status values are consistent.
|
|
|
|
Clients depend on these exact string values.
|
|
"""
|
|
|
|
def test_research_status_enum_values(self):
|
|
"""
|
|
Verify ResearchStatus enum has expected values.
|
|
|
|
Clients check for these exact string values in responses.
|
|
Changing them will break client code.
|
|
"""
|
|
from local_deep_research.database.models.research import (
|
|
ResearchStatus,
|
|
)
|
|
|
|
# These are the status values clients depend on
|
|
expected_values = {
|
|
"pending",
|
|
"in_progress",
|
|
"completed",
|
|
"failed",
|
|
"cancelled",
|
|
"suspended",
|
|
}
|
|
|
|
actual_values = {status.value for status in ResearchStatus}
|
|
|
|
# Check no expected values were removed
|
|
missing = expected_values - actual_values
|
|
assert not missing, (
|
|
f"ResearchStatus is missing expected values: {missing}\n"
|
|
"Clients depend on these status values.\n"
|
|
"Removing them will break client integrations."
|
|
)
|
|
|
|
def test_research_mode_enum_values(self):
|
|
"""
|
|
Verify ResearchMode enum has expected values.
|
|
|
|
Clients use these values when starting research.
|
|
"""
|
|
from local_deep_research.database.models.research import (
|
|
ResearchMode,
|
|
)
|
|
|
|
# These are the mode values clients depend on
|
|
expected_values = {
|
|
"quick",
|
|
"detailed",
|
|
}
|
|
|
|
actual_values = {mode.value for mode in ResearchMode}
|
|
|
|
missing = expected_values - actual_values
|
|
assert not missing, (
|
|
f"ResearchMode is missing expected values: {missing}\n"
|
|
"Clients depend on these mode values."
|
|
)
|
|
|
|
|
|
class TestResponseStructures:
|
|
"""
|
|
Verify that models have expected columns for API responses.
|
|
|
|
These are the fields that clients depend on.
|
|
"""
|
|
|
|
def test_research_has_required_columns(self):
|
|
"""
|
|
Verify Research model has required columns for API responses.
|
|
|
|
These columns are serialized in API responses.
|
|
"""
|
|
from local_deep_research.database.models.research import Research
|
|
|
|
required_columns = {
|
|
"id",
|
|
"query",
|
|
"status",
|
|
"mode",
|
|
"created_at",
|
|
}
|
|
|
|
actual_columns = set(Research.__table__.columns.keys())
|
|
|
|
missing = required_columns - actual_columns
|
|
assert not missing, (
|
|
f"Research model is missing required columns: {missing}\n"
|
|
"These columns are expected in API responses."
|
|
)
|
|
|
|
def test_user_settings_has_required_columns(self):
|
|
"""
|
|
Verify UserSettings model has required columns for API responses.
|
|
"""
|
|
from local_deep_research.database.models import UserSettings
|
|
|
|
required_columns = {"id", "key", "value", "category"}
|
|
|
|
actual_columns = set(UserSettings.__table__.columns.keys())
|
|
|
|
missing = required_columns - actual_columns
|
|
assert not missing, (
|
|
f"UserSettings model is missing required columns: {missing}\n"
|
|
"These columns are expected in settings API responses."
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pytest.main([__file__, "-v"])
|