def get_lod_mime_type(extension, request): """ return the LoD mime-type from the request """ if extension: file_extension, mime_type = extension_to_mime(extension) else: mime_type = best_match(RDF_SUPPORTED_MIME_TYPES, request.META.get("HTTP_ACCEPT")) return mime_type
def test_best_match(): assert mimeutils.best_match(RDF_SUPPORTED_MIME_TYPES, "text/turtle") == mimeutils.TURTLE_MIME assert mimeutils.best_match(RDF_SUPPORTED_MIME_TYPES, "text/unknown") == '' assert mimeutils.best_match(RDF_SUPPORTED_MIME_TYPES, 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8') == '' assert mimeutils.best_match(RDF_SUPPORTED_MIME_TYPES, None) is None