Spaces:
Sleeping
Sleeping
| """Tests for agents/base.py — BaseOrchestrator ABC.""" | |
| import pytest | |
| from agents.base import BaseOrchestrator | |
| from agents.agent_flow import ChatTurnResponse | |
| from agents.design_state import DesignState | |
| class TestBaseOrchestrator: | |
| def test_cannot_instantiate(self): | |
| with pytest.raises(TypeError): | |
| BaseOrchestrator() | |
| def test_subclass_must_implement_chat_turn(self): | |
| class Incomplete(BaseOrchestrator): | |
| pass | |
| with pytest.raises(TypeError): | |
| Incomplete() | |
| def test_subclass_with_chat_turn(self, tmp_path): | |
| class Complete(BaseOrchestrator): | |
| def chat_turn(self, message, history, mentions=None, design_state=None, plan_context=False): | |
| return ChatTurnResponse(responses=[], preview=None, design_state=DesignState()) | |
| orch = Complete(output_dir=tmp_path) | |
| result = orch.chat_turn("test", []) | |
| assert isinstance(result, ChatTurnResponse) | |
| assert result.responses == [] | |
| def test_output_dir_created(self, tmp_path): | |
| out = tmp_path / "new_dir" | |
| class Complete(BaseOrchestrator): | |
| def chat_turn(self, message, history, mentions=None, design_state=None, plan_context=False): | |
| return ChatTurnResponse(responses=[], preview=None, design_state=DesignState()) | |
| orch = Complete(output_dir=out) | |
| assert out.exists() | |
| def test_default_output_dir_from_settings(self): | |
| class Complete(BaseOrchestrator): | |
| def chat_turn(self, message, history, mentions=None, design_state=None, plan_context=False): | |
| return ChatTurnResponse(responses=[], preview=None, design_state=DesignState()) | |
| orch = Complete() | |
| assert orch.output_dir is not None | |