mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Return URL to new job created from job template callback.
This commit is contained in:
parent
7eed13cca4
commit
130d1f071f
@ -1231,7 +1231,8 @@ class JobTemplateCallback(GenericAPIView):
|
||||
data = dict(msg='Error starting job!')
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
else:
|
||||
return Response(status=status.HTTP_202_ACCEPTED)
|
||||
headers = {'Location': job.get_absolute_url()}
|
||||
return Response(status=status.HTTP_202_ACCEPTED, headers=headers)
|
||||
|
||||
class JobTemplateJobsList(SubListCreateAPIView):
|
||||
|
||||
|
@ -1181,9 +1181,12 @@ class JobTemplateCallbackTest(BaseJobTestMixin, django.test.LiveServerTestCase):
|
||||
host_ip = self.get_test_ips_for_host(host.name)[0]
|
||||
jobs_qs = job_template.jobs.filter(launch_type='callback').order_by('-pk')
|
||||
self.assertEqual(jobs_qs.count(), 0)
|
||||
self.post(url, data, expect=202, remote_addr=host_ip)
|
||||
result = self.post(url, data, expect=202, remote_addr=host_ip)
|
||||
self.assertTrue('Location' in result.response, result.response)
|
||||
self.assertEqual(jobs_qs.count(), 1)
|
||||
job = jobs_qs[0]
|
||||
self.assertEqual(urlparse.urlsplit(result.response['Location']).path,
|
||||
job.get_absolute_url())
|
||||
self.assertEqual(job.launch_type, 'callback')
|
||||
self.assertEqual(job.limit, host.name)
|
||||
self.assertEqual(job.hosts.count(), 1)
|
||||
|
Loading…
Reference in New Issue
Block a user