mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
Adds in test to verify content still works for lowercase http method names
This commit is contained in:
parent
0fd72f17ee
commit
81d232da3d
|
@ -452,7 +452,7 @@ class AutoSchema(ViewInspector):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_request_body(self, path, method):
|
def _get_request_body(self, path, method):
|
||||||
if method not in ('PUT', 'PATCH', 'POST'):
|
if method.upper() not in ('PUT', 'PATCH', 'POST'):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
serializer = self._get_serializer(path, method)
|
serializer = self._get_serializer(path, method)
|
||||||
|
|
|
@ -143,6 +143,29 @@ class TestOperationIntrospection(TestCase):
|
||||||
assert request_body['content']['application/json']['schema']['required'] == ['text']
|
assert request_body['content']['application/json']['schema']['required'] == ['text']
|
||||||
assert list(request_body['content']['application/json']['schema']['properties'].keys()) == ['text']
|
assert list(request_body['content']['application/json']['schema']['properties'].keys()) == ['text']
|
||||||
|
|
||||||
|
def test_request_body_lower_cased_method(self):
|
||||||
|
path = '/'
|
||||||
|
method = 'post'
|
||||||
|
|
||||||
|
class Serializer(serializers.Serializer):
|
||||||
|
text = serializers.CharField()
|
||||||
|
read_only = serializers.CharField(read_only=True)
|
||||||
|
|
||||||
|
class View(generics.GenericAPIView):
|
||||||
|
serializer_class = Serializer
|
||||||
|
|
||||||
|
view = create_view(
|
||||||
|
View,
|
||||||
|
method,
|
||||||
|
create_request(path)
|
||||||
|
)
|
||||||
|
inspector = AutoSchema()
|
||||||
|
inspector.view = view
|
||||||
|
|
||||||
|
request_body = inspector._get_request_body(path, method)
|
||||||
|
assert request_body['content']['application/json']['schema']['required'] == ['text']
|
||||||
|
assert list(request_body['content']['application/json']['schema']['properties'].keys()) == ['text']
|
||||||
|
|
||||||
def test_empty_required(self):
|
def test_empty_required(self):
|
||||||
path = '/'
|
path = '/'
|
||||||
method = 'POST'
|
method = 'POST'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user