more tests

This commit is contained in:
Wes Barnett 2021-02-15 11:55:04 -05:00
parent 18ec7c1232
commit baf8fce9c6
No known key found for this signature in database
GPG key ID: 1070BCC98C18BD66
2 changed files with 9 additions and 2 deletions

View file

@ -27,9 +27,9 @@ logging.basicConfig(format="%(message)s", level=logging.INFO)
class SnapperCmd: class SnapperCmd:
def __init__(self, config, snapshot_type, cleanup_algorithm, description="", dbus=False, pre_number=None): def __init__(self, config, snapshot_type, cleanup_algorithm, description="", nodbus=False, pre_number=None):
self.cmd = ["snapper"] self.cmd = ["snapper"]
if dbus: if nodbus:
self.cmd.append("--no-dbus") self.cmd.append("--no-dbus")
self.cmd.append(f"--config {config} create") self.cmd.append(f"--config {config} create")
self.cmd.append(f"--type {snapshot_type}") self.cmd.append(f"--type {snapshot_type}")

View file

@ -52,6 +52,13 @@ def test_snapper_cmd_post():
assert str(snapper_cmd) == cmd assert str(snapper_cmd) == cmd
def test_snapper_cmd_post_nodbus():
snapper_cmd = SnapperCmd("root", "post", "number", "bar", True, 1234)
cmd = "snapper --no-dbus --config root create --type post --cleanup-algorithm number --print-number"
cmd += " --description \"bar\" --pre-number 1234"
assert str(snapper_cmd) == cmd
def test_get_snapper_configs(): def test_get_snapper_configs():
with tempfile.NamedTemporaryFile("w", delete=False) as f: with tempfile.NamedTemporaryFile("w", delete=False) as f:
f.write("## Path: System/Snapper\n") f.write("## Path: System/Snapper\n")