Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

280 lines
9.7 KiB
Python

"""
Behavioral tests for web/routes/route_registry module.
Tests the route registry data structure, route lookups, and filtering functions.
"""
class TestRouteRegistryStructure:
"""Tests for ROUTE_REGISTRY constant."""
def test_is_dict(self):
"""ROUTE_REGISTRY is a dictionary."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert isinstance(ROUTE_REGISTRY, dict)
def test_is_non_empty(self):
"""ROUTE_REGISTRY is non-empty."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert len(ROUTE_REGISTRY) > 0
def test_contains_research_blueprint(self):
"""Contains research blueprint."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert "research" in ROUTE_REGISTRY
def test_contains_settings_blueprint(self):
"""Contains settings blueprint."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert "settings" in ROUTE_REGISTRY
def test_contains_history_blueprint(self):
"""Contains history blueprint."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert "history" in ROUTE_REGISTRY
def test_contains_metrics_blueprint(self):
"""Contains metrics blueprint."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert "metrics" in ROUTE_REGISTRY
def test_contains_api_v1_blueprint(self):
"""Contains api_v1 blueprint."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
assert "api_v1" in ROUTE_REGISTRY
def test_each_blueprint_has_routes(self):
"""Each blueprint has a routes list."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
for name, info in ROUTE_REGISTRY.items():
assert "routes" in info, f"Blueprint {name!r} missing 'routes'"
assert isinstance(info["routes"], list), (
f"Blueprint {name!r} routes is not a list"
)
def test_each_blueprint_has_url_prefix(self):
"""Each blueprint has a url_prefix key."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
for name, info in ROUTE_REGISTRY.items():
assert "url_prefix" in info, (
f"Blueprint {name!r} missing 'url_prefix'"
)
def test_route_tuples_have_four_elements(self):
"""Route tuples have (method, path, endpoint, description)."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
for name, info in ROUTE_REGISTRY.items():
for route in info["routes"]:
assert len(route) == 4, (
f"Route in {name!r} has {len(route)} elements, expected 4"
)
def test_route_methods_are_valid_http(self):
"""Route methods are valid HTTP methods."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
valid_methods = {"GET", "POST", "PUT", "DELETE", "PATCH"}
for name, info in ROUTE_REGISTRY.items():
for method, path, endpoint, desc in info["routes"]:
assert method in valid_methods, (
f"Invalid HTTP method {method!r} in {name!r}"
)
def test_route_paths_start_with_slash(self):
"""Route paths start with /."""
from local_deep_research.web.routes.route_registry import ROUTE_REGISTRY
for name, info in ROUTE_REGISTRY.items():
for method, path, endpoint, desc in info["routes"]:
assert path.startswith("/"), (
f"Path {path!r} in {name!r} doesn't start with /"
)
class TestGetAllRoutes:
"""Tests for get_all_routes function."""
def test_returns_list(self):
"""Returns a list."""
from local_deep_research.web.routes.route_registry import get_all_routes
result = get_all_routes()
assert isinstance(result, list)
def test_returns_non_empty(self):
"""Returns non-empty list."""
from local_deep_research.web.routes.route_registry import get_all_routes
result = get_all_routes()
assert len(result) > 0
def test_each_route_has_method(self):
"""Each route dict has 'method' key."""
from local_deep_research.web.routes.route_registry import get_all_routes
for route in get_all_routes():
assert "method" in route
def test_each_route_has_path(self):
"""Each route dict has 'path' key."""
from local_deep_research.web.routes.route_registry import get_all_routes
for route in get_all_routes():
assert "path" in route
def test_each_route_has_endpoint(self):
"""Each route dict has 'endpoint' key."""
from local_deep_research.web.routes.route_registry import get_all_routes
for route in get_all_routes():
assert "endpoint" in route
def test_each_route_has_description(self):
"""Each route dict has 'description' key."""
from local_deep_research.web.routes.route_registry import get_all_routes
for route in get_all_routes():
assert "description" in route
def test_each_route_has_blueprint(self):
"""Each route dict has 'blueprint' key."""
from local_deep_research.web.routes.route_registry import get_all_routes
for route in get_all_routes():
assert "blueprint" in route
def test_endpoint_includes_blueprint_prefix(self):
"""Endpoint includes blueprint name as prefix."""
from local_deep_research.web.routes.route_registry import get_all_routes
for route in get_all_routes():
assert "." in route["endpoint"], (
f"Endpoint {route['endpoint']!r} missing blueprint prefix"
)
def test_api_v1_routes_have_prefix(self):
"""API v1 routes have /api/v1 prefix in path."""
from local_deep_research.web.routes.route_registry import get_all_routes
api_routes = [r for r in get_all_routes() if r["blueprint"] == "api_v1"]
for route in api_routes:
assert route["path"].startswith("/api/v1"), (
f"API route {route['path']!r} missing /api/v1 prefix"
)
class TestGetRoutesByBlueprint:
"""Tests for get_routes_by_blueprint function."""
def test_returns_list_for_valid_blueprint(self):
"""Returns list for valid blueprint name."""
from local_deep_research.web.routes.route_registry import (
get_routes_by_blueprint,
)
result = get_routes_by_blueprint("research")
assert isinstance(result, list)
def test_returns_empty_for_invalid_blueprint(self):
"""Returns empty list for invalid blueprint name."""
from local_deep_research.web.routes.route_registry import (
get_routes_by_blueprint,
)
result = get_routes_by_blueprint("nonexistent_blueprint")
assert result == []
def test_research_has_routes(self):
"""Research blueprint has routes."""
from local_deep_research.web.routes.route_registry import (
get_routes_by_blueprint,
)
result = get_routes_by_blueprint("research")
assert len(result) > 0
def test_settings_has_routes(self):
"""Settings blueprint has routes."""
from local_deep_research.web.routes.route_registry import (
get_routes_by_blueprint,
)
result = get_routes_by_blueprint("settings")
assert len(result) > 0
def test_routes_have_method_key(self):
"""Returned routes have 'method' key."""
from local_deep_research.web.routes.route_registry import (
get_routes_by_blueprint,
)
for route in get_routes_by_blueprint("research"):
assert "method" in route
def test_routes_have_path_key(self):
"""Returned routes have 'path' key."""
from local_deep_research.web.routes.route_registry import (
get_routes_by_blueprint,
)
for route in get_routes_by_blueprint("research"):
assert "path" in route
class TestFindRoute:
"""Tests for find_route function."""
def test_finds_api_routes(self):
"""Finds routes matching /api pattern."""
from local_deep_research.web.routes.route_registry import find_route
result = find_route("/api")
assert len(result) > 0
def test_returns_empty_for_no_match(self):
"""Returns empty list when nothing matches."""
from local_deep_research.web.routes.route_registry import find_route
result = find_route("/xyz_nonexistent_route_abc")
assert result == []
def test_case_insensitive_matching(self):
"""Matching is case-insensitive."""
from local_deep_research.web.routes.route_registry import find_route
lower_result = find_route("/api")
upper_result = find_route("/API")
assert len(lower_result) == len(upper_result)
def test_finds_settings_routes(self):
"""Finds settings-related routes."""
from local_deep_research.web.routes.route_registry import find_route
result = find_route("settings")
assert len(result) > 0
def test_finds_history_routes(self):
"""Finds history-related routes."""
from local_deep_research.web.routes.route_registry import find_route
result = find_route("history")
assert len(result) > 0
def test_result_items_are_dicts(self):
"""Result items are dictionaries."""
from local_deep_research.web.routes.route_registry import find_route
result = find_route("/api")
for item in result:
assert isinstance(item, dict)