def test_gzip(self, tmpdir): config_mock = mock.Mock() compressor = GZipCompressor(config=config_mock, compression='gzip') src = tmpdir.join('sourcefile') src.write('content') compressor.compress(src.strpath, '%s/zipfile.zip' % tmpdir.strpath) assert os.path.exists('%s/zipfile.zip' % tmpdir.strpath) compression_zip = identify_compression('%s/zipfile.zip' % tmpdir.strpath) assert compression_zip == "gzip" compressor.decompress('%s/zipfile.zip' % tmpdir.strpath, '%s/zipfile.uncompressed' % tmpdir.strpath) f = open('%s/zipfile.uncompressed' % tmpdir.strpath).read() assert f == 'content'
def test_gzip(self, tmpdir): config_mock = mock.Mock() compressor = GZipCompressor(config=config_mock, compression="gzip") src = tmpdir.join("sourcefile") src.write("content") compressor.compress(src.strpath, "%s/zipfile.zip" % tmpdir.strpath) assert os.path.exists("%s/zipfile.zip" % tmpdir.strpath) compression_zip = identify_compression("%s/zipfile.zip" % tmpdir.strpath) assert compression_zip == "gzip" compressor.decompress( "%s/zipfile.zip" % tmpdir.strpath, "%s/zipfile.uncompressed" % tmpdir.strpath, ) f = open("%s/zipfile.uncompressed" % tmpdir.strpath).read() assert f == "content"
def test_gzip(self, tmpdir): config_mock = mock.Mock() compression_manager = CompressionManager(config_mock, tmpdir.strpath) compressor = GZipCompressor(config=config_mock, compression="gzip") src = tmpdir.join("sourcefile") src.write("content") compressor.compress(src.strpath, ZIP_FILE % tmpdir.strpath) assert os.path.exists(ZIP_FILE % tmpdir.strpath) compression_zip = compression_manager.identify_compression( ZIP_FILE % tmpdir.strpath) assert compression_zip == "gzip" compressor.decompress( ZIP_FILE % tmpdir.strpath, ZIP_FILE_UNCOMPRESSED % tmpdir.strpath, ) f = open(ZIP_FILE_UNCOMPRESSED % tmpdir.strpath).read() assert f == "content"