Пример #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')
 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')