Adds a "bare" template, containing the very minimum you want to have in 90% of cases.
This commit is contained in:
@ -6,7 +6,7 @@ from bonobo.commands import BaseCommand
|
|||||||
|
|
||||||
|
|
||||||
class InitCommand(BaseCommand):
|
class InitCommand(BaseCommand):
|
||||||
TEMPLATES = {'default'}
|
TEMPLATES = {'bare', 'default'}
|
||||||
TEMPLATES_PATH = os.path.join(os.path.dirname(__file__), 'templates')
|
TEMPLATES_PATH = os.path.join(os.path.dirname(__file__), 'templates')
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
|
|||||||
15
bonobo/commands/templates/bare.py-tpl
Normal file
15
bonobo/commands/templates/bare.py-tpl
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import bonobo
|
||||||
|
|
||||||
|
|
||||||
|
def get_graph(**options):
|
||||||
|
graph = bonobo.Graph()
|
||||||
|
return graph
|
||||||
|
|
||||||
|
|
||||||
|
def get_services(**options):
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
with bonobo.parse_args() as options:
|
||||||
|
bonobo.run(get_graph(**options), services=get_services(**options))
|
||||||
@ -1,5 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from bonobo.commands.init import InitCommand
|
||||||
from bonobo.util.testing import all_runners
|
from bonobo.util.testing import all_runners
|
||||||
|
|
||||||
|
|
||||||
@ -12,4 +15,15 @@ def test_init_file(runner, tmpdir):
|
|||||||
|
|
||||||
out, err = runner('run', target_filename)
|
out, err = runner('run', target_filename)
|
||||||
assert out.replace('\n', ' ').strip() == 'Hello World'
|
assert out.replace('\n', ' ').strip() == 'Hello World'
|
||||||
assert not err
|
assert not err
|
||||||
|
|
||||||
|
|
||||||
|
@all_runners
|
||||||
|
@pytest.mark.parametrize('template', InitCommand.TEMPLATES)
|
||||||
|
def test_init_file_templates(runner, template, tmpdir):
|
||||||
|
target = tmpdir.join('foo.py')
|
||||||
|
target_filename = str(target)
|
||||||
|
runner('init', target_filename)
|
||||||
|
assert os.path.exists(target_filename)
|
||||||
|
out, err = runner('run', target_filename)
|
||||||
|
assert not err
|
||||||
|
|||||||
Reference in New Issue
Block a user