Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 45 additions & 17 deletions src/azure-cli-core/azure/cli/core/tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,23 @@ def test_load_from_help_py(self, mocked_load, mocked_pkg_util):
self.assertEqual(obj_param_dict["--arg1 -a"].value_sources[0]['link']['command'], "az foo bar")
self.assertEqual(obj_param_dict["--arg1 -a"].value_sources[1]['link']['command'], "az bar baz")

self.assertEqual(command_help_obj.examples[0].short_summary, "Alpha Example")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 a --arg2 b --arg3 c")
self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest")
self.assertEqual(command_help_obj.examples[0].unsupported_profiles, None)
if self.test_cli.cloud.profile in ['2018-03-01-hybrid', 'latest']:
self.assertEqual(command_help_obj.examples[0].short_summary, "Alpha Example")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 a --arg2 b --arg3 c")
self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest")
self.assertEqual(command_help_obj.examples[0].unsupported_profiles, None)

self.assertEqual(command_help_obj.examples[1].supported_profiles, None)
self.assertEqual(command_help_obj.examples[1].unsupported_profiles, "2017-03-09-profile")
self.assertEqual(command_help_obj.examples[1].supported_profiles, None)
self.assertEqual(command_help_obj.examples[1].unsupported_profiles, "2017-03-09-profile")

if self.test_cli.cloud.profile == '2019-03-01-hybrid':
self.assertEqual(len(command_help_obj.examples), 1)
self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example unsupported on latest")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 a --arg2 b")
self.assertEqual(command_help_obj.examples[0].unsupported_profiles, '2017-03-09-profile')

if self.test_cli.cloud.profile == '2017-03-09-profile':
self.assertEqual(len(command_help_obj.examples), 0)

@mock.patch('pkgutil.iter_modules', side_effect=lambda x: [(None, MOCKED_COMMAND_LOADER_MOD, None)])
@mock.patch('azure.cli.core.commands._load_command_loader', side_effect=mock_load_command_loader)
Expand Down Expand Up @@ -425,14 +435,24 @@ def test_load_from_help_yaml(self, mocked_load, mocked_pkg_util):
self.assertEqual(obj_param_dict["--arg2 -b"].value_sources[2]['link'], {"command": "az test show",
"title": "Show test details"})

self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example")
self.assertEqual(command_help_obj.examples[0].long_summary, "More detail on the simple example.")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 apple --arg2 ball --arg3 cat")
self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest")
self.assertEqual(command_help_obj.examples[0].unsupported_profiles, None)
if self.test_cli.cloud.profile in ['2018-03-01-hybrid', 'latest']:
self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example")
self.assertEqual(command_help_obj.examples[0].long_summary, "More detail on the simple example.")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 apple --arg2 ball --arg3 cat")
self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest")
self.assertEqual(command_help_obj.examples[0].unsupported_profiles, None)

self.assertEqual(command_help_obj.examples[1].supported_profiles, None)
self.assertEqual(command_help_obj.examples[1].unsupported_profiles, "2017-03-09-profile")

self.assertEqual(command_help_obj.examples[1].supported_profiles, None)
self.assertEqual(command_help_obj.examples[1].unsupported_profiles, "2017-03-09-profile")
if self.test_cli.cloud.profile == '2019-03-01-hybrid':
self.assertEqual(len(command_help_obj.examples), 1)
self.assertEqual(command_help_obj.examples[0].short_summary, "Another example unsupported on latest")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 apple --arg2 ball")
self.assertEqual(command_help_obj.examples[0].unsupported_profiles, '2017-03-09-profile')

if self.test_cli.cloud.profile == '2017-03-09-profile':
self.assertEqual(len(command_help_obj.examples), 0)

@mock.patch('inspect.getmembers', side_effect=mock_inspect_getmembers)
@mock.patch('pkgutil.iter_modules', side_effect=lambda x: [(None, MOCKED_COMMAND_LOADER_MOD, None)])
Expand Down Expand Up @@ -486,10 +506,18 @@ def test_load_from_help_json(self, mocked_load, mocked_pkg_util, mocked_getmembe
self.assertEqual(obj_param_dict["--arg3"].value_sources[2]['link'],
{"command": "az test show", "title": "Show test details. Json file"})

self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example from json")
self.assertEqual(command_help_obj.examples[0].long_summary, "More detail on the simple example.")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 alpha --arg2 beta --arg3 chi")
self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest")
if self.test_cli.cloud.profile in ['2018-03-01-hybrid', 'latest']:
self.assertEqual(command_help_obj.examples[0].short_summary, "A simple example from json")
self.assertEqual(command_help_obj.examples[0].long_summary, "More detail on the simple example.")
self.assertEqual(command_help_obj.examples[0].command, "az test alpha --arg1 alpha --arg2 beta --arg3 chi")
self.assertEqual(command_help_obj.examples[0].supported_profiles, "2018-03-01-hybrid, latest")

if self.test_cli.cloud.profile == '2019-03-01-hybrid':
# only supported example here
self.assertEqual(len(command_help_obj.examples), 0)

if self.test_cli.cloud.profile == '2017-03-09-profile':
self.assertEqual(len(command_help_obj.examples), 0)

# validate other parameters, which have help from help.py and help.yamls
self.assertEqual(obj_param_dict["--arg1 -a"].short_summary, "A short summary.")
Expand Down