stage-14: pytest test suite over the worker lines
38 tests covering the pure worker-line logic: Classifyline rules, Routeline TLP/country/incident-type gates, Sealine seal/unseal round-trip, Proofline confidence scoring, Mapline CVEResolver escalation, Trainline dataset well-posedness (the v1/v3 input-signal bugs are now regression-guarded), and the Scoutline feed parsers. pytest added as a dev extra. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
40
tests/conftest.py
Normal file
40
tests/conftest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Shared test fixtures — Case builders for the worker-line tests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from psyc.models import Case, Classification, IncidentType, Observables, Severity, TLP
|
||||
|
||||
|
||||
def make_case(
|
||||
feed: str = "urlhaus",
|
||||
incident_type: Optional[IncidentType] = None,
|
||||
severity: Optional[Severity] = None,
|
||||
tlp: TLP = TLP.AMBER,
|
||||
country: str = "",
|
||||
age_days: int = 1,
|
||||
**observables: list,
|
||||
) -> Case:
|
||||
"""A Case with controllable feed, classification, age, and observables."""
|
||||
case = Case(
|
||||
case_id=f"TEST-{feed}-{age_days}",
|
||||
summary=f"test case from {feed}",
|
||||
source_type="abuse_feed",
|
||||
observed_at=datetime.now(timezone.utc) - timedelta(days=age_days),
|
||||
observables=Observables(**observables),
|
||||
classification=Classification(incident_type=incident_type, severity=severity, tlp=tlp),
|
||||
)
|
||||
case.source_metadata["feed"] = feed
|
||||
case.victim.country = country
|
||||
return case
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def urlhaus_case() -> Case:
|
||||
c = make_case(feed="urlhaus", urls=["http://1.2.3.4/x"], domains=["1.2.3.4"], ips=["1.2.3.4"])
|
||||
c.source_metadata["url_status"] = "online"
|
||||
return c
|
||||
Reference in New Issue
Block a user