test: 5 final agents — fix 40+ failures, llm_analysis 80%+, git_plugin 90%+, routes 90-98%, services 98-100%, core 90-100%. Coverage: real 87%, target 95%+
This commit is contained in:
@@ -7,7 +7,7 @@ from sqlalchemy import create_engine, event
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
import pytest
|
||||
|
||||
from src.models.translate import Base, TranslationJob, TranslationRun
|
||||
from src.models.translate import Base, TranslationBatch, TranslationJob, TranslationRun
|
||||
from src.plugins.translate.events import TranslationEventLog
|
||||
|
||||
# Shared IDs for FK references
|
||||
@@ -36,12 +36,16 @@ def db_session():
|
||||
Base.metadata.drop_all(bind=engine)
|
||||
|
||||
|
||||
BATCH_ID = "batch-1"
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db_with_run(db_session):
|
||||
"""Create a TranslationRun in addition to the base job, with RUN_STARTED event."""
|
||||
"""Create a TranslationRun and TranslationBatch in addition to the base job."""
|
||||
run = TranslationRun(id=RUN_ID, job_id=JOB_ID, status="RUNNING",
|
||||
started_at=datetime.now(UTC))
|
||||
db_session.add(run)
|
||||
batch = TranslationBatch(id=BATCH_ID, run_id=RUN_ID, batch_index=0, status="PENDING")
|
||||
db_session.add(batch)
|
||||
db_session.commit()
|
||||
# Log RUN_STARTED event so downstream events can be logged
|
||||
event_log = TranslationEventLog(db_session)
|
||||
|
||||
@@ -144,6 +144,23 @@ class TestCancelRun:
|
||||
result = cancel_run(session, event_log, "test_user", run_id)
|
||||
assert result is not None
|
||||
|
||||
def test_cancel_run_fallback_no_run_found(self):
|
||||
"""_fallback_cancel_request with nonexistent run raises ValueError."""
|
||||
session, engine = None, None
|
||||
from sqlalchemy import create_engine, event
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from src.plugins.translate.orchestrator_cancel import _fallback_cancel_request
|
||||
|
||||
from src.models.translate import Base
|
||||
engine = create_engine("sqlite:///:memory:")
|
||||
Base.metadata.create_all(bind=engine)
|
||||
session = sessionmaker(bind=engine)()
|
||||
try:
|
||||
with pytest.raises(ValueError, match="not found"):
|
||||
_fallback_cancel_request(session, "nonexistent-run-id")
|
||||
finally:
|
||||
session.close()
|
||||
|
||||
|
||||
class TestRetryInsert:
|
||||
"""Verify retry_insert function."""
|
||||
|
||||
Reference in New Issue
Block a user