from qtip.runner import project
+CONTEXT_SETTINGS = dict(ignore_unknown_options=True, allow_extra_args=True, )
+
+
class AliasedGroup(click.Group):
def get_command(self, ctx, cmd_name):
extra_vars=utils.join_vars(**extra_vars)))
-@cli.command(help='Setup testing environment')
-def setup():
- project.setup()
+@cli.command(context_settings=CONTEXT_SETTINGS, help='Setup testing environment')
+@click.pass_context
+def setup(ctx):
+ project.setup(ctx.args)
-@cli.command(help='Execute testing plan')
-def run():
- project.run()
+@cli.command(context_settings=CONTEXT_SETTINGS, help='Execute testing plan')
+@click.pass_context
+def run(ctx):
+ project.run(ctx.args)
-@cli.command(help='Teardown testing environment')
-def teardown():
- project.teardown()
+@cli.command(context_settings=CONTEXT_SETTINGS, help='Teardown testing environment')
+@click.pass_context
+def teardown(ctx):
+ project.teardown(ctx.args)
import os
-def setup():
- os.system('ansible-playbook setup.yml')
+def convert(vals):
+ if vals:
+ return " ".join(vals)
-def run():
- os.system('ansible-playbook run.yml')
+def setup(extra_val=None):
+ os.system('ansible-playbook setup.yml {}'.format(convert(extra_val)))
-def teardown():
- os.system('ansible-playbook teardown.yml')
+def run(extra_val=None):
+ os.system('ansible-playbook run.yml {}'.format(convert(extra_val)))
+
+
+def teardown(extra_val=None):
+ os.system('ansible-playbook teardown.yml {}'.format(convert(extra_val)))
--- /dev/null
+###############################################################
+# Copyright (c) 2017 taseer94@gmail.com and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from click.testing import CliRunner
+import os
+import pytest
+
+from qtip.cli.entry import cli
+
+
+@pytest.fixture(scope='module')
+def runner():
+ return CliRunner()
+
+
+def test_run(mocker, runner):
+ mocker.patch('os.system')
+ runner.invoke(cli, ['run', '-vvv'])
+ os.system.assert_called_once_with('ansible-playbook run.yml -vvv')
+
+
+def test_setup(mocker, runner):
+ mocker.patch('os.system')
+ runner.invoke(cli, ['setup', '-vvv'])
+ os.system.assert_called_once_with('ansible-playbook setup.yml -vvv')
+
+
+def test_teardown(mocker, runner):
+ mocker.patch('os.system')
+ runner.invoke(cli, ['teardown', '-vvv'])
+ os.system.assert_called_once_with('ansible-playbook teardown.yml -vvv')