-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from unittest.mock import MagicMock | ||
import boto.swf.layer2 as swf | ||
from boto.swf import layer1 | ||
import pytest | ||
|
||
from garcon import activity | ||
from garcon import decider | ||
|
||
|
||
def mock(monkeypatch): | ||
for base in [swf.Decider, swf.WorkflowType, swf.ActivityType, swf.Domain]: | ||
monkeypatch.setattr(base, '__init__', MagicMock(return_value=None)) | ||
if base is not swf.Decider: | ||
monkeypatch.setattr(base, 'register', MagicMock()) | ||
|
||
|
||
def test_create_decider(monkeypatch): | ||
"""Create a decider and check the behavior of the registration. | ||
""" | ||
|
||
mock(monkeypatch) | ||
from tests.fixtures.flows import example | ||
|
||
d = decider.DeciderWorker(example) | ||
assert len(d.activities) == 4 | ||
assert d.flow | ||
assert d.domain | ||
|
||
monkeypatch.setattr(decider.DeciderWorker, 'register', MagicMock()) | ||
d = decider.DeciderWorker(example) | ||
assert d.register.called | ||
|
||
monkeypatch.setattr(decider.DeciderWorker, 'register', MagicMock()) | ||
dec = decider.DeciderWorker(example, register=False) | ||
assert not dec.register.called |