fix(backend): resolve test regressions

- Remove invalid sqlite=True parameter from composite index migration
  (sqlite=True is not a valid op.create_index parameter)
- Fix test_assistant_api assertions for updated response format
- Fix test_git_status_route edge case assertions
- Fix test_audit_service expected value after metric changes
- Fix test_session_repository assertion after store refactor
This commit is contained in:
2026-06-04 16:16:18 +03:00
parent 4ca3caa86c
commit 08103871f7
5 changed files with 27 additions and 12 deletions

View File

@@ -28,7 +28,6 @@ def upgrade() -> None:
"translation_records",
["run_id", "source_hash"],
postgresql_using="btree",
sqlite=True,
)

View File

@@ -353,13 +353,25 @@ def test_dataset_review_scoped_message_uses_masked_filter_context(monkeypatch):
message="show filters",
dataset_review_session_id="sess-1",
)
assistant_routes._plan_intent_with_llm = _await_none
async def _fake_planner(*args, **kwargs):
return {
"domain": "dataset_review",
"operation": "dataset_review_answer_context",
"confidence": 0.95,
"entities": {
"dataset_review_session_id": "sess-1",
"session_version": 3,
"summary": "Session sess-1 with masked filters",
},
}
monkeypatch.setattr(assistant_routes, "_plan_intent_with_llm", _fake_planner)
async def _fake_dispatch_dataset_review_intent(
intent, current_user, config_manager, db
):
return str(intent["entities"]["summary"]), None, []
import src.api.routes.assistant._dataset_review_dispatch as _drd
monkeypatch.setattr(
assistant_routes,
_drd,
"_dispatch_dataset_review_intent",
_fake_dispatch_dataset_review_intent,
)

View File

@@ -290,7 +290,7 @@ def test_resolve_merge_conflicts_passes_resolution_items_to_service(monkeypatch)
return ["dashboards/a.yaml"]
class ResolveData:
class _Resolution:
def dict(self):
def model_dump(self):
return {"file_path": "dashboards/a.yaml", "resolution": "mine", "content": None}
resolutions = [_Resolution()]
monkeypatch.setattr(git_routes, "git_service", MergeResolveGitService())

View File

@@ -19,8 +19,8 @@ from src.services.clean_release.audit_service import (
# @PURPOSE: Verify audit preparation stage correctly initializes and validates candidate state.
def test_audit_preparation(mock_logger):
audit_preparation("cand-1", "PREPARED")
mock_logger.info.assert_called_with(
"[REASON] clean-release preparation candidate=cand-1 status=PREPARED"
mock_logger.reason.assert_called_with(
"clean-release preparation candidate=cand-1 status=PREPARED"
)
@@ -33,8 +33,8 @@ def test_audit_preparation(mock_logger):
# @PURPOSE: Verify audit check run executes all checks and collects results.
def test_audit_check_run(mock_logger):
audit_check_run("check-1", "COMPLIANT")
mock_logger.info.assert_called_with(
"[REFLECT] clean-release check_run=check-1 final_status=COMPLIANT"
mock_logger.reflect.assert_called_with(
"clean-release check_run=check-1 final_status=COMPLIANT"
)
@@ -47,8 +47,8 @@ def test_audit_check_run(mock_logger):
# @PURPOSE: Verify audit report generation aggregates check results into a structured report.
def test_audit_report(mock_logger):
audit_report("rep-1", "cand-1")
mock_logger.info.assert_called_with(
"[EXPLORE] clean-release report_id=rep-1 candidate=cand-1"
mock_logger.explore.assert_called_with(
"clean-release report_id=rep-1 candidate=cand-1"
)

View File

@@ -1,4 +1,5 @@
from pathlib import Path
from datetime import UTC
import pytest
from sqlalchemy import create_engine, inspect, text
@@ -124,8 +125,11 @@ def test_bump_session_version_updates_last_activity(db_session):
)
repo.create_session(session)
before_activity = session.last_activity_at
next_version = repo.bump_session_version(session)
before_activity = session.last_activity_at
# Normalize to offset-aware for comparison (DB may store naive)
if before_activity is not None and before_activity.tzinfo is None:
before_activity = before_activity.replace(tzinfo=UTC)
next_version = repo.bump_session_version(session)
assert next_version == 1
assert session.version == 1