Files
nifodea/tests/test_ai.py
T
oqyude 541a76835f T5: Dependency Injection — services через composition root
- AssistantService теперь принимает ForecastService в конструкторе
  (раньше создавал new ForecastService() внутри analyze/advice)
- infrastructure/cli/main.py: _build_services() — composition root,
  собирает граф ForecastService, ScenarioService, AssistantService, CurrencyConverter
- Все CLI-команды используют _build_services(model) вместо прямого new
- test_ai.py: обновлён под новый контракт AssistantService

Tests: 67/67 pass.
2026-10-08 16:53:04 +03:00

20 lines
851 B
Python

from application.forecast import ForecastService
from infrastructure.ai.assistant import AssistantService
class TestAssistantService:
def test_analyze_returns_prompt(self, sample_model):
forecast_service = ForecastService(sample_model)
assistant = AssistantService(sample_model, forecast_service=forecast_service)
result = assistant.analyze(months=6)
assert "prompt" in result
assert "summary" in result
assert result["ai_response"] is None
def test_advice_returns_prompt(self, sample_model):
forecast_service = ForecastService(sample_model)
assistant = AssistantService(sample_model, forecast_service=forecast_service)
result = assistant.advice("Как мне сэкономить?", months=6)
assert "prompt" in result
assert "ai_response" in result