neuralcad / tests /conftest.py
CallMeDaniel's picture
refactor: update test fixtures to use Pydantic models
beda709
"""Shared fixtures for NeuralCAD tests."""
import pytest
from pathlib import Path
from agents.design_state import DesignState
@pytest.fixture
def tmp_output_dir(tmp_path):
"""Temporary output directory for model files."""
out = tmp_path / "output"
out.mkdir()
return out
@pytest.fixture
def sample_history():
"""A typical multi-turn conversation history."""
return [
{"role": "user", "content": "I need a servo bracket for an MG996R"},
{"role": "agent", "agent_id": "design", "content": "I'd suggest an L-bracket with a servo pocket on the vertical face."},
{"role": "agent", "agent_id": "engineering", "content": "3mm wall thickness in aluminum 6061-T6 should handle the load."},
{"role": "user", "content": "Make it 60mm wide with M4 base mounting holes"},
]
@pytest.fixture
def empty_design_state():
"""Empty design state."""
return DesignState()
@pytest.fixture
def populated_design_state():
"""Design state with some decisions already made."""
return DesignState(
part_name="servo_bracket",
material="aluminum 6061",
dimensions={"width": 60.0},
features=["4x M4 holes"],
decisions=["L-bracket form factor"],
)
class FakeLLMBackend:
"""A controllable fake LLM backend for testing orchestrators."""
def __init__(self, response: str = '{"agents": []}'):
self.response = response
self.calls: list[list[dict]] = []
def generate(self, messages: list[dict]) -> str:
self.calls.append(messages)
return self.response
@pytest.fixture
def fake_backend():
"""FakeLLMBackend factory — call with desired JSON response."""
def _make(response: str = '{"agents": []}'):
return FakeLLMBackend(response)
return _make