Working toward sqlalchemy extension. Better ability to extend context. Still needs a lot of cleanup.

This commit is contained in:
Romain Dorgueil
2017-01-03 22:06:09 +01:00
parent 6bfe751c73
commit f736e7e7e3
27 changed files with 387 additions and 142 deletions

View File

@ -5,7 +5,8 @@ from bonobo.core.bags import INHERIT_INPUT
args = (
'foo',
'bar', )
'bar',
)
kwargs = dict(acme='corp')
@ -40,13 +41,15 @@ def test_inherit():
assert bag2.args == (
'a',
'b', )
'b',
)
assert bag2.kwargs == {'a': 1, 'b': 2}
assert INHERIT_INPUT in bag2.flags
assert bag3.args == (
'a',
'c', )
'c',
)
assert bag3.kwargs == {'a': 1, 'c': 3}
assert bag3.flags is ()
@ -57,7 +60,8 @@ def test_inherit():
bag4.set_parent(bag)
assert bag4.args == (
'a',
'd', )
'd',
)
assert bag4.kwargs == {'a': 1, 'd': 4}
assert bag4.flags is ()
@ -65,7 +69,8 @@ def test_inherit():
assert bag4.args == (
'a',
'c',
'd', )
'd',
)
assert bag4.kwargs == {'a': 1, 'c': 3, 'd': 4}
assert bag4.flags is ()

View File

@ -5,7 +5,8 @@ class MyThingWithStats(WithStatistics):
def get_stats(self, *args, **kwargs):
return (
('foo', 42),
('bar', 69), )
('bar', 69),
)
def test_with_statistics():

View File

@ -19,17 +19,18 @@ class ResponseMock:
def test_read_from_opendatasoft_api():
extract = from_opendatasoft_api('http://example.com/', 'test-a-set')
with patch(
'requests.get', return_value=ResponseMock([
{
'fields': {
'foo': 'bar'
}
},
{
'fields': {
'foo': 'zab'
}
},
])):
'requests.get', return_value=ResponseMock([
{
'fields': {
'foo': 'bar'
}
},
{
'fields': {
'foo': 'zab'
}
},
])
):
for line in extract():
assert 'foo' in line

View File

@ -11,7 +11,8 @@ from bonobo.util.tokens import BEGIN, END
[
(('ACME', ), 'ACME'), # one line...
(('Foo', 'Bar', 'Baz'), 'Foo\nBar\nBaz'), # more than one line...
])
]
)
def test_file_writer_in_context(tmpdir, lines, output):
file = tmpdir.join('output.txt')