From 30297b085e00187e00eed32022bd085a47c2df4d Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sun, 29 Oct 2017 18:03:54 +0100 Subject: cli: Add compression and forcing options --- tests/test_recursiveloader.py | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'tests/test_recursiveloader.py') diff --git a/tests/test_recursiveloader.py b/tests/test_recursiveloader.py index 9521c2e..6f8f4e1 100644 --- a/tests/test_recursiveloader.py +++ b/tests/test_recursiveloader.py @@ -879,6 +879,30 @@ DATA test 0 MD5 d41d8cd98f00b204e9800998ecf8427e self.assertTrue(os.path.exists( os.path.join(self.dir, 'Manifest'))) + def test_cli_compress_manifests_low_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'update', + '--hashes=SHA256 SHA512', + '--compress-watermark=0', + self.dir]), + 0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + + def test_cli_compress_manifests_high_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'update', + '--hashes=SHA256 SHA512', + '--compress-watermark=4096', + self.dir]), + 0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + class DuplicateManifestFileEntryTest(TempDirTestCase): """ @@ -1915,6 +1939,30 @@ DATA test 0 MD5 d41d8cd98f00b204e9800998ecf8427e self.assertTrue(os.path.exists( os.path.join(self.dir, 'Manifest'))) + def test_cli_decompress_manifests_low_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'update', + '--hashes=SHA256 SHA512', + '--compress-watermark=0', + self.dir]), + 0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + + def test_cli_decompress_manifests_high_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'update', + '--hashes=SHA256 SHA512', + '--compress-watermark=4096', + self.dir]), + 0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + class CompressedSubManifestTest(TempDirTestCase): """ @@ -2010,6 +2058,38 @@ MANIFEST sub/Manifest.gz 78 MD5 9c158f87b2445279d7c8aac439612fba self.assertFalse(os.path.exists( os.path.join(self.dir, 'sub/Manifest.gz'))) + def test_cli_recompress_manifests_low_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'update', + '--hashes=SHA256 SHA512', + '--compress-watermark=0', + self.dir]), + 0) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'sub/Manifest.gz'))) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'sub/Manifest'))) + + def test_cli_recompress_manifests_high_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'update', + '--hashes=SHA256 SHA512', + '--compress-watermark=4096', + self.dir]), + 0) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'sub/Manifest'))) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'sub/Manifest.gz'))) + class CompressedManifestOrderingTest(TempDirTestCase): """ @@ -2319,6 +2399,30 @@ class CreateNewManifestTest(TempDirTestCase): self.assertTrue(os.path.exists( os.path.join(self.dir, 'Manifest'))) + def test_cli_compress_manifests_low_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'create', + '--hashes=SHA256 SHA512', + '--compress-watermark=0', + os.path.join(self.dir, 'Manifest')]), + 0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + + def test_cli_compress_manifests_high_watermark(self): + self.assertEqual( + gemato.cli.main(['gemato', 'create', + '--hashes=SHA256 SHA512', + '--compress-watermark=4096', + os.path.join(self.dir, 'Manifest')]), + 0) + self.assertFalse(os.path.exists( + os.path.join(self.dir, 'Manifest.gz'))) + self.assertTrue(os.path.exists( + os.path.join(self.dir, 'Manifest'))) + class CreateNewCompressedManifestTest(TempDirTestCase): DIRS = ['sub'] -- cgit v1.2.3