feat(v2): complete v2 reimplementation
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from backup_tool.execution import TransitionError, transition
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("current", "target"),
|
||||
[
|
||||
("queued", "preparing"),
|
||||
("queued", "cancelled"),
|
||||
("queued", "failed"),
|
||||
("preparing", "running"),
|
||||
("preparing", "cancelling"),
|
||||
("preparing", "failed"),
|
||||
("running", "verifying"),
|
||||
("running", "cancelling"),
|
||||
("running", "failed"),
|
||||
("verifying", "committed"),
|
||||
("verifying", "failed"),
|
||||
("cancelling", "cancelled"),
|
||||
("cancelling", "failed"),
|
||||
],
|
||||
)
|
||||
def test_all_legal_execution_transitions_are_accepted(current: str, target: str) -> None:
|
||||
assert transition(current, target) == target
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("current", "target"),
|
||||
[
|
||||
("queued", "running"),
|
||||
("preparing", "queued"),
|
||||
("running", "preparing"),
|
||||
("verifying", "cancelling"),
|
||||
("cancelling", "running"),
|
||||
("committed", "cancelled"),
|
||||
("cancelled", "queued"),
|
||||
("failed", "queued"),
|
||||
("unknown", "queued"),
|
||||
],
|
||||
)
|
||||
def test_invalid_or_backward_execution_transitions_are_rejected(current: str, target: str) -> None:
|
||||
with pytest.raises(TransitionError) as raised:
|
||||
transition(current, target)
|
||||
|
||||
assert raised.value.code == "invalid_transition"
|
||||
Reference in New Issue
Block a user