Beispiel #1
0
 def test_match_mask_one_asterisk(self):
     arg = 'text/*; q=0.7'
     accept = urlmap.Accept(arg)
     self.assertEqual(('text/html', {
         'q': '0.7'
     }), accept.best_match(['text/html']))
Beispiel #2
0
 def test_best_match_ValueError(self):
     arg = 'text/html; q=some_invalud_value'
     accept = urlmap.Accept(arg)
     self.assertEqual((None, {}), accept.best_match(['text/html']))
 def test_content_type_params_wrong_content_type(self):
     arg = 'application/xml; q=0.1, text/html; q=0.1'
     accept = urlmap.Accept(arg)
     self.assertEqual({}, accept.content_type_params('application/json'))
 def test_content_type_params(self):
     arg = "application/xml; q=0.1, application/json; q=0.2," \
           " text/html; q=0.3"
     accept = urlmap.Accept(arg)
     self.assertEqual({'q': '0.2'},
                      accept.content_type_params('application/json'))
 def test_match_mask_no_asterisk(self):
     arg = 'application/json; q=0.7'
     accept = urlmap.Accept(arg)
     self.assertEqual((None, {}), accept.best_match(['text/html']))
Beispiel #6
0
 def test_best_match(self):
     arg = '*/*; q=0.7, application/json; q=0.7, text/html; q=-0.8'
     accept = urlmap.Accept(arg)
     self.assertEqual(('application/json', {
         'q': '0.7'
     }), accept.best_match(['application/json', 'text/html']))