def test_determine_function_returns_octet_stream_for_unknown_formats(self): """ Check that we return application/octet-stream when we give a filename with an unknown extension. """ typ = gcs._determine_content_type("unknown.format") assert typ == "application/octet-stream"
def test_determine_function_returns_a_string(self): """ Sanity check that _determine_content_type returns a string for the happy path. """ typ = gcs._determine_content_type("me.pdf") assert isinstance(typ, str)
def _update_metadata(self, blob): name = str(blob.name) content_type = gcs._determine_content_type(name) cache_control = self._determine_cache_control(name) blob_update = { "Content-Type": content_type, "Cache-Control": cache_control, } blob.metadata = blob_update blob.patch()
def test_determine_function_returns_pdf_for_pdfs(self): """ Check that _determine_content_type returns an application/pdf for .pdf suffixed strings. """ assert gcs._determine_content_type("me.pdf") == "application/pdf"