File size: 1,805 Bytes
fad0d42
 
 
 
 
beda709
 
fad0d42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
beda709
 
fad0d42
 
 
 
 
beda709
 
 
 
 
 
 
fad0d42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""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