Skip to content

Commit

Permalink
Merge pull request #5 from Roanmh/fix-media-type
Browse files Browse the repository at this point in the history
fix: incorrect media type
  • Loading branch information
jokiefer authored Oct 25, 2024
2 parents a1646d8 + eb820f5 commit fce15e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion atomic_operations/consts.py
Original file line number Diff line number Diff line change
@@ -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}'
23 changes: 23 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down

0 comments on commit fce15e2

Please sign in to comment.