Browse Source

Tests: Updating console

pull/9/head
Ryan Reed 1 year ago
parent
commit
f6ffe77f37
1 changed files with 54 additions and 28 deletions
  1. +54
    -28
      tests/test_console.py

+ 54
- 28
tests/test_console.py View File

@ -4,53 +4,77 @@ from transpose.console import parse_arguments
def test_parse_arguments(): def test_parse_arguments():
# Missing required argument - action
with pytest.raises(SystemExit):
with pytest.raises(SystemExit): # Missing required args: action
parse_arguments() parse_arguments()
args = parse_arguments( args = parse_arguments(
[ [
"store",
"--cache-filename",
"test-cache-file.json",
"--store-path", "--store-path",
"/mnt/store", "/mnt/store",
"MyTarget",
"store",
"/tmp/some/path", "/tmp/some/path",
"MyTarget",
] ]
) )
assert args.cache_filename == "test-cache-file.json"
assert args.store_path == "/mnt/store" assert args.store_path == "/mnt/store"
def test_parse_arguments_apply(): def test_parse_arguments_apply():
# Missing required argument - target_path
with pytest.raises(SystemExit):
with pytest.raises(SystemExit): # Missing required args: name
args = parse_arguments(["apply"]) args = parse_arguments(["apply"])
args = parse_arguments(["apply", "/tmp/some/path"])
args = parse_arguments(["apply", "SomeName"])
assert args.action == "apply" assert args.action == "apply"
assert args.target_path == "/tmp/some/path"
assert args.name == "SomeName"
assert args.force is False
args = parse_arguments(["apply", "SomeName", "--force"])
assert args.force is True
def test_parse_arguments_config():
with pytest.raises(SystemExit): # Missing required args: config_action
parse_arguments(["config"])
def test_parse_arguments_config_add():
with pytest.raises(SystemExit): # Missing required args: name, path
args = parse_arguments(["config", "add"])
def test_parse_arguments_create():
# Missing required argument - target_path store_path
with pytest.raises(SystemExit):
args = parse_arguments(["create"])
with pytest.raises(SystemExit): # Missing required args: path
args = parse_arguments(["config", "add", "SomeName"])
# Missing required argument - stored_path
with pytest.raises(SystemExit):
args = parse_arguments(["create", "/tmp/target_path"])
args = parse_arguments(["config", "add", "SomeName", "/var/tmp/something"])
assert args.config_action == "add"
assert args.name == "SomeName"
assert args.path == "/var/tmp/something"
args = parse_arguments(["create", "/tmp/target_path", "/tmp/stored_path"])
assert args.action == "create"
assert args.target_path == "/tmp/target_path"
assert args.stored_path == "/tmp/stored_path"
def test_parse_arguments_config_get():
with pytest.raises(SystemExit): # Missing required args: name
args = parse_arguments(["config", "get"])
args = parse_arguments(["config", "get", "SomeName"])
assert args.config_action == "get"
assert args.name == "SomeName"
def test_parse_arguments_config_list():
args = parse_arguments(["config", "list"])
assert args.config_action == "list"
def test_parse_arguments_config_remove():
with pytest.raises(SystemExit): # Missing required args: name
args = parse_arguments(["config", "remove"])
args = parse_arguments(["config", "remove", "SomeName"])
assert args.config_action == "remove"
assert args.name == "SomeName"
def test_parse_arguments_store(): def test_parse_arguments_store():
# Missing required argument - target_path
with pytest.raises(SystemExit):
with pytest.raises(SystemExit): # Missing required args: target_path
args = parse_arguments(["store"]) args = parse_arguments(["store"])
args = parse_arguments(["store", "/tmp/some/path"]) args = parse_arguments(["store", "/tmp/some/path"])
@ -63,10 +87,12 @@ def test_parse_arguments_store():
def test_parse_arguments_restore(): def test_parse_arguments_restore():
# Missing required argument - target_path
with pytest.raises(SystemExit):
with pytest.raises(SystemExit): # Missing required args: name
args = parse_arguments(["restore"]) args = parse_arguments(["restore"])
args = parse_arguments(["restore", "/tmp/some/path"])
args = parse_arguments(["restore", "SomeName"])
assert args.action == "restore" assert args.action == "restore"
assert args.target_path == "/tmp/some/path"
assert args.name == "SomeName"
args = parse_arguments(["restore", "SomeName", "--force"])
assert args.force is True

Loading…
Cancel
Save