コード例 #1
0
 def test_select_parser_failed(self):
     negotiation = DefaultNegotiation()
     parsers = [JSON, URLEncodedForm]
     headers = {'Content-Type': 'application/xml'}
     with app.test_request_context(headers=headers):
         with self.assertRaises(exceptions.UnsupportedMediaType):
             renderer, media_type = negotiation.select_parser(parsers)
コード例 #2
0
 def test_select_parser_failed(self):
     negotiation = DefaultNegotiation()
     parsers = [JSON, URLEncodedForm]
     headers = {'Content-Type': 'application/xml'}
     with app.test_request_context(headers=headers):
         with self.assertRaises(exceptions.UnsupportedMediaType):
             renderer, media_type = negotiation.select_parser(parsers)
コード例 #3
0
 def test_select_parser(self):
     negotiation = DefaultNegotiation()
     parsers = [JSON, URLEncodedForm]
     headers = {'Content-Type': 'application/x-www-form-urlencoded'}
     with app.test_request_context(headers=headers):
         renderer, media_type = negotiation.select_parser(parsers)
         self.assertEqual(renderer, URLEncodedForm)
         self.assertEqual(str(media_type), 'application/x-www-form-urlencoded')
コード例 #4
0
 def test_select_parser(self):
     negotiation = DefaultNegotiation()
     parsers = [JSON, URLEncodedForm]
     headers = {'Content-Type': 'application/x-www-form-urlencoded'}
     with app.test_request_context(headers=headers):
         renderer, media_type = negotiation.select_parser(parsers)
         self.assertEqual(renderer, URLEncodedForm)
         self.assertEqual(str(media_type), 'application/x-www-form-urlencoded')