Add test to ensure context suffix is handled with ietfparse<1.5.1 behavior

This commit is contained in:
Andrew Rabert 2018-11-30 11:47:32 -05:00
parent 30a7360ada
commit 723ed25edb

View file

@ -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):