fix(tests): assert the withdrawn flag on its row, not on a count the skew margin inflates (#4208)
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / TypeScript typecheck (push) Successful in 52s
CI & Build / integration (push) Successful in 1m1s
CI & Build / Python tests (push) Successful in 1m34s
CI & Build / Build & push image (push) Successful in 14s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 9s
CI & Build / TypeScript typecheck (push) Successful in 52s
CI & Build / integration (push) Successful in 1m1s
CI & Build / Python tests (push) Successful in 1m34s
CI & Build / Build & push image (push) Successful in 14s
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01821k5B3Ysecp9fNYs92Kuy
This commit is contained in:
@@ -1057,24 +1057,36 @@ async def test_a_later_conclusive_miss_withdraws_a_flag_raised_before_it(seeded)
|
|||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from scribe.services import shape_ledger
|
from scribe.services import shape_ledger
|
||||||
from scribe.services.shape_ledger import flag_divergence, propose_for_repo
|
from scribe.services.shape_ledger import (
|
||||||
|
BASIS_NO_SEMANTIC_MATCH, flag_divergence, live_rows, propose_for_repo,
|
||||||
|
)
|
||||||
|
|
||||||
owner, pid, later, previous = await _two_generations(seeded, "withdraw")
|
owner, pid, later, previous = await _two_generations(seeded, "withdraw")
|
||||||
since = previous - timedelta(seconds=1)
|
since = previous - timedelta(seconds=1)
|
||||||
|
|
||||||
|
async def _danger():
|
||||||
|
return next(r for r in await live_rows(pid) if r.symbol == "confirmDanger")
|
||||||
|
|
||||||
|
# Asserted on the ROW, not on a flag count. `since` sits a second before
|
||||||
|
# the second sync to absorb clock skew, which also admits the fixture's
|
||||||
|
# old helper as "new" — how many rows get flagged is a property of that
|
||||||
|
# margin, and this test is about one row's flag coming off.
|
||||||
|
|
||||||
# First refresh: the arm is quiet (formed no opinion), so the prompt is raised.
|
# First refresh: the arm is quiet (formed no opinion), so the prompt is raised.
|
||||||
with patch.object(shape_ledger, "_semantic_canon", AsyncMock(return_value=None)):
|
with patch.object(shape_ledger, "_semantic_canon", AsyncMock(return_value=None)):
|
||||||
await propose_for_repo(owner, pid, REPO, later)
|
await propose_for_repo(owner, pid, REPO, later)
|
||||||
assert await flag_divergence(pid, since=since) == 1
|
await flag_divergence(pid, since=since)
|
||||||
|
assert (await _danger()).diverges_from is not None
|
||||||
|
|
||||||
# A later refresh re-reads the body (a ruleset bump forces it) and is sure.
|
# A later refresh re-reads the body (a ruleset bump forces it) and is sure.
|
||||||
with patch.object(shape_ledger, "_PROPOSER_VERSION", 10_000), \
|
with patch.object(shape_ledger, "_PROPOSER_VERSION", 10_000), \
|
||||||
patch.object(shape_ledger, "_semantic_canon",
|
patch.object(shape_ledger, "_semantic_canon",
|
||||||
AsyncMock(side_effect=_conclusive)):
|
AsyncMock(side_effect=_conclusive)):
|
||||||
await propose_for_repo(owner, pid, REPO, later)
|
await propose_for_repo(owner, pid, REPO, later)
|
||||||
assert await flag_divergence(pid, since=since) == 0
|
await flag_divergence(pid, since=since)
|
||||||
_, total = await list_project_shapes(owner, pid, flag="divergence")
|
danger = await _danger()
|
||||||
assert total == 0
|
assert danger.proposal_basis == BASIS_NO_SEMANTIC_MATCH
|
||||||
|
assert danger.diverges_from is None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.integration
|
@pytest.mark.integration
|
||||||
|
|||||||
Reference in New Issue
Block a user