Spaces:
Sleeping
Sleeping
Commit ·
fad0d42
1
Parent(s): 96f5f87
test: add pytest config and shared test fixtures
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pyproject.toml +7 -0
- tests/__init__.py +0 -0
- tests/conftest.py +61 -0
pyproject.toml
CHANGED
|
@@ -20,3 +20,10 @@ dependencies = [
|
|
| 20 |
|
| 21 |
[dependency-groups]
|
| 22 |
dev = ["ruff", "pytest"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
[dependency-groups]
|
| 22 |
dev = ["ruff", "pytest"]
|
| 23 |
+
|
| 24 |
+
[tool.pytest.ini_options]
|
| 25 |
+
testpaths = ["tests"]
|
| 26 |
+
pythonpath = ["."]
|
| 27 |
+
markers = [
|
| 28 |
+
"requires_cadquery: marks tests that need CadQuery installed",
|
| 29 |
+
]
|
tests/__init__.py
ADDED
|
File without changes
|
tests/conftest.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared fixtures for NeuralCAD tests."""
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@pytest.fixture
|
| 8 |
+
def tmp_output_dir(tmp_path):
|
| 9 |
+
"""Temporary output directory for model files."""
|
| 10 |
+
out = tmp_path / "output"
|
| 11 |
+
out.mkdir()
|
| 12 |
+
return out
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@pytest.fixture
|
| 16 |
+
def sample_history():
|
| 17 |
+
"""A typical multi-turn conversation history."""
|
| 18 |
+
return [
|
| 19 |
+
{"role": "user", "content": "I need a servo bracket for an MG996R"},
|
| 20 |
+
{"role": "agent", "agent_id": "design", "content": "I'd suggest an L-bracket with a servo pocket on the vertical face."},
|
| 21 |
+
{"role": "agent", "agent_id": "engineering", "content": "3mm wall thickness in aluminum 6061-T6 should handle the load."},
|
| 22 |
+
{"role": "user", "content": "Make it 60mm wide with M4 base mounting holes"},
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@pytest.fixture
|
| 27 |
+
def empty_design_state():
|
| 28 |
+
"""Empty design state dict."""
|
| 29 |
+
return {}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
@pytest.fixture
|
| 33 |
+
def populated_design_state():
|
| 34 |
+
"""Design state with some decisions already made."""
|
| 35 |
+
return {
|
| 36 |
+
"part_name": "servo_bracket",
|
| 37 |
+
"material": "aluminum 6061",
|
| 38 |
+
"dimensions": {"width": 60.0},
|
| 39 |
+
"features": ["4x M4 holes"],
|
| 40 |
+
"decisions": ["L-bracket form factor"],
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class FakeLLMBackend:
|
| 45 |
+
"""A controllable fake LLM backend for testing orchestrators."""
|
| 46 |
+
|
| 47 |
+
def __init__(self, response: str = '{"agents": []}'):
|
| 48 |
+
self.response = response
|
| 49 |
+
self.calls: list[list[dict]] = []
|
| 50 |
+
|
| 51 |
+
def generate(self, messages: list[dict]) -> str:
|
| 52 |
+
self.calls.append(messages)
|
| 53 |
+
return self.response
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
@pytest.fixture
|
| 57 |
+
def fake_backend():
|
| 58 |
+
"""FakeLLMBackend factory — call with desired JSON response."""
|
| 59 |
+
def _make(response: str = '{"agents": []}'):
|
| 60 |
+
return FakeLLMBackend(response)
|
| 61 |
+
return _make
|