def test_best_matches(): accept = Accept('Content-Type', 'text/html, foo/bar') assert accept.best_matches() == ['text/html', 'foo/bar'] accept = Accept('Content-Type', 'text/html, foo/bar;q=0.5') assert accept.best_matches() == ['text/html', 'foo/bar'] accept = Accept('Content-Type', 'text/html;q=0.5, foo/bar') assert accept.best_matches() == ['foo/bar', 'text/html']
def test_best_matches_with_fallback(): accept = Accept('Content-Type', 'text/html, foo/bar') assert accept.best_matches('xxx/yyy') == ['text/html', 'foo/bar', 'xxx/yyy'] accept = Accept('Content-Type', 'text/html;q=0.5, foo/bar') assert accept.best_matches('xxx/yyy') == ['foo/bar', 'text/html', 'xxx/yyy'] assert accept.best_matches('foo/bar') == ['foo/bar'] assert accept.best_matches('text/html') == ['foo/bar', 'text/html']