def test_want_html(self): for mimetype in 'text/html', 'application/xhtml+xml': headers = {'accept': mimetype} with self.app.test_request_context(headers=headers): self.assertFalse(want_rdf()) with self.app.test_request_context(): self.assertFalse(want_rdf())
def dispatch_request(self, *args, **kwargs): if want_rdf(): fmt = RDF_EXTENSIONS[negociate_content()] url = url_for('datasets.rdf_format', dataset=kwargs['dataset'].id, format=fmt) return redirect(url) return super(DatasetDetailView, self).dispatch_request(*args, **kwargs)
def test_want_rdf(self): for mimetype in 'application/xml', 'application/json': headers = {'accept': mimetype} with self.app.test_request_context(headers=headers): self.assertTrue(want_rdf())