""" 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