Merge "[API] Extend api.Task.get_detailed"
This commit is contained in:
commit
3b7115fd15
16
rally/api.py
16
rally/api.py
@ -157,8 +157,20 @@ class Task(object):
|
|||||||
return objects.Task.get(task_id)
|
return objects.Task.get(task_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_detailed(task_id):
|
def get_detailed(task_id, extended_results=False):
|
||||||
return objects.Task.get_detailed(task_id)
|
"""Get detailed task data.
|
||||||
|
|
||||||
|
:param task_id: str task UUID
|
||||||
|
:param extended_results: whether to return task data as dict
|
||||||
|
with extended results
|
||||||
|
:returns: rally.common.db.sqlalchemy.models.Task
|
||||||
|
:returns: dict
|
||||||
|
"""
|
||||||
|
task = objects.Task.get_detailed(task_id)
|
||||||
|
if task and extended_results:
|
||||||
|
task = dict(task)
|
||||||
|
task["results"] = objects.Task.extend_results(task["results"])
|
||||||
|
return task
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def render_template(cls, task_template, template_dir="./", **kwargs):
|
def render_template(cls, task_template, template_dir="./", **kwargs):
|
||||||
|
@ -256,6 +256,24 @@ class TaskAPITestCase(test.TestCase):
|
|||||||
mock_task_delete.assert_called_once_with(
|
mock_task_delete.assert_called_once_with(
|
||||||
self.task_uuid, status=None)
|
self.task_uuid, status=None)
|
||||||
|
|
||||||
|
@mock.patch("rally.api.objects.Task")
|
||||||
|
def test_get_detailed(self, mock_task):
|
||||||
|
mock_task.get_detailed.return_value = "detailed_task_data"
|
||||||
|
self.assertEqual("detailed_task_data",
|
||||||
|
api.Task.get_detailed("task_uuid"))
|
||||||
|
mock_task.get_detailed.assert_called_once_with("task_uuid")
|
||||||
|
|
||||||
|
@mock.patch("rally.api.objects.Task")
|
||||||
|
def test_get_detailed_with_extended_results(self, mock_task):
|
||||||
|
mock_task.get_detailed.return_value = (("uuid", "foo_uuid"),
|
||||||
|
("results", "raw_results"))
|
||||||
|
mock_task.extend_results.return_value = "extended_results"
|
||||||
|
self.assertEqual({"uuid": "foo_uuid", "results": "extended_results"},
|
||||||
|
api.Task.get_detailed("foo_uuid",
|
||||||
|
extended_results=True))
|
||||||
|
mock_task.get_detailed.assert_called_once_with("foo_uuid")
|
||||||
|
mock_task.extend_results.assert_called_once_with("raw_results")
|
||||||
|
|
||||||
|
|
||||||
class BaseDeploymentTestCase(test.TestCase):
|
class BaseDeploymentTestCase(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user