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

221 lines
7.1 KiB
Python

"""
Tests for constants.py
Tests cover:
- USER_AGENT constant
- BROWSER_USER_AGENT constant
- ResearchStatus StrEnum
- Rate limiting constants
- Snippet length constants
"""
from enum import StrEnum
class TestUserAgent:
"""Tests for USER_AGENT constant."""
def test_user_agent_exists(self):
"""Test USER_AGENT constant exists."""
from local_deep_research.constants import USER_AGENT
assert USER_AGENT is not None
assert isinstance(USER_AGENT, str)
def test_user_agent_contains_project_name(self):
"""Test USER_AGENT contains project name."""
from local_deep_research.constants import USER_AGENT
assert "Local-Deep-Research" in USER_AGENT
def test_user_agent_contains_version(self):
"""Test USER_AGENT contains version."""
from local_deep_research.constants import USER_AGENT
from local_deep_research.__version__ import __version__
assert __version__ in USER_AGENT
def test_user_agent_contains_github_url(self):
"""Test USER_AGENT contains GitHub URL."""
from local_deep_research.constants import USER_AGENT
assert "github.com/LearningCircuit/local-deep-research" in USER_AGENT
def test_user_agent_contains_description(self):
"""Test USER_AGENT contains description."""
from local_deep_research.constants import USER_AGENT
assert "Academic Research Tool" in USER_AGENT
class TestBrowserUserAgent:
"""Tests for BROWSER_USER_AGENT constant."""
def test_browser_user_agent_exists(self):
"""Test BROWSER_USER_AGENT constant exists."""
from local_deep_research.constants import BROWSER_USER_AGENT
assert BROWSER_USER_AGENT is not None
assert isinstance(BROWSER_USER_AGENT, str)
def test_browser_user_agent_looks_like_browser(self):
"""Test BROWSER_USER_AGENT looks like a browser."""
from local_deep_research.constants import BROWSER_USER_AGENT
assert "Mozilla" in BROWSER_USER_AGENT
assert "AppleWebKit" in BROWSER_USER_AGENT
def test_browser_user_agent_contains_chrome(self):
"""Test BROWSER_USER_AGENT contains Chrome."""
from local_deep_research.constants import BROWSER_USER_AGENT
assert "Chrome" in BROWSER_USER_AGENT
def test_browser_user_agent_contains_windows(self):
"""Test BROWSER_USER_AGENT contains Windows."""
from local_deep_research.constants import BROWSER_USER_AGENT
assert "Windows" in BROWSER_USER_AGENT
class TestVersionImport:
"""Tests for version import."""
def test_version_exists(self):
"""Test __version__ exists."""
from local_deep_research.__version__ import __version__
assert __version__ is not None
assert isinstance(__version__, str)
def test_version_not_empty(self):
"""Test __version__ is not empty."""
from local_deep_research.__version__ import __version__
assert len(__version__) > 0
class TestResearchStatus:
"""Tests for ResearchStatus StrEnum."""
def test_research_status_is_strenum(self):
"""ResearchStatus is a StrEnum."""
from local_deep_research.constants import ResearchStatus
assert issubclass(ResearchStatus, StrEnum)
def test_completed_status(self):
"""COMPLETED is 'completed'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.COMPLETED == "completed"
def test_suspended_status(self):
"""SUSPENDED is 'suspended'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.SUSPENDED == "suspended"
def test_failed_status(self):
"""FAILED is 'failed'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.FAILED == "failed"
def test_in_progress_status(self):
"""IN_PROGRESS is 'in_progress'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.IN_PROGRESS == "in_progress"
def test_pending_status(self):
"""PENDING is 'pending'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.PENDING == "pending"
def test_error_status(self):
"""ERROR is 'error'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.ERROR == "error"
def test_queued_status(self):
"""QUEUED is 'queued'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.QUEUED == "queued"
def test_cancelled_status(self):
"""CANCELLED is 'cancelled'."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.CANCELLED == "cancelled"
def test_string_comparison(self):
"""StrEnum values compare equal to plain strings."""
from local_deep_research.constants import ResearchStatus
assert ResearchStatus.COMPLETED == "completed"
assert "completed" == ResearchStatus.COMPLETED
assert ResearchStatus.IN_PROGRESS != "completed"
def test_membership_check(self):
"""StrEnum supports 'in' membership testing."""
from local_deep_research.constants import ResearchStatus
assert "completed" in ResearchStatus
assert "in_progress" in ResearchStatus
assert "nonexistent" not in ResearchStatus
def test_all_statuses_are_strings(self):
"""All status values are strings."""
from local_deep_research.constants import ResearchStatus
for member in ResearchStatus:
assert isinstance(member, str)
assert isinstance(member.value, str)
def test_all_statuses_are_unique(self):
"""All status values are distinct."""
from local_deep_research.constants import ResearchStatus
values = [member.value for member in ResearchStatus]
assert len(values) == len(set(values))
def test_importable_from_database_models(self):
"""ResearchStatus is importable from database.models (re-export)."""
from local_deep_research.constants import ResearchStatus as RS1
from local_deep_research.database.models.research import (
ResearchStatus as RS2,
)
assert RS1 is RS2
class TestSnippetLengthConstants:
"""Tests for snippet length constants."""
def test_snippet_length_short(self):
"""SNIPPET_LENGTH_SHORT is a positive integer."""
from local_deep_research.constants import SNIPPET_LENGTH_SHORT
assert isinstance(SNIPPET_LENGTH_SHORT, int)
assert SNIPPET_LENGTH_SHORT > 0
def test_snippet_length_long(self):
"""SNIPPET_LENGTH_LONG is a positive integer."""
from local_deep_research.constants import SNIPPET_LENGTH_LONG
assert isinstance(SNIPPET_LENGTH_LONG, int)
assert SNIPPET_LENGTH_LONG > 0
def test_long_greater_than_short(self):
"""SNIPPET_LENGTH_LONG > SNIPPET_LENGTH_SHORT."""
from local_deep_research.constants import (
SNIPPET_LENGTH_LONG,
SNIPPET_LENGTH_SHORT,
)
assert SNIPPET_LENGTH_LONG > SNIPPET_LENGTH_SHORT