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
This commit is contained in:
tivaliy
2016-06-01 14:30:45 +03:00
parent 40f7a87eca
commit 81cb49df72
2 changed files with 8 additions and 1 deletions

View File

@@ -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',

View File

@@ -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',