[config] Adds test for requires() decorator.
This commit is contained in:
@ -58,19 +58,22 @@ class ConfigurationError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MissingServiceImplementationError(KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class UnrecoverableError(Exception):
|
class UnrecoverableError(Exception):
|
||||||
"""Flag for errors that must interrupt the workflow, either because they will happen for sure on each node run, or
|
"""Flag for errors that must interrupt the workflow, either because they will happen for sure on each node run, or
|
||||||
because you know that your transformation has no point continuing runnning after a bad event."""
|
because you know that your transformation has no point continuing runnning after a bad event."""
|
||||||
|
|
||||||
|
|
||||||
class UnrecoverableValueError(UnrecoverableError, ValueError):
|
class UnrecoverableValueError(UnrecoverableError, ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UnrecoverableRuntimeError(UnrecoverableError, RuntimeError):
|
class UnrecoverableRuntimeError(UnrecoverableError, RuntimeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UnrecoverableNotImplementedError(UnrecoverableError, NotImplementedError):
|
class UnrecoverableNotImplementedError(UnrecoverableError, NotImplementedError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MissingServiceImplementationError(UnrecoverableError, KeyError):
|
||||||
|
pass
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import time
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bonobo.config import Configurable, Container, Exclusive, Service
|
from bonobo.config import Configurable, Container, Exclusive, Service, requires
|
||||||
from bonobo.config.services import validate_service_name
|
from bonobo.config.services import validate_service_name
|
||||||
|
|
||||||
|
|
||||||
@ -94,3 +94,23 @@ def test_exclusive():
|
|||||||
'hello', '0 0', '0 1', '0 2', '0 3', '0 4', '1 0', '1 1', '1 2', '1 3', '1 4', '2 0', '2 1', '2 2', '2 3',
|
'hello', '0 0', '0 1', '0 2', '0 3', '0 4', '1 0', '1 1', '1 2', '1 3', '1 4', '2 0', '2 1', '2 2', '2 3',
|
||||||
'2 4', '3 0', '3 1', '3 2', '3 3', '3 4', '4 0', '4 1', '4 2', '4 3', '4 4'
|
'2 4', '3 0', '3 1', '3 2', '3 3', '3 4', '4 0', '4 1', '4 2', '4 3', '4 4'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_requires():
|
||||||
|
vcr = VCR()
|
||||||
|
|
||||||
|
services = Container(
|
||||||
|
output=vcr.append
|
||||||
|
)
|
||||||
|
|
||||||
|
@requires('output')
|
||||||
|
def append(out, x):
|
||||||
|
out(x)
|
||||||
|
|
||||||
|
svcargs = services.args_for(append)
|
||||||
|
assert len(svcargs) == 1
|
||||||
|
assert svcargs[0] == vcr.append
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user