Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_append_states_after_terminal_state_will_fail():
with pytest.raises(ValueError):
chain = Chain()
chain.append(Pass('Pass'))
chain.append(Fail('Fail'))
chain.append(Pass('Pass2'))
with pytest.raises(ValueError):
chain = Chain()
chain.append(Pass('Pass'))
chain.append(Succeed('Succeed'))
chain.append(Pass('Pass2'))
with pytest.raises(ValueError):
chain = Chain()
chain.append(Pass('Pass'))
chain.append(Choice('Choice'))
chain.append(Pass('Pass2'))
def test_fail_creation():
fail_state = Fail(
state_id='Fail',
error='ErrorA',
cause='Kaiju attack',
comment='This is a comment'
)
assert fail_state.state_id == 'Fail'
assert fail_state.error == 'ErrorA'
assert fail_state.cause == 'Kaiju attack'
assert fail_state.comment == 'This is a comment'
assert fail_state.to_dict() == {
'Type': 'Fail',
'Comment': 'This is a comment',
'Error': 'ErrorA',
'Cause': 'Kaiju attack'
}
def test_verify_fail_state_fields():
with pytest.raises(TypeError):
Fail('Succeed', unknown_field='Unknown Field')