Fix "rally info" failure in case of empty docstrings
In case the input query for "rally info find ... " requested for a benchmark scenario with an empty docstring, the CLI failed with an exception. Instead, we should print that there is no info about that scenario. Change-Id: If3a806f794f9b11ce1eb44eaabce732183c4c99b Closes-Bug: 1371461
This commit is contained in:
parent
b92bf5b2f6
commit
ac92ccc4b0
@ -91,6 +91,8 @@ class InfoCommands(object):
|
||||
{"scenario_group": scenario_group_name,
|
||||
"scenario_name": scenario.__name__})
|
||||
doc = utils.parse_docstring(scenario.__doc__)
|
||||
if not doc["short_description"]:
|
||||
return None
|
||||
info += doc["short_description"] + "\n\n"
|
||||
if doc["long_description"]:
|
||||
info += doc["long_description"] + "\n\n"
|
||||
|
@ -20,6 +20,7 @@ from rally.cmd.commands import info
|
||||
from rally.deploy.engines import existing as existing_cloud
|
||||
from rally.deploy.serverprovider.providers import existing as existing_servers
|
||||
from rally import exceptions
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
|
||||
@ -57,6 +58,14 @@ class InfoCommandsTestCase(test.TestCase):
|
||||
mock_get_scenario_by_name.assert_called_once_with(query)
|
||||
self.assertEqual(1, status)
|
||||
|
||||
@mock.patch(SCENARIO + ".get_scenario_by_name",
|
||||
return_value=fakes.FakeScenario.do_it)
|
||||
def test_find_scenario_with_empty_docs(self, mock_get_scenario_by_name):
|
||||
query = "FakeScenario.do_it"
|
||||
status = self.info.find(query)
|
||||
mock_get_scenario_by_name.assert_called_once_with(query)
|
||||
self.assertEqual(1, status)
|
||||
|
||||
@mock.patch(ENGINE + ".get_by_name",
|
||||
return_value=existing_cloud.ExistingCloud)
|
||||
def test_find_existing_cloud(self, mock_get_by_name):
|
||||
|
Loading…
x
Reference in New Issue
Block a user