|
@@ -7,14 +7,19 @@ from borgmatic.commands import borgmatic as module
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_no_arguments_uses_defaults():
|
|
|
+ config_paths = ['default']
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
|
|
|
+
|
|
|
parser = module.parse_arguments()
|
|
|
|
|
|
- assert parser.config_paths == module.collect.DEFAULT_CONFIG_PATHS
|
|
|
+ assert parser.config_paths == config_paths
|
|
|
assert parser.excludes_filename == None
|
|
|
assert parser.verbosity is None
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_path_arguments_overrides_defaults():
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
|
|
+
|
|
|
parser = module.parse_arguments('--config', 'myconfig', '--excludes', 'myexcludes')
|
|
|
|
|
|
assert parser.config_paths == ['myconfig']
|
|
@@ -23,6 +28,8 @@ def test_parse_arguments_with_path_arguments_overrides_defaults():
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
|
|
+
|
|
|
parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')
|
|
|
|
|
|
assert parser.config_paths == ['myconfig', 'otherconfig']
|
|
@@ -30,14 +37,19 @@ def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
|
|
+ config_paths = ['default']
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
|
|
|
+
|
|
|
parser = module.parse_arguments('--verbosity', '1')
|
|
|
|
|
|
- assert parser.config_paths == module.collect.DEFAULT_CONFIG_PATHS
|
|
|
+ assert parser.config_paths == config_paths
|
|
|
assert parser.excludes_filename == None
|
|
|
assert parser.verbosity == 1
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_no_actions_defaults_to_all_actions_enabled():
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
|
|
+
|
|
|
parser = module.parse_arguments()
|
|
|
|
|
|
assert parser.prune is True
|
|
@@ -46,6 +58,8 @@ def test_parse_arguments_with_no_actions_defaults_to_all_actions_enabled():
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_prune_action_leaves_other_actions_disabled():
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
|
|
+
|
|
|
parser = module.parse_arguments('--prune')
|
|
|
|
|
|
assert parser.prune is True
|
|
@@ -54,6 +68,8 @@ def test_parse_arguments_with_prune_action_leaves_other_actions_disabled():
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_multiple_actions_leaves_other_action_disabled():
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
|
|
+
|
|
|
parser = module.parse_arguments('--create', '--check')
|
|
|
|
|
|
assert parser.prune is False
|
|
@@ -62,5 +78,7 @@ def test_parse_arguments_with_multiple_actions_leaves_other_action_disabled():
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_invalid_arguments_exits():
|
|
|
+ flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
|
|
+
|
|
|
with pytest.raises(SystemExit):
|
|
|
module.parse_arguments('--posix-me-harder')
|