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
127 lines
4.5 KiB
Python
127 lines
4.5 KiB
Python
"""High-value tests for web/warning_checks/hardware.py - Hardware Warnings."""
|
|
|
|
from local_deep_research.web.warning_checks.hardware import (
|
|
check_high_context,
|
|
check_model_mismatch,
|
|
LOCAL_PROVIDERS,
|
|
)
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# LOCAL_PROVIDERS
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
class TestLocalProviders:
|
|
def test_is_frozenset(self):
|
|
assert isinstance(LOCAL_PROVIDERS, frozenset)
|
|
|
|
def test_expected_providers(self):
|
|
assert LOCAL_PROVIDERS == {"ollama", "llamacpp", "lmstudio"}
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# check_high_context()
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
class TestCheckHighContext:
|
|
"""High context warning for local providers."""
|
|
|
|
def test_non_local_provider_returns_none(self):
|
|
assert check_high_context("openai", 16384, False) is None
|
|
|
|
def test_context_at_threshold_returns_none(self):
|
|
assert check_high_context("ollama", 8192, False) is None
|
|
|
|
def test_context_below_threshold_returns_none(self):
|
|
assert check_high_context("ollama", 4096, False) is None
|
|
|
|
def test_dismissed_returns_none(self):
|
|
assert check_high_context("ollama", 16384, True) is None
|
|
|
|
def test_ollama_high_context_returns_warning(self):
|
|
result = check_high_context("ollama", 16384, False)
|
|
assert result is not None
|
|
assert result["type"] == "high_context"
|
|
assert "16,384" in result["message"]
|
|
|
|
def test_llamacpp_high_context(self):
|
|
result = check_high_context("llamacpp", 32768, False)
|
|
assert result is not None
|
|
assert result["type"] == "high_context"
|
|
|
|
def test_lmstudio_high_context(self):
|
|
result = check_high_context("lmstudio", 10000, False)
|
|
assert result is not None
|
|
assert result["type"] == "high_context"
|
|
|
|
def test_warning_has_dismiss_key(self):
|
|
result = check_high_context("ollama", 16384, False)
|
|
assert "dismissKey" in result
|
|
|
|
def test_warning_has_icon(self):
|
|
result = check_high_context("ollama", 16384, False)
|
|
assert "icon" in result
|
|
|
|
def test_anthropic_not_local(self):
|
|
assert check_high_context("anthropic", 100000, False) is None
|
|
|
|
def test_boundary_8193_triggers_warning(self):
|
|
result = check_high_context("ollama", 8193, False)
|
|
assert result is not None
|
|
assert result["title"] == "High Context Warning"
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# check_model_mismatch()
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
class TestCheckModelMismatch:
|
|
"""Model mismatch warning for large models with high context."""
|
|
|
|
def test_empty_model_returns_none(self):
|
|
assert check_model_mismatch("ollama", "", 16384, False) is None
|
|
|
|
def test_none_model_returns_none(self):
|
|
assert check_model_mismatch("ollama", None, 16384, False) is None
|
|
|
|
def test_non_local_provider_returns_none(self):
|
|
assert (
|
|
check_model_mismatch("openai", "llama3-70b", 16384, False) is None
|
|
)
|
|
|
|
def test_non_70b_model_returns_none(self):
|
|
assert check_model_mismatch("ollama", "llama3-7b", 16384, False) is None
|
|
|
|
def test_low_context_returns_none(self):
|
|
assert check_model_mismatch("ollama", "llama3-70b", 8192, False) is None
|
|
|
|
def test_dismissed_returns_none(self):
|
|
assert check_model_mismatch("ollama", "llama3-70b", 16384, True) is None
|
|
|
|
def test_70b_high_context_returns_warning(self):
|
|
result = check_model_mismatch("ollama", "llama3-70b", 16384, False)
|
|
assert result is not None
|
|
assert result["type"] == "model_mismatch"
|
|
assert "llama3-70b" in result["message"]
|
|
assert "16,384" in result["message"]
|
|
|
|
def test_case_insensitive_70b(self):
|
|
result = check_model_mismatch("ollama", "Llama3-70B-Q4", 16384, False)
|
|
assert result is not None
|
|
|
|
def test_boundary_8193_triggers_warning(self):
|
|
result = check_model_mismatch("ollama", "llama3-70b", 8193, False)
|
|
assert result is not None
|
|
assert result["title"] == "Model & Context Warning"
|
|
|
|
def test_warning_has_dismiss_key(self):
|
|
result = check_model_mismatch("ollama", "model-70b", 16384, False)
|
|
assert "dismissKey" in result
|
|
|
|
def test_warning_has_icon(self):
|
|
result = check_model_mismatch("ollama", "model-70b", 16384, False)
|
|
assert "icon" in result
|