From 81cb49df72a3ae3571b52e38fcb0ad2eae809c85 Mon Sep 17 00:00:00 2001 From: tivaliy Date: Wed, 1 Jun 2016 14:30:45 +0300 Subject: [PATCH] Align required args for 'fuel2 graph upload' Dissallow 'fuel2 graph uplod' command execution without required args (-e ENV | -r RELEASE | -p PLUGIN), e.g.: usage: fuel2 graph upload [-h] (-e ENV | -r RELEASE | -p PLUGIN) [-t TYPE] -f FILE Change-Id: I4fb1215874a849ea032afadb9604fca0dc0784a1 Closes-Bug: 1587837 --- fuelclient/commands/graph.py | 2 +- fuelclient/tests/unit/v2/cli/test_deployment_graph.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fuelclient/commands/graph.py b/fuelclient/commands/graph.py index 32eacace..5f6ec40b 100644 --- a/fuelclient/commands/graph.py +++ b/fuelclient/commands/graph.py @@ -59,7 +59,7 @@ class GraphUpload(base.BaseCommand, FileMethodsMixin): def get_parser(self, prog_name): parser = super(GraphUpload, self).get_parser(prog_name) - graph_class = parser.add_mutually_exclusive_group() + graph_class = parser.add_mutually_exclusive_group(required=True) graph_class.add_argument('-e', '--env', diff --git a/fuelclient/tests/unit/v2/cli/test_deployment_graph.py b/fuelclient/tests/unit/v2/cli/test_deployment_graph.py index 1c5e272c..4d7b53e9 100644 --- a/fuelclient/tests/unit/v2/cli/test_deployment_graph.py +++ b/fuelclient/tests/unit/v2/cli/test_deployment_graph.py @@ -77,6 +77,13 @@ class TestGraphActions(test_engine.BaseCLITest): ) ) + @mock.patch('sys.stderr') + def test_upload_fail(self, mocked_stderr): + cmd = 'graph upload --file new_graph.yaml' + self.assertRaises(SystemExit, self.exec_command, cmd) + self.assertIn('-e/--env -r/--release -p/--plugin', + mocked_stderr.write.call_args_list[-1][0][0]) + def test_execute(self): self._test_cmd( 'execute',