Update tests
Make them more explicit. Also formatting.
This commit is contained in:
parent
5f87ea3ec5
commit
3e22414613
4 changed files with 40 additions and 26 deletions
|
@ -8,10 +8,11 @@ def test_run_check_calls_hooks_for_configured_repository():
|
|||
flexmock(module.borgmatic.config.checks).should_receive(
|
||||
'repository_enabled_for_checks'
|
||||
).and_return(True)
|
||||
flexmock(module.borgmatic.borg.check).should_receive('check_archives')
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
||||
flexmock(module.borgmatic.borg.check).should_receive('check_archives').once()
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('execute_hook').times(2)
|
||||
check_arguments = flexmock(
|
||||
repository=None, progress=flexmock(), repair=flexmock(), only=flexmock(), force=flexmock()
|
||||
repository=None, progress=flexmock(), repair=flexmock(), only=flexmock(), force=flexmock(),
|
||||
)
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
||||
|
@ -33,16 +34,22 @@ def test_run_check_calls_hooks_for_configured_repository():
|
|||
|
||||
def test_run_check_runs_with_select_repository():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
|
||||
flexmock(module.borgmatic.borg.check).should_receive('check_archives')
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'repositories_match'
|
||||
).once().and_return(True)
|
||||
flexmock(module.borgmatic.borg.check).should_receive('check_archives').once()
|
||||
check_arguments = flexmock(
|
||||
repository='repo', progress=flexmock(), repair=flexmock(), only=flexmock(), force=flexmock()
|
||||
repository=flexmock(),
|
||||
progress=flexmock(),
|
||||
repair=flexmock(),
|
||||
only=flexmock(),
|
||||
force=flexmock(),
|
||||
)
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
||||
module.run_check(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository=flexmock(),
|
||||
location={'repositories': ['repo']},
|
||||
storage={},
|
||||
consistency={},
|
||||
|
@ -58,12 +65,12 @@ def test_run_check_runs_with_select_repository():
|
|||
|
||||
def test_run_check_bails_if_repository_does_not_match():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
|
||||
False
|
||||
)
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'repositories_match'
|
||||
).once().and_return(False)
|
||||
flexmock(module.borgmatic.borg.check).should_receive('check_archives').never()
|
||||
check_arguments = flexmock(
|
||||
repository='repo2',
|
||||
repository=flexmock(),
|
||||
progress=flexmock(),
|
||||
repair=flexmock(),
|
||||
only=flexmock(),
|
||||
|
|
|
@ -6,7 +6,8 @@ from borgmatic.actions import compact as module
|
|||
def test_compact_actions_calls_hooks_for_configured_repository():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.compact).should_receive('compact_segments')
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
||||
flexmock(module.borgmatic.borg.compact).should_receive('compact_segments').once()
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('execute_hook').times(2)
|
||||
compact_arguments = flexmock(
|
||||
repository=None, progress=flexmock(), cleanup_commits=flexmock(), threshold=flexmock()
|
||||
|
@ -31,11 +32,13 @@ def test_compact_actions_calls_hooks_for_configured_repository():
|
|||
|
||||
def test_compact_runs_with_select_repository():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'repositories_match'
|
||||
).once().and_return(True)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.compact).should_receive('compact_segments')
|
||||
flexmock(module.borgmatic.borg.compact).should_receive('compact_segments').once()
|
||||
compact_arguments = flexmock(
|
||||
repository='repo', progress=flexmock(), cleanup_commits=flexmock(), threshold=flexmock()
|
||||
repository=flexmock(), progress=flexmock(), cleanup_commits=flexmock(), threshold=flexmock()
|
||||
)
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
||||
|
@ -58,12 +61,12 @@ def test_compact_runs_with_select_repository():
|
|||
def test_compact_bails_if_repository_does_not_match():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
|
||||
False
|
||||
)
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'repositories_match'
|
||||
).once().and_return(False)
|
||||
flexmock(module.borgmatic.borg.compact).should_receive('compact_segments').never()
|
||||
compact_arguments = flexmock(
|
||||
repository='repo2', progress=flexmock(), cleanup_commits=flexmock(), threshold=flexmock()
|
||||
repository=flexmock(), progress=flexmock(), cleanup_commits=flexmock(), threshold=flexmock()
|
||||
)
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@ from flexmock import flexmock
|
|||
from borgmatic.actions import create as module
|
||||
|
||||
|
||||
def test_run_create_executes_and_calls_hooks():
|
||||
def test_run_create_executes_and_calls_hooks_for_configured_repository():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
||||
flexmock(module.borgmatic.borg.create).should_receive('create_archive').once()
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('execute_hook').times(2)
|
||||
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return({})
|
||||
|
@ -12,7 +13,7 @@ def test_run_create_executes_and_calls_hooks():
|
|||
'call_hooks_even_if_unconfigured'
|
||||
).and_return({})
|
||||
create_arguments = flexmock(
|
||||
repository=flexmock(),
|
||||
repository=None,
|
||||
progress=flexmock(),
|
||||
stats=flexmock(),
|
||||
json=flexmock(),
|
||||
|
|
|
@ -5,7 +5,8 @@ from borgmatic.actions import prune as module
|
|||
|
||||
def test_run_prune_calls_hooks_of_configured_repository():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.borg.prune).should_receive('prune_archives')
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').never()
|
||||
flexmock(module.borgmatic.borg.prune).should_receive('prune_archives').once()
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('execute_hook').times(2)
|
||||
prune_arguments = flexmock(repository=None, stats=flexmock(), list_archives=flexmock())
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
@ -28,8 +29,10 @@ def test_run_prune_calls_hooks_of_configured_repository():
|
|||
|
||||
def test_run_prune_runs_with_select_repository():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
|
||||
flexmock(module.borgmatic.borg.prune).should_receive('prune_archives')
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'repositories_match'
|
||||
).once().and_return(True)
|
||||
flexmock(module.borgmatic.borg.prune).should_receive('prune_archives').once()
|
||||
prune_arguments = flexmock(repository=flexmock(), stats=flexmock(), list_archives=flexmock())
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
||||
|
@ -51,9 +54,9 @@ def test_run_prune_runs_with_select_repository():
|
|||
|
||||
def test_run_prune_bails_if_repository_does_not_match():
|
||||
flexmock(module.logger).answer = lambda message: None
|
||||
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
|
||||
False
|
||||
)
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'repositories_match'
|
||||
).once().and_return(False)
|
||||
flexmock(module.borgmatic.borg.prune).should_receive('prune_archives').never()
|
||||
prune_arguments = flexmock(repository=flexmock(), stats=flexmock(), list_archives=flexmock())
|
||||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
|
Loading…
Reference in a new issue