Skip to content

Commit

Permalink
Test some more properties of process_transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
danpalmer committed Jan 12, 2018
1 parent cc6bd78 commit 7a6ac4b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions routemaster/state_machine/tests/test_transitions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import mock

from routemaster.state_machine.exceptions import DeletedLabel
from routemaster.state_machine.transitions import process_transitions


def test_cannot_infinite_loop(app_config, create_label, set_metadata):
label = create_label('foo', 'test_infinite_machine', {})
set_metadata(label, {'should_progress': True})

with mock.patch('routemaster.state_machine.transitions.logger') as logger:
process_transitions(app_config, label)
logger.warn.assert_called_once()


def test_stops_on_delete(app_config, create_label, set_metadata):
label = create_label('foo', 'test_infinite_machine', {})
set_metadata(label, {'should_progress': True})

with mock.patch(
'routemaster.state_machine.transitions.process_gate',
side_effect=[mock.DEFAULT, mock.DEFAULT, DeletedLabel],
) as mock_process_gate:
process_transitions(app_config, label)

assert mock_process_gate.call_count == 3

0 comments on commit 7a6ac4b

Please sign in to comment.