fix(cli): use container DI override for correction service mock in integration test
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 23s
CI / typecheck (pull_request) Successful in 47s
CI / lint (pull_request) Successful in 3m20s
CI / quality (pull_request) Successful in 3m55s
CI / security (pull_request) Successful in 4m8s
CI / unit_tests (pull_request) Successful in 6m19s
CI / docker (pull_request) Successful in 12s
CI / integration_tests (pull_request) Successful in 9m11s
CI / coverage (pull_request) Successful in 13m11s
CI / e2e_tests (pull_request) Successful in 20m10s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 55m31s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 23s
CI / typecheck (pull_request) Successful in 47s
CI / lint (pull_request) Successful in 3m20s
CI / quality (pull_request) Successful in 3m55s
CI / security (pull_request) Successful in 4m8s
CI / unit_tests (pull_request) Successful in 6m19s
CI / docker (pull_request) Successful in 12s
CI / integration_tests (pull_request) Successful in 9m11s
CI / coverage (pull_request) Successful in 13m11s
CI / e2e_tests (pull_request) Successful in 20m10s
CI / status-check (pull_request) Successful in 2s
CI / benchmark-regression (pull_request) Successful in 55m31s
The plan_correct_isolated_resolve robot helper patched CorrectionService at the module level, but correct_decision now resolves the service via container.correction_service(). The module-level patch had no effect on the container's already-imported reference, causing the mock to never intercept the call and the test to fail with exit code 1. Replace unittest.mock.patch with container.correction_service.override() which is the idiomatic dependency-injector mechanism and correctly intercepts the singleton provider. ISSUES CLOSED: #1025
This commit is contained in:
@@ -13,7 +13,7 @@ import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from typer.testing import CliRunner
|
||||
from ulid import ULID
|
||||
@@ -90,10 +90,8 @@ def run_regression() -> int:
|
||||
)
|
||||
|
||||
runner = CliRunner()
|
||||
with patch(
|
||||
"cleveragents.application.services.correction_service.CorrectionService",
|
||||
return_value=fake_svc,
|
||||
):
|
||||
container = get_container()
|
||||
with container.correction_service.override(fake_svc):
|
||||
result = runner.invoke(
|
||||
plan_app,
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user