-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from kalaspuff/feature/call-decorated-invoker-…
…methods-directly Invoker methods can now be called directly without the need to mock the invoker decorator function
- Loading branch information
Showing
5 changed files
with
16 additions
and
35 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
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,36 +1,10 @@ | ||
import asyncio | ||
import functools | ||
import importlib | ||
import mock | ||
import services.mock_decorator_service | ||
|
||
|
||
def mock_decorator(*args, **kwargs): | ||
def decorator(f): | ||
@functools.wraps(f) | ||
def decorated_function(*args, **kwargs): | ||
return f(*args, **kwargs) | ||
return decorated_function | ||
return decorator | ||
|
||
|
||
def test_without_mocked_function(monkeypatch, capsys): | ||
import services.mock_decorator_service | ||
importlib.reload(services.mock_decorator_service) | ||
|
||
def test_without_mocked_invoker_function(): | ||
service = services.mock_decorator_service.MockDecoratorService() | ||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(service.test()) | ||
assert service.function_tested is False | ||
|
||
|
||
def test_mocked_function(monkeypatch, capsys): | ||
with mock.patch('tomodachi.transport.aws_sns_sqs.aws_sns_sqs', mock_decorator): | ||
import services.mock_decorator_service | ||
importlib.reload(services.mock_decorator_service) | ||
|
||
service = services.mock_decorator_service.MockDecoratorService() | ||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(service.test()) | ||
assert service.function_tested is True | ||
assert service.function_tested is True |
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
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 +1 @@ | ||
from .base import Invoker, FUNCTION_ATTRIBUTE # noqa | ||
from .base import Invoker, FUNCTION_ATTRIBUTE, START_ATTRIBUTE # noqa |
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