diff --git a/features/resource_cli_coverage_boost.feature b/features/resource_cli_coverage_boost.feature index c33f665d8..8b60f9f8e 100644 --- a/features/resource_cli_coverage_boost.feature +++ b/features/resource_cli_coverage_boost.feature @@ -56,7 +56,7 @@ Feature: Resource CLI coverage boost for remaining uncovered lines Given a mock resource service whose session reports edges on the resource When I invoke resource remove with --yes via CliRunner for the edged resource Then the CliRunner exit code should be non-zero - And the CliRunner output should contain "edge(s) still reference it" + And the CliRunner output should contain "link(s) still reference it" # ---- resource_remove generic Exception rollback (lines 668-672) ---- diff --git a/features/steps/resource_cli_coverage_boost_steps.py b/features/steps/resource_cli_coverage_boost_steps.py index b444349bb..636f25f59 100644 --- a/features/steps/resource_cli_coverage_boost_steps.py +++ b/features/steps/resource_cli_coverage_boost_steps.py @@ -291,13 +291,13 @@ def step_mock_service_resource_edges(context: Context) -> None: mock_session = MagicMock() - # ResourceEdgeModel query → count returns 3 (edges exist) - edge_query = MagicMock() - edge_query.filter.return_value.count.return_value = 3 + # ResourceLinkModel query → count returns 3 (links exist) + link_query = MagicMock() + link_query.filter.return_value.count.return_value = 3 mock_session.query.side_effect = _smart_query_side_effect( { - "ResourceEdgeModel": edge_query, + "ResourceLinkModel": link_query, } ) svc._session.return_value = mock_session @@ -335,9 +335,9 @@ def step_mock_service_resource_delete_exception(context: Context) -> None: mock_session = MagicMock() - # ResourceEdgeModel query → count returns 0 (no edges) - edge_query = MagicMock() - edge_query.filter.return_value.count.return_value = 0 + # ResourceLinkModel query → count returns 0 (no links) + link_query = MagicMock() + link_query.filter.return_value.count.return_value = 0 # ResourceModel query → first returns a mock row mock_row = MagicMock() @@ -346,7 +346,7 @@ def step_mock_service_resource_delete_exception(context: Context) -> None: mock_session.query.side_effect = _smart_query_side_effect( { - "ResourceEdgeModel": edge_query, + "ResourceLinkModel": link_query, "ResourceModel": resource_query, } ) diff --git a/features/steps/tdd_resource_remove_children_guard_steps.py b/features/steps/tdd_resource_remove_children_guard_steps.py index 0deabcb39..45bdd3a58 100644 --- a/features/steps/tdd_resource_remove_children_guard_steps.py +++ b/features/steps/tdd_resource_remove_children_guard_steps.py @@ -8,7 +8,6 @@ from behave.runner import Context # type: ignore[import-untyped] from cleveragents.application.services.resource_registry_service import ( ResourceRegistryService, ) - from features.steps import resource_cli_steps as resource_cli diff --git a/robot/helper_tdd_resource_remove_children_guard.py b/robot/helper_tdd_resource_remove_children_guard.py index 9da7a60a2..296d63bfe 100644 --- a/robot/helper_tdd_resource_remove_children_guard.py +++ b/robot/helper_tdd_resource_remove_children_guard.py @@ -1,4 +1,3 @@ - """Helper script for tdd_resource_remove_children_guard.robot integration tests.""" from __future__ import annotations @@ -6,25 +5,20 @@ from __future__ import annotations import contextlib import os import sys -from pathlib import Path -from typing import Iterator, NoReturn +from collections.abc import Iterator +from typing import NoReturn from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.pool import StaticPool from typer.testing import CliRunner -ROOT: Path = Path(__file__).resolve().parents[1] -SRC_DIR: str = str(ROOT / "src") -if SRC_DIR not in sys.path: - sys.path.insert(0, SRC_DIR) - from cleveragents.application.services.resource_registry_service import ( ResourceRegistryService, ) +from cleveragents.cli.commands.resource import app as resource_app from cleveragents.core.exceptions import NotFoundError from cleveragents.infrastructure.database.models import Base -from cleveragents.cli.commands.resource import app as resource_app RUNNER: CliRunner = CliRunner() @@ -102,9 +96,7 @@ def _scenario_block_parent_removal() -> None: result = _invoke(service, "remove", "--yes", parent_name) if result.exit_code == 0: - _fail( - "resource remove succeeded unexpectedly despite existing DAG links." - ) + _fail("resource remove succeeded unexpectedly despite existing DAG links.") if "link(s) still reference" not in result.stdout: _fail( "resource remove did not report remaining links when guard triggered.\n" @@ -152,7 +144,10 @@ def main(argv: list[str]) -> int: """Entry point dispatcher for helper subcommands.""" if len(argv) < 2: - _fail("Missing subcommand: expected 'block-parent-removal' or 'unlink-then-remove'.") + _fail( + "Missing subcommand: expected 'block-parent-removal' or " + "'unlink-then-remove'." + ) command = argv[1] if command == "block-parent-removal":