def test_highest_q(self): self.assertEqual( ['text/plain'], webdav.pick_content_types( [('text/html', {'q': '0.3'}), ('text/plain', {'q': '0.4'})], ['text/plain', 'text/html'])) self.assertEqual( ['text/html', 'text/plain'], webdav.pick_content_types( [('text/html', {}), ('text/plain', {'q': '1'})], ['text/plain', 'text/html']))
def test_wildcard(self): self.assertEqual( ['text/plain'], webdav.pick_content_types( [('text/*', {'q': '0.3'}), ('text/plain', {'q': '0.4'})], ['text/plain', 'text/html'])) self.assertEqual( set(['text/plain', 'text/html']), set(webdav.pick_content_types( [('text/*', {'q': '0.4'}), ('text/plain', {'q': '0.3'})], ['text/plain', 'text/html']))) self.assertEqual( ['application/html'], webdav.pick_content_types( [('application/*', {'q': '0.4'}), ('text/plain', {'q': '0.3'})], ['text/plain', 'application/html']))
def render(self, accepted_content_types, accepted_content_languages): content_types = webdav.pick_content_types(accepted_content_types, ['text/html']) assert content_types == ['text/html'] return render_jinja_page('collection.html', accepted_content_languages, collection=self)
async def render(self, self_url, accepted_content_types, accepted_content_languages): content_types = webdav.pick_content_types( accepted_content_types, ['text/html']) assert content_types == ['text/html'] return await render_jinja_page( 'root.html', accepted_content_languages, self_url=self_url)
def test_no_q(self): self.assertEqual( ["text/html", "text/plain"], webdav.pick_content_types( [("text/html", {}), ("text/plain", {})], ["text/plain", "text/html"], ), )
def render(self, self_url, accepted_content_types, accepted_content_languages): content_types = webdav.pick_content_types( accepted_content_types, ['text/html']) assert content_types == ['text/html'] return render_jinja_page( 'principal.html', accepted_content_languages, principal=self, self_url=self_url)
async def render(self, self_url, accepted_content_types, accepted_content_languages): content_types = webdav.pick_content_types(accepted_content_types, ["text/html"]) assert content_types == ["text/html"] return await render_jinja_page( "principal.html", accepted_content_languages, principal=self, self_url=self_url, )
def render(self, self_url, accepted_content_types, accepted_content_languages): content_types = webdav.pick_content_types(accepted_content_types, ["text/html"]) assert content_types == ["text/html"] return render_jinja_page( "root.html", accepted_content_languages, principals=self.backend.find_principals(), self_url=self_url, )
def test_highest_q(self): self.assertEqual( ["text/plain"], webdav.pick_content_types( [("text/html", { "q": "0.3" }), ("text/plain", { "q": "0.4" })], ["text/plain", "text/html"], ), ) self.assertEqual( ["text/html", "text/plain"], webdav.pick_content_types( [("text/html", {}), ("text/plain", { "q": "1" })], ["text/plain", "text/html"], ), )
def test_wildcard(self): self.assertEqual( ["text/plain"], webdav.pick_content_types( [("text/*", { "q": "0.3" }), ("text/plain", { "q": "0.4" })], ["text/plain", "text/html"], ), ) self.assertEqual( set(["text/plain", "text/html"]), set( webdav.pick_content_types( [("text/*", { "q": "0.4" }), ("text/plain", { "q": "0.3" })], ["text/plain", "text/html"], )), ) self.assertEqual( ["application/html"], webdav.pick_content_types( [ ("application/*", { "q": "0.4" }), ("text/plain", { "q": "0.3" }), ], ["text/plain", "application/html"], ), )
def test_no_q(self): self.assertEqual( ['text/html', 'text/plain'], webdav.pick_content_types( [('text/html', {}), ('text/plain', {})], ['text/plain', 'text/html']))