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:
m17hr1l
2026-05-18 23:36:41 +02:00
parent bc61b9a3a1
commit e504b3dbcf
9 changed files with 403 additions and 0 deletions

40
tests/conftest.py Normal file
View 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