|
|
@@ -939,6 +939,7 @@ def test_run_configuration_with_multiple_repositories_retries_with_timeout():
|
|
|
def test_run_actions_runs_repo_create():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -962,9 +963,64 @@ def test_run_actions_runs_repo_create():
|
|
|
)
|
|
|
|
|
|
|
|
|
+def test_run_actions_with_matching_repository_flag_runs_repo_create():
|
|
|
+ flexmock(module).should_receive('add_custom_log_levels')
|
|
|
+ flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
+ flexmock(),
|
|
|
+ )
|
|
|
+ flexmock(module.command).should_receive('Before_after_hooks').and_return(flexmock())
|
|
|
+ flexmock(borgmatic.actions.repo_create).should_receive('run_repo_create').once()
|
|
|
+
|
|
|
+ tuple(
|
|
|
+ module.run_actions(
|
|
|
+ arguments={
|
|
|
+ 'global': flexmock(dry_run=False),
|
|
|
+ 'repo-create': flexmock(repository='repo'),
|
|
|
+ },
|
|
|
+ config_filename=flexmock(),
|
|
|
+ config={'repositories': []},
|
|
|
+ config_paths=[],
|
|
|
+ local_path=flexmock(),
|
|
|
+ remote_path=flexmock(),
|
|
|
+ local_borg_version=flexmock(),
|
|
|
+ repository={'path': 'repo'},
|
|
|
+ ),
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def test_run_actions_with_non_matching_repository_flag_bails():
|
|
|
+ flexmock(module).should_receive('add_custom_log_levels')
|
|
|
+ flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
|
|
|
+ False
|
|
|
+ )
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').never()
|
|
|
+ flexmock(module.command).should_receive('Before_after_hooks').never()
|
|
|
+ flexmock(borgmatic.actions.repo_create).should_receive('run_repo_create').never()
|
|
|
+
|
|
|
+ tuple(
|
|
|
+ module.run_actions(
|
|
|
+ arguments={
|
|
|
+ 'global': flexmock(dry_run=False),
|
|
|
+ 'repo-create': flexmock(repository='other-repo'),
|
|
|
+ },
|
|
|
+ config_filename=flexmock(),
|
|
|
+ config={'repositories': []},
|
|
|
+ config_paths=[],
|
|
|
+ local_path=flexmock(),
|
|
|
+ remote_path=flexmock(),
|
|
|
+ local_borg_version=flexmock(),
|
|
|
+ repository={'path': 'repo'},
|
|
|
+ ),
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
def test_run_actions_adds_label_file_to_hook_context():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1001,6 +1057,7 @@ def test_run_actions_adds_label_file_to_hook_context():
|
|
|
def test_run_actions_adds_log_file_to_hook_context():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1037,6 +1094,7 @@ def test_run_actions_adds_log_file_to_hook_context():
|
|
|
def test_run_actions_runs_transfer():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1060,6 +1118,7 @@ def test_run_actions_runs_transfer():
|
|
|
def test_run_actions_runs_create():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1085,6 +1144,7 @@ def test_run_actions_runs_create():
|
|
|
def test_run_actions_with_skip_actions_does_not_run_action_or_action_command_hooks():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return(['create'])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1121,6 +1181,7 @@ def test_run_actions_with_skip_actions_does_not_run_action_or_action_command_hoo
|
|
|
def test_run_actions_runs_recreate():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1145,6 +1206,7 @@ def test_run_actions_runs_recreate():
|
|
|
def test_run_actions_runs_prune():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1168,6 +1230,7 @@ def test_run_actions_runs_prune():
|
|
|
def test_run_actions_runs_compact():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1191,6 +1254,7 @@ def test_run_actions_runs_compact():
|
|
|
def test_run_actions_runs_check_when_repository_enabled_for_checks():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1215,6 +1279,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
|
|
|
def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1239,6 +1304,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
|
|
|
def test_run_actions_runs_extract():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1262,6 +1328,7 @@ def test_run_actions_runs_extract():
|
|
|
def test_run_actions_runs_export_tar():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1285,6 +1352,7 @@ def test_run_actions_runs_export_tar():
|
|
|
def test_run_actions_runs_mount():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1308,6 +1376,7 @@ def test_run_actions_runs_mount():
|
|
|
def test_run_actions_runs_restore():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1331,6 +1400,7 @@ def test_run_actions_runs_restore():
|
|
|
def test_run_actions_runs_repo_list():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1356,6 +1426,7 @@ def test_run_actions_runs_repo_list():
|
|
|
def test_run_actions_runs_list():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1381,6 +1452,7 @@ def test_run_actions_runs_list():
|
|
|
def test_run_actions_runs_repo_info():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1406,6 +1478,7 @@ def test_run_actions_runs_repo_info():
|
|
|
def test_run_actions_runs_info():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1431,6 +1504,7 @@ def test_run_actions_runs_info():
|
|
|
def test_run_actions_runs_break_lock():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1454,6 +1528,7 @@ def test_run_actions_runs_break_lock():
|
|
|
def test_run_actions_runs_export_key():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1477,6 +1552,7 @@ def test_run_actions_runs_export_key():
|
|
|
def test_run_actions_runs_import_key():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1500,6 +1576,7 @@ def test_run_actions_runs_import_key():
|
|
|
def test_run_actions_runs_change_passphrase():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1526,6 +1603,7 @@ def test_run_actions_runs_change_passphrase():
|
|
|
def test_run_actions_runs_delete():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1549,6 +1627,7 @@ def test_run_actions_runs_delete():
|
|
|
def test_run_actions_runs_repo_delete():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1575,6 +1654,7 @@ def test_run_actions_runs_repo_delete():
|
|
|
def test_run_actions_runs_borg():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1598,6 +1678,7 @@ def test_run_actions_runs_borg():
|
|
|
def test_run_actions_runs_multiple_actions_in_argument_order():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|
|
|
@@ -1626,6 +1707,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
|
|
|
def test_run_actions_runs_action_hooks_for_one_action_at_a_time():
|
|
|
flexmock(module).should_receive('add_custom_log_levels')
|
|
|
flexmock(module).should_receive('get_skip_actions').and_return([])
|
|
|
+ flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
|
|
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
flexmock(),
|
|
|
)
|