Fix empty config error message
Broken bybc819cb
, which merged shortly before8c2b6c1
. Change-Id: I5b95993ee69a2082b3290aafe93643855ff7f56a
This commit is contained in:
parent
d8fde48e86
commit
41b91cd0e4
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user