mirror of
https://github.com/sprockets/sprockets.mixins.mediatype.git
synced 2024-12-29 11:17:10 +00:00
Add test to ensure context suffix is handled with ietfparse<1.5.1 behavior
This commit is contained in:
parent
30a7360ada
commit
723ed25edb
1 changed files with 22 additions and 0 deletions
22
tests.py
22
tests.py
|
@ -101,6 +101,17 @@ class SendResponseTests(testing.AsyncHTTPTestCase):
|
|||
self.assertEqual(response.code, 200)
|
||||
self.assertEqual(response.headers['Vary'], 'Accept')
|
||||
|
||||
def test_that_accept_header_with_suffix_is_obeyed(self):
|
||||
content.add_transcoder(
|
||||
self._app,
|
||||
transcoders.MsgPackTranscoder(content_type='expected/content'),
|
||||
'application/vendor+msgpack')
|
||||
response = self.fetch('/', method='POST', body='{}',
|
||||
headers={'Accept': 'application/vendor+msgpack',
|
||||
'Content-Type': 'application/json'})
|
||||
self.assertEqual(response.code, 200)
|
||||
self.assertEqual(response.headers['Content-Type'], 'expected/content')
|
||||
|
||||
|
||||
class GetRequestBodyTests(testing.AsyncHTTPTestCase):
|
||||
|
||||
|
@ -135,6 +146,17 @@ class GetRequestBodyTests(testing.AsyncHTTPTestCase):
|
|||
'</param></params></methodCall>').encode('utf-8'))
|
||||
self.assertEqual(response.code, 400)
|
||||
|
||||
def test_that_content_type_suffix_is_handled(self):
|
||||
content.add_transcoder(
|
||||
self._app, transcoders.JSONTranscoder(),
|
||||
'application/vendor+json')
|
||||
body = {'hello': 'world'}
|
||||
response = self.fetch(
|
||||
'/', method='POST', body=json.dumps(body),
|
||||
headers={'Content-Type': 'application/vendor+json'})
|
||||
self.assertEqual(response.code, 200)
|
||||
self.assertEqual(json.loads(response.body.decode()), body)
|
||||
|
||||
|
||||
class JSONTranscoderTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in a new issue