aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhihui wu <wu.zhihui1@zte.com.cn>2017-06-06 06:18:34 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-06-06 06:18:34 +0000
commit1b507724e4cd0542b654a96e7b59a6f6463f2848 (patch)
tree2b5cebc0dd37ffa8437c1aaeea432a913324db50
parent0dffb7f523b9681533517b61436e9010d67def47 (diff)
parentb82052c8c00ba54f03c0f23a10a18c787946ffc1 (diff)
Merge "Pass on unhandled options."
-rw-r--r--qtip/runner/project.py25
-rw-r--r--tests/unit/cli/cmd_project_test.py18
2 files changed, 37 insertions, 6 deletions
diff --git a/qtip/runner/project.py b/qtip/runner/project.py
index 90d1e079..a0617228 100644
--- a/qtip/runner/project.py
+++ b/qtip/runner/project.py
@@ -15,13 +15,26 @@ def convert(vals):
return " ".join(vals)
-def setup(extra_val=None):
- os.system('ansible-playbook setup.yml {}'.format(convert(extra_val)))
+ARGS = 'ansible-playbook {}.yml {}'
+NO_ARGS = 'ansible-playbook {}.yml'
-def run(extra_val=None):
- os.system('ansible-playbook run.yml {}'.format(convert(extra_val)))
+def setup(extra_val):
+ if extra_val:
+ os.system(ARGS.format('setup', convert(extra_val)))
+ else:
+ os.system(NO_ARGS.format('setup'))
-def teardown(extra_val=None):
- os.system('ansible-playbook teardown.yml {}'.format(convert(extra_val)))
+def run(extra_val):
+ if extra_val:
+ os.system(ARGS.format('run', convert(extra_val)))
+ else:
+ os.system(NO_ARGS.format('run'))
+
+
+def teardown(extra_val):
+ if extra_val:
+ os.system(ARGS.format('teardown', convert(extra_val)))
+ else:
+ os.system(NO_ARGS.format('teardown'))
diff --git a/tests/unit/cli/cmd_project_test.py b/tests/unit/cli/cmd_project_test.py
index 8b9216fa..102e9ed7 100644
--- a/tests/unit/cli/cmd_project_test.py
+++ b/tests/unit/cli/cmd_project_test.py
@@ -21,17 +21,35 @@ def runner():
def test_run(mocker, runner):
mocker.patch('os.system')
+ runner.invoke(cli, ['run'])
+ os.system.assert_called_once_with('ansible-playbook run.yml')
+
+
+def test_run_verbose(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'])
+ os.system.assert_called_once_with('ansible-playbook setup.yml')
+
+
+def test_setup_verbose(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'])
+ os.system.assert_called_once_with('ansible-playbook teardown.yml')
+
+
+def test_teardown_verbose(mocker, runner):
+ mocker.patch('os.system')
runner.invoke(cli, ['teardown', '-vvv'])
os.system.assert_called_once_with('ansible-playbook teardown.yml -vvv')