fix(tests): align BDD scenarios with rollback-removal behaviour (PR #8179)
CI / lint (pull_request) Successful in 37s
CI / typecheck (pull_request) Successful in 1m5s
CI / push-validation (pull_request) Successful in 39s
CI / quality (pull_request) Successful in 1m8s
CI / build (pull_request) Successful in 53s
CI / helm (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m25s
CI / unit_tests (pull_request) Successful in 8m49s
CI / integration_tests (pull_request) Successful in 9m50s
CI / docker (pull_request) Successful in 1m47s
CI / coverage (pull_request) Successful in 12m55s
CI / status-check (pull_request) Successful in 3s
CI / lint (pull_request) Successful in 37s
CI / typecheck (pull_request) Successful in 1m5s
CI / push-validation (pull_request) Successful in 39s
CI / quality (pull_request) Successful in 1m8s
CI / build (pull_request) Successful in 53s
CI / helm (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m25s
CI / unit_tests (pull_request) Successful in 8m49s
CI / integration_tests (pull_request) Successful in 9m50s
CI / docker (pull_request) Successful in 1m47s
CI / coverage (pull_request) Successful in 12m55s
CI / status-check (pull_request) Successful in 3s
Three CI gates were failing on this PR; this commit addresses the root
causes for each:
* lint (ruff format): drop the blank line between the docstring close
and first statement in step_pr_create_with_error, and add the missing
second blank line between step_pr_check_remove_link_persisted and the
"Data integrity BDD step extensions" section comment block.
* unit_tests: two scenarios were inverted by `@tdd_expected_fail` on
post-fix assertions, masking unrelated test-logic problems.
- Remove `@tdd_expected_fail` from both `@tdd_issue_8179` scenarios in
project_repository.feature - they describe post-fix behaviour and
must report PASS as PASS, not as inverted-FAIL.
- Drop the "Given project exists" precondition from the Update-non-
existent scenario; the Background already initialises the in-memory
DB and creating the same project being "updated as non-existent" is
self-contradictory (caused the prior scenario to silently report
inverted-PASS while actually never raising).
- Update the OperationalError scenario in database_repository_coverage
to assert the post-fix invariant: the repository no longer calls
session.rollback() itself; that responsibility is delegated to the
outer UnitOfWork. Step text + assertion both flipped.
ISSUES CLOSED: #8179
This commit is contained in:
@@ -42,7 +42,7 @@ Feature: Database Repository Error Handling Coverage
|
||||
Given I have a project repository with a session that fails on create
|
||||
When I attempt to create a project named "failing-project" with that failing session
|
||||
Then a database error should be raised when creating the project
|
||||
And the session rollback should be triggered for the project create failure
|
||||
And the session rollback should not be triggered for the project create failure
|
||||
|
||||
@phase1
|
||||
Scenario: ProjectRepository get_by_id wraps OperationalError in DatabaseError
|
||||
|
||||
@@ -149,14 +149,13 @@ Feature: Namespaced project repository operations
|
||||
|
||||
# ---------- Data integrity: rollback removal verification ----------
|
||||
|
||||
@tdd_issue @tdd_issue_8179 @tdd_expected_fail
|
||||
@tdd_issue @tdd_issue_8179
|
||||
Scenario: IntegrityError raises DatabaseError through repository create method (no explicit rollback)
|
||||
Given a namespaced project "local/integrity-verify" exists in the repository
|
||||
When I create a namespaced project "local/integrity-verify" via the repository expecting an error
|
||||
Then the repository error should be "DatabaseError"
|
||||
|
||||
@tdd_issue @tdd_issue_8179 @tdd_expected_fail
|
||||
@tdd_issue @tdd_issue_8179
|
||||
Scenario: Update non-existent project raises ProjectNotFoundError without leaving transaction dirty
|
||||
Given a namespaced project "local/missing-update-check" exists in the repository
|
||||
When I update a non-existent project "local/missing-update-check" expecting an error
|
||||
Then the repository error should be "ProjectNotFoundError"
|
||||
|
||||
@@ -378,10 +378,14 @@ def step_verify_create_database_error(context):
|
||||
assert isinstance(context.create_error, DatabaseError)
|
||||
|
||||
|
||||
@then("the session rollback should be triggered for the project create failure")
|
||||
@then("the session rollback should not be triggered for the project create failure")
|
||||
def step_verify_create_rollback(context):
|
||||
"""Verify session rollback executed on create failure."""
|
||||
assert context.session_mock.rollback.call_count >= 1
|
||||
"""Verify session rollback NOT executed by the repository on create failure.
|
||||
|
||||
Per PR #8179, ``ProjectRepository.create()`` no longer calls
|
||||
``session.rollback()`` itself — the outer UnitOfWork owns rollback.
|
||||
"""
|
||||
assert context.session_mock.rollback.call_count == 0
|
||||
|
||||
|
||||
@given("I have a project repository with a session that fails on query")
|
||||
|
||||
@@ -566,6 +566,7 @@ def step_pr_removed_link_absent_new_session(context: Any) -> None:
|
||||
finally:
|
||||
new_session.close()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Data integrity BDD step extensions (PR #8179)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -584,7 +585,6 @@ def step_pr_create_with_error(context: Any, ns_name: str) -> None:
|
||||
redundant ``session.rollback()`` was removed from exception handlers —
|
||||
``session.rollback()`` now fires in the ``finally`` block instead.
|
||||
"""
|
||||
|
||||
project = _make_project(ns_name)
|
||||
try:
|
||||
context.pr_project = context.pr_project_repo.create(project)
|
||||
|
||||
Reference in New Issue
Block a user