Skip to content

Commit fce15e2

Browse files
authored
Merge pull request #5 from Roanmh/fix-media-type
fix: incorrect media type
2 parents a1646d8 + eb820f5 commit fce15e2

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

atomic_operations/consts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ATOMIC_OPERATIONS = "atomic:operations"
22
ATOMIC_RESULTS = "atomic:results"
3-
ATOMIC_MEDIA_TYPE = 'vnd.api+json;ext="https://jsonapi.org/ext/atomic'
3+
ATOMIC_MEDIA_TYPE = 'vnd.api+json;ext="https://jsonapi.org/ext/atomic"'
44
ATOMIC_CONTENT_TYPE = f'application/{ATOMIC_MEDIA_TYPE}'

tests/test_views.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ def setUp(self):
2121

2222
self.maxDiff = None
2323

24+
def test_content_type_extension(self):
25+
"""Test that the correct content type is accepted
26+
27+
The media type and parameters are defined at https://jsonapi.org/ext/atomic. This tests
28+
hardcodes the value to separate the test from the library's constants.
29+
30+
"""
31+
operations = []
32+
33+
data = {
34+
ATOMIC_OPERATIONS: operations
35+
}
36+
37+
response = self.client.post(
38+
path="/",
39+
data=data,
40+
content_type='application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"',
41+
42+
**{"HTTP_ACCEPT": 'application/vnd.api+json; ext="https://jsonapi.org/ext/atomic"'}
43+
)
44+
45+
self.assertNotEqual(406, response.status_code) # 406 Not Acceptable
46+
2447
def test_view_processing_with_valid_request(self):
2548
operations = [
2649
{

0 commit comments

Comments
 (0)