Starting to work on #47 a.k.a the context processor mess. This is a first implementation removing all the uggly function calls, but further work must work on less things called "context", as it is bad for readability. Concerns better separated now.
This commit is contained in:
27
tests/test_basics.py
Normal file
27
tests/test_basics.py
Normal file
@ -0,0 +1,27 @@
|
||||
import pprint
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import bonobo
|
||||
import pytest
|
||||
from bonobo.config.processors import ContextCurrifier
|
||||
|
||||
|
||||
def test_count():
|
||||
with pytest.raises(TypeError):
|
||||
bonobo.count()
|
||||
|
||||
context = MagicMock()
|
||||
|
||||
currified = ContextCurrifier(bonobo.count)
|
||||
currified.setup(context)
|
||||
|
||||
for i in range(42):
|
||||
currified()
|
||||
currified.teardown()
|
||||
|
||||
context.send.assert_called_once()
|
||||
bag = context.send.call_args[0][0]
|
||||
assert isinstance(bag, bonobo.Bag)
|
||||
assert 0 == len(bag.kwargs)
|
||||
assert 1 == len(bag.args)
|
||||
assert bag.args[0] == 42
|
||||
Reference in New Issue
Block a user