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)
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)
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')