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
322 lines
9.2 KiB
Python
322 lines
9.2 KiB
Python
"""
|
|
Behavioral tests for base_constraint module.
|
|
|
|
Tests ConstraintType enum and Constraint dataclass logic.
|
|
"""
|
|
|
|
|
|
class TestConstraintTypeEnum:
|
|
"""Tests for ConstraintType enum values."""
|
|
|
|
def test_property_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.PROPERTY.value == "property"
|
|
|
|
def test_name_pattern_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.NAME_PATTERN.value == "name_pattern"
|
|
|
|
def test_event_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.EVENT.value == "event"
|
|
|
|
def test_statistic_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.STATISTIC.value == "statistic"
|
|
|
|
def test_temporal_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.TEMPORAL.value == "temporal"
|
|
|
|
def test_location_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.LOCATION.value == "location"
|
|
|
|
def test_comparison_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.COMPARISON.value == "comparison"
|
|
|
|
def test_existence_type_exists(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert ConstraintType.EXISTENCE.value == "existence"
|
|
|
|
def test_has_eight_types(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
ConstraintType,
|
|
)
|
|
|
|
assert len(ConstraintType) == 8
|
|
|
|
|
|
class TestConstraintInit:
|
|
"""Tests for Constraint dataclass initialization."""
|
|
|
|
def test_basic_construction(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="test",
|
|
value="ice age",
|
|
)
|
|
assert c.id == "c1"
|
|
assert c.type == ConstraintType.PROPERTY
|
|
assert c.description == "test"
|
|
assert c.value == "ice age"
|
|
|
|
def test_default_weight_is_one(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1", type=ConstraintType.PROPERTY, description="test", value="v"
|
|
)
|
|
assert c.weight == 1.0
|
|
|
|
def test_custom_weight(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="test",
|
|
value="v",
|
|
weight=0.5,
|
|
)
|
|
assert c.weight == 0.5
|
|
|
|
def test_metadata_defaults_to_empty_dict(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1", type=ConstraintType.PROPERTY, description="test", value="v"
|
|
)
|
|
assert c.metadata == {}
|
|
|
|
def test_metadata_none_becomes_empty_dict(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="test",
|
|
value="v",
|
|
metadata=None,
|
|
)
|
|
assert c.metadata == {}
|
|
|
|
def test_custom_metadata_preserved(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
meta = {"key": "val"}
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="test",
|
|
value="v",
|
|
metadata=meta,
|
|
)
|
|
assert c.metadata == {"key": "val"}
|
|
|
|
|
|
class TestConstraintToSearchTerms:
|
|
"""Tests for Constraint.to_search_terms() method."""
|
|
|
|
def test_property_returns_value_directly(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="d",
|
|
value="ice age",
|
|
)
|
|
assert c.to_search_terms() == "ice age"
|
|
|
|
def test_name_pattern_appends_keywords(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.NAME_PATTERN,
|
|
description="d",
|
|
value="body part",
|
|
)
|
|
result = c.to_search_terms()
|
|
assert "body part" in result
|
|
assert "name" in result
|
|
assert "trail" in result
|
|
|
|
def test_event_appends_keywords(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.EVENT,
|
|
description="d",
|
|
value="rockslide",
|
|
)
|
|
result = c.to_search_terms()
|
|
assert "rockslide" in result
|
|
assert "accident" in result or "incident" in result
|
|
|
|
def test_statistic_appends_keywords(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.STATISTIC,
|
|
description="d",
|
|
value="84.5x",
|
|
)
|
|
result = c.to_search_terms()
|
|
assert "84.5x" in result
|
|
assert "statistics" in result
|
|
|
|
def test_other_types_return_str_value(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.LOCATION,
|
|
description="d",
|
|
value="Colorado",
|
|
)
|
|
assert c.to_search_terms() == "Colorado"
|
|
|
|
|
|
class TestConstraintIsCritical:
|
|
"""Tests for Constraint.is_critical() method."""
|
|
|
|
def test_name_pattern_always_critical(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.NAME_PATTERN,
|
|
description="d",
|
|
value="v",
|
|
weight=0.1,
|
|
)
|
|
assert c.is_critical() is True
|
|
|
|
def test_high_weight_is_critical(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="d",
|
|
value="v",
|
|
weight=0.9,
|
|
)
|
|
assert c.is_critical() is True
|
|
|
|
def test_low_weight_not_critical(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.PROPERTY,
|
|
description="d",
|
|
value="v",
|
|
weight=0.5,
|
|
)
|
|
assert c.is_critical() is False
|
|
|
|
def test_weight_exactly_0_8_not_critical(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.EVENT,
|
|
description="d",
|
|
value="v",
|
|
weight=0.8,
|
|
)
|
|
assert c.is_critical() is False
|
|
|
|
def test_weight_just_above_0_8_is_critical(self):
|
|
from local_deep_research.advanced_search_system.constraints.base_constraint import (
|
|
Constraint,
|
|
ConstraintType,
|
|
)
|
|
|
|
c = Constraint(
|
|
id="c1",
|
|
type=ConstraintType.EVENT,
|
|
description="d",
|
|
value="v",
|
|
weight=0.81,
|
|
)
|
|
assert c.is_critical() is True
|