From eb393331cdf4136af2c1955f532350528ba43103 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Sun, 5 Nov 2017 14:59:25 +0100 Subject: [PATCH] Adds a "bare" template, containing the very minimum you want to have in 90% of cases. --- bonobo/commands/init.py | 2 +- bonobo/commands/templates/bare.py-tpl | 15 +++++++++++++++ tests/commands/test_init.py | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 bonobo/commands/templates/bare.py-tpl diff --git a/bonobo/commands/init.py b/bonobo/commands/init.py index 8c50b16..6d4b217 100644 --- a/bonobo/commands/init.py +++ b/bonobo/commands/init.py @@ -6,7 +6,7 @@ from bonobo.commands import BaseCommand class InitCommand(BaseCommand): - TEMPLATES = {'default'} + TEMPLATES = {'bare', 'default'} TEMPLATES_PATH = os.path.join(os.path.dirname(__file__), 'templates') def add_arguments(self, parser): diff --git a/bonobo/commands/templates/bare.py-tpl b/bonobo/commands/templates/bare.py-tpl new file mode 100644 index 0000000..1ca3019 --- /dev/null +++ b/bonobo/commands/templates/bare.py-tpl @@ -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)) diff --git a/tests/commands/test_init.py b/tests/commands/test_init.py index a551a9a..626f5e8 100644 --- a/tests/commands/test_init.py +++ b/tests/commands/test_init.py @@ -1,5 +1,8 @@ import os +import pytest + +from bonobo.commands.init import InitCommand from bonobo.util.testing import all_runners @@ -12,4 +15,15 @@ def test_init_file(runner, tmpdir): out, err = runner('run', target_filename) assert out.replace('\n', ' ').strip() == 'Hello World' - assert not err \ No newline at end of file + 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