From 32f81eff27125a4b2de15d3c369aead5c86b2ab4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 13 Sep 2022 00:01:55 +0200 Subject: [PATCH] move config cmd tests to own module --- src/borg/testsuite/archiver/__init__.py | 40 --------------------- src/borg/testsuite/archiver/config_cmd.py | 42 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 40 deletions(-) create mode 100644 src/borg/testsuite/archiver/config_cmd.py diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py index 1587c6c27..36d5c0401 100644 --- a/src/borg/testsuite/archiver/__init__.py +++ b/src/borg/testsuite/archiver/__init__.py @@ -1891,42 +1891,6 @@ def test_bad_filters(self): self.cmd(f"--repo={self.repository_location}", "create", "test", "input") self.cmd(f"--repo={self.repository_location}", "delete", "--first", "1", "--last", "1", fork=True, exit_code=2) - def test_config(self): - self.create_test_files() - os.unlink("input/flagfile") - self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) - output = self.cmd(f"--repo={self.repository_location}", "config", "--list") - self.assert_in("[repository]", output) - self.assert_in("version", output) - self.assert_in("segments_per_dir", output) - self.assert_in("storage_quota", output) - self.assert_in("append_only", output) - self.assert_in("additional_free_space", output) - self.assert_in("id", output) - self.assert_not_in("last_segment_checked", output) - - output = self.cmd(f"--repo={self.repository_location}", "config", "last_segment_checked", exit_code=1) - self.assert_in("No option ", output) - self.cmd(f"--repo={self.repository_location}", "config", "last_segment_checked", "123") - output = self.cmd(f"--repo={self.repository_location}", "config", "last_segment_checked") - assert output == "123" + "\n" - output = self.cmd(f"--repo={self.repository_location}", "config", "--list") - self.assert_in("last_segment_checked", output) - self.cmd(f"--repo={self.repository_location}", "config", "--delete", "last_segment_checked") - - for cfg_key, cfg_value in [("additional_free_space", "2G"), ("repository.append_only", "1")]: - output = self.cmd(f"--repo={self.repository_location}", "config", cfg_key) - assert output == "0" + "\n" - self.cmd(f"--repo={self.repository_location}", "config", cfg_key, cfg_value) - output = self.cmd(f"--repo={self.repository_location}", "config", cfg_key) - assert output == cfg_value + "\n" - self.cmd(f"--repo={self.repository_location}", "config", "--delete", cfg_key) - self.cmd(f"--repo={self.repository_location}", "config", cfg_key, exit_code=1) - - self.cmd(f"--repo={self.repository_location}", "config", "--list", "--delete", exit_code=2) - self.cmd(f"--repo={self.repository_location}", "config", exit_code=2) - self.cmd(f"--repo={self.repository_location}", "config", "invalid-option", exit_code=1) - # derived from test_extract_xattrs_errors() @pytest.mark.skipif( not xattr.XATTR_FAKEROOT, reason="xattr not supported on this system or on this version of fakeroot" @@ -2117,10 +2081,6 @@ def test_remote_repo_restrict_to_repository(self): with pytest.raises(PathNotAllowed): self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) - @unittest.skip("only works locally") - def test_config(self): - pass - @unittest.skip("only works locally") def test_migrate_lock_alive(self): pass diff --git a/src/borg/testsuite/archiver/config_cmd.py b/src/borg/testsuite/archiver/config_cmd.py new file mode 100644 index 000000000..a466739f4 --- /dev/null +++ b/src/borg/testsuite/archiver/config_cmd.py @@ -0,0 +1,42 @@ +import os + +from ...constants import * # NOQA +from . import ArchiverTestCaseBase, RK_ENCRYPTION + + +class ArchiverTestCase(ArchiverTestCaseBase): + def test_config(self): + self.create_test_files() + os.unlink("input/flagfile") + self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION) + output = self.cmd(f"--repo={self.repository_location}", "config", "--list") + self.assert_in("[repository]", output) + self.assert_in("version", output) + self.assert_in("segments_per_dir", output) + self.assert_in("storage_quota", output) + self.assert_in("append_only", output) + self.assert_in("additional_free_space", output) + self.assert_in("id", output) + self.assert_not_in("last_segment_checked", output) + + output = self.cmd(f"--repo={self.repository_location}", "config", "last_segment_checked", exit_code=1) + self.assert_in("No option ", output) + self.cmd(f"--repo={self.repository_location}", "config", "last_segment_checked", "123") + output = self.cmd(f"--repo={self.repository_location}", "config", "last_segment_checked") + assert output == "123" + "\n" + output = self.cmd(f"--repo={self.repository_location}", "config", "--list") + self.assert_in("last_segment_checked", output) + self.cmd(f"--repo={self.repository_location}", "config", "--delete", "last_segment_checked") + + for cfg_key, cfg_value in [("additional_free_space", "2G"), ("repository.append_only", "1")]: + output = self.cmd(f"--repo={self.repository_location}", "config", cfg_key) + assert output == "0" + "\n" + self.cmd(f"--repo={self.repository_location}", "config", cfg_key, cfg_value) + output = self.cmd(f"--repo={self.repository_location}", "config", cfg_key) + assert output == cfg_value + "\n" + self.cmd(f"--repo={self.repository_location}", "config", "--delete", cfg_key) + self.cmd(f"--repo={self.repository_location}", "config", cfg_key, exit_code=1) + + self.cmd(f"--repo={self.repository_location}", "config", "--list", "--delete", exit_code=2) + self.cmd(f"--repo={self.repository_location}", "config", exit_code=2) + self.cmd(f"--repo={self.repository_location}", "config", "invalid-option", exit_code=1)