formating, better consistency in readers, ability to read files from http (fast and dirty).

This commit is contained in:
Romain Dorgueil
2017-02-12 08:10:22 +01:00
parent 9dab39a474
commit b035bdea32
33 changed files with 203 additions and 158 deletions

View File

@ -3,10 +3,7 @@ from mock import Mock
from bonobo import Bag
from bonobo.core.bags import INHERIT_INPUT
args = (
'foo',
'bar',
)
args = ('foo', 'bar', )
kwargs = dict(acme='corp')
@ -39,17 +36,11 @@ def test_inherit():
assert bag.kwargs == {'a': 1}
assert bag.flags is ()
assert bag2.args == (
'a',
'b',
)
assert bag2.args == ('a', 'b', )
assert bag2.kwargs == {'a': 1, 'b': 2}
assert INHERIT_INPUT in bag2.flags
assert bag3.args == (
'a',
'c',
)
assert bag3.args == ('a', 'c', )
assert bag3.kwargs == {'a': 1, 'c': 3}
assert bag3.flags is ()
@ -58,19 +49,12 @@ def test_inherit():
assert bag4.flags is ()
bag4.set_parent(bag)
assert bag4.args == (
'a',
'd',
)
assert bag4.args == ('a', 'd', )
assert bag4.kwargs == {'a': 1, 'd': 4}
assert bag4.flags is ()
bag4.set_parent(bag3)
assert bag4.args == (
'a',
'c',
'd',
)
assert bag4.args == ('a', 'c', 'd', )
assert bag4.kwargs == {'a': 1, 'c': 3, 'd': 4}
assert bag4.flags is ()

View File

@ -3,10 +3,7 @@ from bonobo.core.statistics import WithStatistics
class MyThingWithStats(WithStatistics):
def get_statistics(self, *args, **kwargs):
return (
('foo', 42),
('bar', 69),
)
return (('foo', 42), ('bar', 69), )
def test_with_statistics():

View File

@ -1,6 +1,7 @@
from mock import patch
from bonobo.ext.opendatasoft import from_opendatasoft_api
from bonobo.ext.opendatasoft import OpenDataSoftAPI
from bonobo.util.objects import ValueHolder
class ResponseMock:
@ -13,11 +14,13 @@ class ResponseMock:
return {}
else:
self.count += 1
return {'records': self.json_value, }
return {
'records': self.json_value,
}
def test_read_from_opendatasoft_api():
extract = from_opendatasoft_api('http://example.com/', 'test-a-set')
extract = OpenDataSoftAPI(dataset='test-a-set')
with patch(
'requests.get', return_value=ResponseMock([
{
@ -32,5 +35,5 @@ def test_read_from_opendatasoft_api():
},
])
):
for line in extract():
for line in extract('http://example.com/', ValueHolder(0)):
assert 'foo' in line

View File

@ -5,9 +5,7 @@ import bonobo as bb
@pytest.mark.timeout(2)
def test_run_graph_noop():
graph = bb.Graph(
bb.noop
)
graph = bb.Graph(bb.noop)
assert len(graph) == 1
result = bb.run(graph, strategy='threadpool')

View File

@ -14,14 +14,17 @@ def test_entrypoint():
assert 'init' in commands
assert 'run' in commands
def test_no_command(capsys):
with pytest.raises(SystemExit):
entrypoint([])
out, err = capsys.readouterr()
assert 'error: the following arguments are required: command' in err
def test_init():
pass # need ext dir
pass # need ext dir
def test_run(capsys):
entrypoint(['run', '--quiet', get_examples_path('types/strings.py')])