This commit is contained in:
+17
-20
@@ -105,7 +105,6 @@ def test_command_received_preserves_input_and_requests_authorization() -> None:
|
||||
("body", "pr_number", "expected_kind", "expected_message"),
|
||||
[
|
||||
("/agent plan write tests", None, JobKind.PLAN, "write tests"),
|
||||
("/agent iterate refine", None, JobKind.ITERATE_PLAN, "refine"),
|
||||
("/agent iterate address review", 8, JobKind.ITERATE_IMPLEMENT, "address review"),
|
||||
],
|
||||
)
|
||||
@@ -342,36 +341,34 @@ def test_comment_link_is_allowed_after_a_job_is_terminal() -> None:
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("state", "event"),
|
||||
("state", "event", "error_match"),
|
||||
[
|
||||
(received(), JobStarted(job_id="job")),
|
||||
(queued(), PermissionGranted(job_id="job")),
|
||||
(running(), PermissionGranted(job_id="job")),
|
||||
(None, PermissionGranted(job_id="job"), "Only CommandReceived"),
|
||||
(
|
||||
received(),
|
||||
PermissionDenied(job_id="another-job"),
|
||||
"job ID does not match",
|
||||
),
|
||||
(received(), JobStarted(job_id="job"), "invalid while job"),
|
||||
(queued(), PermissionGranted(job_id="job"), "invalid while job"),
|
||||
(running(), PermissionGranted(job_id="job"), "invalid while job"),
|
||||
(
|
||||
reduce_job(running(), JobCompleted(job_id="job", comment_body="ok")).job,
|
||||
JobStarted(job_id="job"),
|
||||
"invalid while job",
|
||||
),
|
||||
],
|
||||
ids=["received", "queued", "running", "terminal"],
|
||||
ids=["missing-state", "mismatched-id", "received", "queued", "running", "terminal"],
|
||||
)
|
||||
def test_events_invalid_for_the_current_status_are_rejected(
|
||||
state: Job,
|
||||
event: JobStarted | PermissionGranted,
|
||||
def test_invalid_transitions_are_rejected(
|
||||
state: Job | None,
|
||||
event: JobStarted | PermissionDenied | PermissionGranted,
|
||||
error_match: str,
|
||||
) -> None:
|
||||
with pytest.raises(InvalidTransition, match="invalid while job"):
|
||||
with pytest.raises(InvalidTransition, match=error_match):
|
||||
reduce_job(state, event)
|
||||
|
||||
|
||||
def test_only_command_received_can_create_state() -> None:
|
||||
with pytest.raises(InvalidTransition, match="Only CommandReceived"):
|
||||
reduce_job(None, PermissionGranted(job_id="job"))
|
||||
|
||||
|
||||
def test_event_job_id_must_match_state() -> None:
|
||||
with pytest.raises(InvalidTransition, match="job ID does not match"):
|
||||
reduce_job(received(), PermissionDenied(job_id="another-job"))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("state", "expected"),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user