-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test some more properties of process_transitions
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |