mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Deprecate post to v2 jobs (#18)
This commit is contained in:
@@ -3719,6 +3719,13 @@ class JobList(ListCreateAPIView):
|
|||||||
metadata_class = JobTypeMetadata
|
metadata_class = JobTypeMetadata
|
||||||
serializer_class = JobListSerializer
|
serializer_class = JobListSerializer
|
||||||
|
|
||||||
|
@property
|
||||||
|
def allowed_methods(self):
|
||||||
|
methods = super(JobList, self).allowed_methods
|
||||||
|
if get_request_version(self.request) > 1:
|
||||||
|
methods.remove('POST')
|
||||||
|
return methods
|
||||||
|
|
||||||
|
|
||||||
class JobDetail(RetrieveUpdateDestroyAPIView):
|
class JobDetail(RetrieveUpdateDestroyAPIView):
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from rest_framework import exceptions
|
|||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.views import ApiErrorView
|
from awx.main.views import ApiErrorView
|
||||||
|
from awx.api.views import JobList
|
||||||
|
|
||||||
|
|
||||||
HTTP_METHOD_NAMES = [
|
HTTP_METHOD_NAMES = [
|
||||||
@@ -35,3 +36,11 @@ def test_exception_view_raises_exception(api_view_obj_fixture, method_name):
|
|||||||
request_mock = mock.MagicMock()
|
request_mock = mock.MagicMock()
|
||||||
with pytest.raises(exceptions.APIException):
|
with pytest.raises(exceptions.APIException):
|
||||||
getattr(api_view_obj_fixture, method_name)(request_mock)
|
getattr(api_view_obj_fixture, method_name)(request_mock)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('version, supports_post', [(1, True), (2, False)])
|
||||||
|
def test_disable_post_on_v2_jobs_list(version, supports_post):
|
||||||
|
job_list = JobList()
|
||||||
|
job_list.request = mock.MagicMock()
|
||||||
|
with mock.patch('awx.api.views.get_request_version', return_value=version):
|
||||||
|
assert ('POST' in job_list.allowed_methods) == supports_post
|
||||||
|
|||||||
Reference in New Issue
Block a user