fixup! Add MapFields transformation

This commit is contained in:
Kryštof Pilnáček
2018-10-29 13:52:20 +01:00
parent 721bdb4318
commit f93f6bb62e
2 changed files with 13 additions and 5 deletions

View File

@ -123,6 +123,8 @@ MyBag = BagType("MyBag", ["a", "b", "c"])
(MyBag(1, 2, 3), True, MyBag(1, 4, 9)),
(MyBag(1, 2, 3), False, MyBag(1, 2, 3)),
(MyBag(1, 2, 3), lambda x: x == 'c', MyBag(1, 2, 9)),
((1, 2, 3), True, (1, 4, 9)),
((1, 2, 3), False, (1, 2, 3)),
])
def test_map_fields(input_, key, expected):
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x**2, key)) as context:
@ -133,7 +135,7 @@ def test_map_fields(input_, key, expected):
def test_map_fields_error():
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x**2)) as context:
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x**2, lambda x: x == 'c')) as context:
context.write_sync(tuple())
assert context.status == '!'
assert context.defunct