Fix empty config error message

Broken by bc819cb, which merged shortly before 8c2b6c1.

Change-Id: I5b95993ee69a2082b3290aafe93643855ff7f56a
This commit is contained in:
Chris St. Pierre 2016-04-18 12:01:51 -05:00
parent d8fde48e86
commit 41b91cd0e4
3 changed files with 15 additions and 7 deletions

View File

@ -185,11 +185,6 @@ class TaskEngine(object):
:param abort_on_sla_failure: True if the execution should be stopped
when some SLA check fails
"""
if config is None:
msg = _("Input task is empty")
task.set_failed(log=msg)
raise exceptions.InvalidTaskException(msg)
try:
self.config = TaskConfig(config)
except Exception as e:
@ -456,6 +451,13 @@ class TaskConfig(object):
:param config: Dict with configuration of specified task
"""
if config is None:
# NOTE(stpierre): This gets reraised as
# InvalidTaskException. if we raise it here as
# InvalidTaskException, then "Task config is invalid: "
# gets prepended to the message twice.
raise Exception(_("Input task is empty"))
self.version = self._get_version(config)
self._validate_version()
self._validate_json(config)

View File

@ -164,6 +164,13 @@ class TaskTestCase(unittest.TestCase):
detailed_iterations_data = rally("task detailed --iterations-data")
self.assertNotIn("n/a", detailed_iterations_data)
def test_start_with_empty_config(self):
rally = utils.Rally()
config = utils.TaskConfig(None)
with self.assertRaises(utils.RallyCliError) as err:
rally("task start --task %s" % config.filename)
self.assertIn("Input task is empty", err.exception.output)
def test_results(self):
rally = utils.Rally()
cfg = self._get_sample_task_config()

View File

@ -44,8 +44,7 @@ class TaskEngineTestCase(test.TestCase):
self.assertEqual(eng.config, fake_task_instance)
self.assertEqual(eng.task, task)
@mock.patch("rally.task.engine.TaskConfig")
def test_init_empty_config(self, mock_task_config):
def test_init_empty_config(self):
config = None
task = mock.Mock()
exception = self.assertRaises(exceptions.InvalidTaskException,