Issue #134: add a bonobo download url command
This enables users on different platforms to download the examples in the tutorial using the same command.
This commit is contained in:
@ -13,6 +13,7 @@ from cookiecutter.exceptions import OutputDirExistsException
|
||||
from bonobo import __main__, __version__, get_examples_path
|
||||
from bonobo.commands import entrypoint
|
||||
from bonobo.commands.run import DEFAULT_GRAPH_FILENAMES
|
||||
from bonobo.commands.download import EXAMPLES_BASE_URL
|
||||
|
||||
|
||||
def runner(f):
|
||||
@ -152,6 +153,29 @@ def test_version(runner):
|
||||
assert __version__ in out
|
||||
|
||||
|
||||
@all_runners
|
||||
def test_download_works_for_examples(runner):
|
||||
fout = io.BytesIO()
|
||||
fout.close = lambda: None
|
||||
|
||||
expected_bytes = b'hello world'
|
||||
with patch('bonobo.commands.download._open_url') as mock_open_url, \
|
||||
patch('bonobo.commands.download.open') as mock_open:
|
||||
mock_open_url.return_value = io.BytesIO(expected_bytes)
|
||||
mock_open.return_value = fout
|
||||
runner('download', 'examples/datasets/coffeeshops.txt')
|
||||
expected_url = EXAMPLES_BASE_URL + 'datasets/coffeeshops.txt'
|
||||
mock_open_url.assert_called_once_with(expected_url)
|
||||
|
||||
assert fout.getvalue() == expected_bytes
|
||||
|
||||
|
||||
@all_runners
|
||||
def test_download_fails_non_example(runner):
|
||||
with pytest.raises(ValueError):
|
||||
runner('download', '/something/entirely/different.txt')
|
||||
|
||||
|
||||
@all_runners
|
||||
class TestDefaultEnvFile(object):
|
||||
def test_run_file_with_default_env_file(self, runner):
|
||||
|
||||
Reference in New Issue
Block a user