30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
import pytest
|
|
|
|
from viano_bug_analysis.lifecycle import LifecycleError, State
|
|
from viano_bug_analysis.lifecycle.state import ACTIVE, ORDER, check_transition
|
|
|
|
|
|
@pytest.mark.parametrize("before,after", list(zip(ORDER, ORDER[1:])))
|
|
def test_forward_transitions(before, after):
|
|
check_transition(before, after)
|
|
|
|
|
|
@pytest.mark.parametrize("state", list(ACTIVE))
|
|
def test_block_failure_and_progress_checkpoint(state):
|
|
check_transition(state, State.BLOCKED)
|
|
check_transition(state, State.FAILED_TO_ANALYZE)
|
|
check_transition(state, state)
|
|
check_transition(State.BLOCKED, state, state)
|
|
|
|
|
|
@pytest.mark.parametrize("before,after", [(State.NEW, State.BUILDING_CASE), (State.HANDED_OFF, State.VALIDATED), (State.BLOCKED, State.INTERPRETING_CASE), (State.FAILED_TO_ANALYZE, State.BUILDING_CASE), (State.OUTPUT_READY, State.NEW)])
|
|
def test_forbidden_transitions(before, after):
|
|
with pytest.raises(LifecycleError, match="Cannot transition"):
|
|
check_transition(before, after)
|
|
|
|
|
|
def test_reopening():
|
|
check_transition(State.HANDED_OFF, State.REOPENED)
|
|
check_transition(State.FAILED_TO_ANALYZE, State.REOPENED)
|
|
check_transition(State.REOPENED, State.BUILDING_CASE)
|