Files
periscope/tests/test_placement_pipeline.py
T
michele c362ef8a56 Split native Periscope (periscope/src) from inherited PinScope (periscope/dependency).
Keep validate.py and the finding engine as-is. AGPL LICENSE stays at the repo root.
Docker overlays dependency then src. Do not delete the inherited tree.
2026-09-20 14:31:42 +02:00

55 lines
1.7 KiB
Python

"""Placement pipeline smoke — topology only, no LLM."""
from __future__ import annotations
from tests.paths import SIMPLE_PROJECT, TAXONOMY
from pathlib import Path
import pytest
from backend.periscopex.functional_groups import (
FunctionalGroupsReport,
build_placement_plan,
)
from backend.periscopex.models import DesignGraph
ROOT = Path(__file__).resolve().parents[1]
SIMPLE = SIMPLE_PROJECT
@pytest.fixture
def graph() -> DesignGraph:
path = SIMPLE / "design_graph.json"
return DesignGraph.model_validate_json(path.read_text(encoding="utf-8"))
def test_placement_plan_writes_domains_and_groups(graph: DesignGraph, tmp_path: Path):
plan = build_placement_plan(graph)
assert plan.objective == "routing"
assert plan.domains
assert plan.groups
out = tmp_path / "placement_plan.json"
out.write_text(plan.model_dump_json(indent=2) + "\n")
loaded = FunctionalGroupsReport.model_validate_json(out.read_text())
assert len(loaded.groups) == len(plan.groups)
def test_placement_busy_helpers():
from backend.services.projects import ProjectMeta, STATUS_QUEUED, STATUS_RUNNING
# Mirror placement_pipeline helpers without importing the worker stack
# (that pulls Anthropic via services.pipeline in lean test envs).
active = frozenset({"queued", "running"})
analysis = frozenset({STATUS_QUEUED, STATUS_RUNNING})
draft = ProjectMeta(id="p", name="t", created="2026-01-01", user_id="u")
assert (draft.placement_status or "draft") not in active
assert draft.status not in analysis
draft.placement_status = "queued"
assert (draft.placement_status or "draft") in active
draft.status = STATUS_RUNNING
assert draft.status in analysis