Four-part fix for the collection bottleneck that was blocking the dev loop: 1. Lazy mitreattack.stix20 import in attack_stix.py — deferred to first _load() call (TYPE_CHECKING guard at top level) 2. Lazy misp_stix_converter import in both MISP export routers — moved from module level into the route handler body 3. Lazy attack_catalog / attack_stix in ttp.py repo mixin — thin wrapper functions so the import chain never fires at module load time 4. tests/api/conftest.py — `from decnet.web.api import app` moved inside the `client()` fixture; `pytest_ignore_collect` broadened to skip all test_schemathesis*.py variants (not just test_schemathesis.py), which were launching a subprocess server at module-import time 5. pyproject.toml — `norecursedirs` for tests/live, tests/stress, tests/service_testing, tests/docker, tests/perf so these directories are never entered; `-m` filter removed from addopts (now redundant); `--dist loadscope` → `--dist load` to unblock workers immediately 6. behave_core / behave_shell rename — BEHAVE packages dropped the `decnet_` prefix; reinstalled editable installs and updated all 14 import sites across profiler, ttp, bus, and correlation modules
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
"""W.2 smoke: BEHAVE library pins are install-time importable.
|
|
|
|
Three asserts protect the pyproject.toml pin from a broken wheel /
|
|
missing install / drift in the BEHAVE-side public API. CI catches
|
|
these before they make it onto a running master.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
|
|
def test_envelope_imports_cleanly() -> None:
|
|
from behave_core.spec.envelope import Observation, Window
|
|
# construction smoke — registry-agnostic envelope
|
|
obs = Observation(
|
|
primitive="motor.input_modality",
|
|
value="typed",
|
|
confidence=0.9,
|
|
window=Window(start_ts=0.0, end_ts=1.0),
|
|
source="test",
|
|
)
|
|
assert obs.primitive == "motor.input_modality"
|
|
assert obs.v >= 1
|
|
|
|
|
|
def test_registry_imports_and_is_non_empty() -> None:
|
|
from behave_shell.spec.primitives import PRIMITIVE_REGISTRY
|
|
assert len(PRIMITIVE_REGISTRY) > 0
|
|
# spot-check a primitive every Tier-A engine emits
|
|
assert "motor.input_modality" in PRIMITIVE_REGISTRY
|
|
|
|
|
|
def test_event_adapter_topic_shape() -> None:
|
|
from behave_shell.spec.event_adapter import event_topic_for
|
|
assert (
|
|
event_topic_for("motor.input_modality")
|
|
== "attacker.observation.motor.input_modality"
|
|
)
|
|
|
|
|
|
def test_to_event_payload_excludes_envelope_meta_fields() -> None:
|
|
"""The adapter excludes id/ts/v from payload (they ride at the
|
|
DECNET Event envelope level). The profiler worker re-merges them
|
|
in per BEHAVE-INTEGRATION.md §339-366."""
|
|
from behave_core.spec.envelope import Observation, Window
|
|
from behave_shell.spec.event_adapter import to_event_payload
|
|
obs = Observation(
|
|
primitive="motor.input_modality",
|
|
value="typed",
|
|
confidence=0.9,
|
|
window=Window(start_ts=0.0, end_ts=1.0),
|
|
source="test",
|
|
)
|
|
payload = to_event_payload(obs)
|
|
for excluded in ("id", "ts", "v"):
|
|
assert excluded not in payload, (
|
|
f"event_adapter.to_event_payload leaked {excluded!r} into "
|
|
f"the payload body — DECNET re-merges these explicitly"
|
|
)
|