コード例 #1
0
ファイル: test_compressor.py プロジェクト: girgen/barman
    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'
コード例 #2
0
ファイル: test_compressor.py プロジェクト: secwall/barman
    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'
コード例 #3
0
ファイル: test_compressor.py プロジェクト: qiuwenhuifx/barman
    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"
コード例 #4
0
    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"