def test_infer_file_type_from_uri_unsupported(self): """ Unit test for method infer_file_type_from_uri, unsupported file type case """ file_io = FileIO() with self.assertRaises(FileTypeNotSupportedYet): file_io.infer_file_type_from_uri(TEST_UNSUPPORTED_FILE_TYPE, mimetype=True)
def test_infer_file_type_tar_files(): """Unit test for method infer_file_type_from_uri, tar file case.""" file_io = FileIO() for ffile in os.listdir(TEST_TAR_LOCATION): test_file_type = mimetypes.guess_type( os.path.join(TEST_TAR_LOCATION, ffile))[1] assert file_io.infer_file_type_from_uri( os.path.join(TEST_TAR_LOCATION, ffile), mimetype=True) == TarCompressedTypes.mime(test_file_type) assert file_io.infer_file_type_from_uri( os.path.join(TEST_TAR_LOCATION, ffile), mimetype=False) == TarCompressedTypes.name(test_file_type)
def test_infer_file_type_from_uri_remote(): """ Unit test for method infer_file_type_from_uri, remote case. """ file_io = FileIO() assert file_io.infer_file_type_from_uri(TEST_URL) == 'JPG'
def test_infer_file_type_from_uri_no_mimetype(): """ Unit test for method infer_file_type_from_uri, no mimetype case """ file_io = FileIO() assert file_io.infer_file_type_from_uri(TEST_LOCAL, mimetype=False) == 'JPG'
def test_infer_file_type_from_uri_with_mimetype(): """ Unit test for method infer_file_type_from_uri, with mimetype case """ file_io = FileIO() _, mime = file_io.infer_file_type_from_uri(TEST_LOCAL, mimetype=True) assert mime == 'image/jpeg'
def test_infer_file_type_from_uri_unknown(self): """ Unit test infer_file_type_from_uri, unknown case. """ with self.assertRaises(FileTypeNotSupportedYet): file_io = FileIO() file_io.infer_file_type_from_uri(TEST_UNKNOWN)