Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
/ pulp Public archive

Commit

Permalink
Add support for parsing TaskStatus objects to the TaskResult object
Browse files Browse the repository at this point in the history
fixes #1011
  • Loading branch information
barnabycourt committed Jun 4, 2015
1 parent efc4579 commit 499dc63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions server/pulp/server/async/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def __init__(self, result=None, error=None, spawned_tasks=None):
self.spawned_tasks.append({'task_id': spawned_task.get('task_id')})
elif isinstance(spawned_task, AsyncResult):
self.spawned_tasks.append({'task_id': spawned_task.id})
elif isinstance(spawned_task, TaskStatus):
self.spawned_tasks.append({'task_id': spawned_task.task_id})
else: # This should be a string
self.spawned_tasks.append({'task_id': spawned_task})

Expand Down
7 changes: 5 additions & 2 deletions server/test/unit/server/async/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,16 @@ def test_serialize(self):

async_result = AsyncResult('foo')
test_exception = PulpException('foo')
result = tasks.TaskResult('foo', test_exception, [{'task_id': 'baz'}, async_result, "qux"])
task_status = TaskStatus(task_id='quux')
result = tasks.TaskResult('foo', test_exception, [{'task_id': 'baz'},
async_result, "qux", task_status])
serialized = result.serialize()
self.assertEquals(serialized.get('result'), 'foo')
compare_dict(test_exception.to_dict(), serialized.get('error'))
self.assertEquals(serialized.get('spawned_tasks'), [{'task_id': 'baz'},
{'task_id': 'foo'},
{'task_id': 'qux'}])
{'task_id': 'qux'},
{'task_id': 'quux'}])


class TestReservedTaskMixinApplyAsyncWithReservation(ResourceReservationTests):
Expand Down

0 comments on commit 499dc63

Please sign in to comment.