def test_accept_media_range_must_accept_parameters(self): match = ACCEPT_MEDIA_RANGE.match('text/x-dvi; q=0.8') self.assertNotEqual( match, None, "ACCEPT_MEDIA_RANGE does not accept parameters" )
def test_accept_media_range_must_not_match_some_text(self): match = ACCEPT_MEDIA_RANGE.match('Some text') self.assertEqual( match, None, "ACCEPT_MEDIA_RANGE accepts some text" )
def test_accept_media_range_must_match_all_types(self): match = ACCEPT_MEDIA_RANGE.match('*/*') self.assertNotEqual( match, None, "ACCEPT_MEDIA_RANGE does not accept all types" )
def test_accept_media_range_must_fetch_right_values(self): match = ACCEPT_MEDIA_RANGE.match('text/plain; q=0.5') media_type = match.group('type') or '*' media_subtype = match.group('subtype') or '*' media_q = float(match.group('q') or 1.0) match_dict = { 'type': media_type, 'subtype': media_subtype, 'q': media_q } self.assertDictEqual(match_dict, { 'type': 'text', 'subtype': 'plain', 'q': 0.5, }, "ACCEPT_MEDIA_RANGE does not fetch right values" )