Exemple #1
0
    def test_bzip2(self, tmpdir):

        config_mock = mock.Mock()

        compression_manager = CompressionManager(config_mock, tmpdir.strpath)

        compressor = PyBZip2Compressor(config=config_mock,
                                       compression="pybzip2")

        src = tmpdir.join("sourcefile")
        src.write("content")

        compressor.compress(src.strpath, BZIP2_FILE % tmpdir.strpath)
        assert os.path.exists(BZIP2_FILE % tmpdir.strpath)
        compression_zip = compression_manager.identify_compression(
            BZIP2_FILE % tmpdir.strpath, )
        assert compression_zip == "bzip2"

        compressor.decompress(
            BZIP2_FILE % tmpdir.strpath,
            BZIP2_FILE_UNCOMPRESSED % tmpdir.strpath,
        )

        f = open(BZIP2_FILE_UNCOMPRESSED % tmpdir.strpath).read()
        assert f == "content"
Exemple #2
0
    def test_bzip2(self, tmpdir):

        config_mock = mock.Mock()

        compressor = PyBZip2Compressor(config=config_mock,
                                       compression='pybzip2')

        src = tmpdir.join('sourcefile')
        src.write('content')

        compressor.compress(src.strpath, '%s/bzipfile.bz2' % tmpdir.strpath)
        assert os.path.exists('%s/bzipfile.bz2' % tmpdir.strpath)
        compression_zip = identify_compression('%s/bzipfile.bz2' %
                                               tmpdir.strpath)
        assert compression_zip == "bzip2"

        compressor.decompress('%s/bzipfile.bz2' % tmpdir.strpath,
                              '%s/bzipfile.uncompressed' % tmpdir.strpath)

        f = open('%s/bzipfile.uncompressed' % tmpdir.strpath).read()
        assert f == 'content'
    def test_bzip2(self, tmpdir):

        config_mock = mock.Mock()

        compressor = PyBZip2Compressor(config=config_mock,
                                       compression="pybzip2")

        src = tmpdir.join("sourcefile")
        src.write("content")

        compressor.compress(src.strpath, "%s/bzipfile.bz2" % tmpdir.strpath)
        assert os.path.exists("%s/bzipfile.bz2" % tmpdir.strpath)
        compression_zip = identify_compression("%s/bzipfile.bz2" %
                                               tmpdir.strpath)
        assert compression_zip == "bzip2"

        compressor.decompress(
            "%s/bzipfile.bz2" % tmpdir.strpath,
            "%s/bzipfile.uncompressed" % tmpdir.strpath,
        )

        f = open("%s/bzipfile.uncompressed" % tmpdir.strpath).read()
        assert f == "content"