38 lines
970 B
Python
38 lines
970 B
Python
from unittest.mock import Mock
|
|
|
|
from test_config import settings
|
|
|
|
from lai_automation.models import FailureReport
|
|
from lai_automation.worker import AutomationWorker
|
|
|
|
|
|
def test_dry_run_generates_task_without_agent_or_git() -> None:
|
|
report = FailureReport(
|
|
id=11,
|
|
chat_message_id=1,
|
|
source="automatic",
|
|
category="sql_execution",
|
|
user_feedback=None,
|
|
prompt="List locations",
|
|
response=None,
|
|
sql_query=None,
|
|
error_message="Unknown column",
|
|
context={},
|
|
)
|
|
worker = AutomationWorker(settings())
|
|
worker.reports = Mock()
|
|
worker.reports.claim_next.return_value = report
|
|
|
|
assert worker.run_once()
|
|
worker.reports.release.assert_called_once()
|
|
worker.agent = Mock()
|
|
worker.agent.run.assert_not_called()
|
|
|
|
|
|
def test_stop_signal_interrupts_worker_wait() -> None:
|
|
worker = AutomationWorker(settings())
|
|
|
|
worker._stop(15, None)
|
|
|
|
assert worker.stop_event.is_set()
|