Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Commit ed9fbf7

Browse files
committed
Added id and resource_uri to state URL
1 parent 24ec55f commit ed9fbf7

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

setup.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
README = open(os.path.join(os.path.dirname(__file__), 'README.md')).read()
1111

12-
# allow setup.py to be run from any path
13-
#os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
14-
1512
setup(
1613
name='tastypie-async',
1714
version='0.1',
@@ -47,5 +44,4 @@
4744
],
4845
dependency_links=[
4946
]
50-
)
51-
47+
)

tpasync/resources.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def async_state(self, request, task_id, **kwargs):
5151
"""
5252
task = AsyncResult(task_id)
5353
if request.method == 'GET':
54-
data = {'state': task.state}
54+
data = {
55+
'state': task.state, 'id': task.id,
56+
'resource_uri': request.get_full_path()}
5557
if task.ready():
5658
data['result_uri'] = self._build_reverse_url(
5759
'api_async_result',

tpasync/tests.py

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ def test_successful_task(self):
6464
self.assertHttpOK(response)
6565
data = self.deserialize(response)
6666
self.assertEqual(data['state'], 'PENDING')
67+
self.assertIn('resource_uri', data)
68+
self.assertIn('id', data)
69+
task_id = data['id']
70+
self.assertEqual(
71+
data['resource_uri'],
72+
'/api/v1/test/state/{}/'.format(task_id))
6773
self.assertNotIn('result_uri', data)
6874
# Wait 4 seconds and retry. This time result_uri should be ready
6975
time.sleep(4)

0 commit comments

Comments
 (0)