freezer/tests/test_tar_builders.py
Memo Garcia 309e6e1e81 add option to choose compression algorithm with choose between gzip, bzip2 and xz
xz.exe with sources added for windows

Implements: blueprint compression-options

Change-Id: I62d7b0c696556c68ab7bab5cd00689f0ba731b9e
2015-08-12 15:15:19 +02:00

47 lines
1.8 KiB
Python

import unittest
from freezer import tar
class TestTarCommandBuilder(unittest.TestCase):
def setUp(self):
self.builder = tar.TarCommandBuilder("gnutar", ".", "gzip")
def test_build(self):
self.assertEquals(
self.builder.build(),
"gnutar --create -z --warning=none --no-check-device "
"--one-file-system --preserve-permissions "
"--same-owner --seek --ignore-failed-read .")
def test_build_listed(self):
self.builder.set_listed_incremental("listed-file.tar")
self.assertEquals(
self.builder.build(),
"gnutar --create -z --warning=none --no-check-device "
"--one-file-system --preserve-permissions --same-owner --seek "
"--ignore-failed-read --listed-incremental=listed-file.tar .")
def test_build_every_arg(self):
self.builder.set_listed_incremental("listed-file.tar")
self.builder.set_encryption("openssl", "encrypt_pass_file")
self.builder.set_dereference("hard")
self.builder.set_exclude("excluded_files")
self.assertEquals(
self.builder.build(),
"gnutar --create -z --warning=none --no-check-device "
"--one-file-system --preserve-permissions --same-owner "
"--seek --ignore-failed-read --listed-incremental=listed-file.tar "
"--exclude=\"excluded_files\" . | openssl enc -aes-256-cfb -pass "
"file:encrypt_pass_file")
class TestTarCommandRestoreBuilder(unittest.TestCase):
def setUp(self):
self.builder = tar.TarCommandRestoreBuilder("gnutar", "restore_path", "gzip")
def test(self):
self.assertEquals(
self.builder.build(),
"gnutar -z --incremental --extract --unlink-first --ignore-zeros "
"--warning=none --overwrite --directory restore_path")