Merge "Friendlier error message with empty task file"

This commit is contained in:
Jenkins 2016-04-15 00:11:15 +00:00 committed by Gerrit Code Review
commit 47fbf92d47
2 changed files with 14 additions and 0 deletions

View File

@ -185,6 +185,11 @@ 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:

View File

@ -44,6 +44,15 @@ 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):
config = None
task = mock.Mock()
exception = self.assertRaises(exceptions.InvalidTaskException,
engine.TaskEngine, config, task)
self.assertIn("Input task is empty", str(exception))
self.assertTrue(task.set_failed.called)
@mock.patch("rally.task.engine.TaskConfig")
@mock.patch("jsonschema.validate")
def test_validate(self, mock_validate, mock_task_config):