diff --git a/atomic_operations/consts.py b/atomic_operations/consts.py index c36a624..aa76ccd 100644 --- a/atomic_operations/consts.py +++ b/atomic_operations/consts.py @@ -1,4 +1,4 @@ ATOMIC_OPERATIONS = "atomic:operations" ATOMIC_RESULTS = "atomic:results" -ATOMIC_MEDIA_TYPE = 'vnd.api+json;ext="https://jsonapi.org/ext/atomic' +ATOMIC_MEDIA_TYPE = 'vnd.api+json;ext="https://jsonapi.org/ext/atomic"' ATOMIC_CONTENT_TYPE = f'application/{ATOMIC_MEDIA_TYPE}' diff --git a/tests/test_views.py b/tests/test_views.py index 83ce388..b78efd4 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -21,6 +21,29 @@ def setUp(self): self.maxDiff = None + def test_content_type_extension(self): + """Test that the correct content type is accepted + + The media type and parameters are defined at https://jsonapi.org/ext/atomic. This tests + hardcodes the value to separate the test from the library's constants. + + """ + operations = [] + + data = { + ATOMIC_OPERATIONS: operations + } + + response = self.client.post( + path="/", + data=data, + content_type='application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"', + + **{"HTTP_ACCEPT": 'application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"'} + ) + + self.assertNotEqual(406, response.status_code) # 406 Not Acceptable + def test_view_processing_with_valid_request(self): operations = [ {