aboutsummaryrefslogtreecommitdiffstats
path: root/tools/archiver/tests/test.py
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /tools/archiver/tests/test.py
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'tools/archiver/tests/test.py')
-rw-r--r--tools/archiver/tests/test.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/archiver/tests/test.py b/tools/archiver/tests/test.py
new file mode 100644
index 0000000000..b92d58f6a9
--- /dev/null
+++ b/tools/archiver/tests/test.py
@@ -0,0 +1,68 @@
+import os
+import logging
+from yatest import common as ytc
+
+logger = logging.getLogger("test_logger")
+
+
+class TestArchiver(object):
+ @classmethod
+ def setup_class(cls):
+ cls.archiver_path = ytc.binary_path("tools/archiver/archiver")
+
+ def test_recursive(self):
+ assert 'archiver' == os.path.basename(self.archiver_path)
+ assert os.path.exists(self.archiver_path)
+ contents = ytc.source_path("tools/archiver/tests/directory")
+ ytc.execute(
+ command=[
+ self.archiver_path,
+ "--output", "archive",
+ "--recursive",
+ contents,
+ ]
+ )
+ with open('result', 'w') as archive_list:
+ ytc.execute(
+ command=[
+ self.archiver_path,
+ "--list",
+ "archive",
+ ],
+ stdout=archive_list,
+ stderr=None,
+ )
+ archive_list = sorted(open('result').read().strip().split('\n'))
+ assert len(archive_list) == 3
+ assert archive_list[0] == 'file1'
+ assert archive_list[1] == 'file2'
+ assert archive_list[2] == 'file3'
+
+ def test_deduplicate(self):
+ assert 'archiver' == os.path.basename(self.archiver_path)
+ assert os.path.exists(self.archiver_path)
+ contents = ytc.source_path("tools/archiver/tests/directory")
+ ytc.execute(
+ command=[
+ self.archiver_path,
+ "--output", "result_dedup",
+ "--recursive",
+ "--deduplicate",
+ "--plain",
+ contents,
+ ]
+ )
+ ytc.execute(
+ command=[
+ self.archiver_path,
+ "--output", "result_no_dedup",
+ "--recursive",
+ "--plain",
+ contents,
+ ]
+ )
+ with open('result_dedup', 'rb') as f_dedup, open('result_no_dedup', 'rb') as f_no_dedup:
+ archive_dedup = f_dedup.read()
+ archive_no_dedup = f_no_dedup.read()
+ assert len(archive_dedup) == 58
+ assert len(archive_no_dedup) == 75