coverage at 100
This commit is contained in:
parent
f82631e3bb
commit
2d761dd86b
4 changed files with 67 additions and 0 deletions
|
@ -297,6 +297,7 @@ def test_parse_arguments_disallows_paths_unless_action_consumes_it():
|
|||
with pytest.raises(SystemExit):
|
||||
module.parse_arguments('--config', 'myconfig', '--path', 'test')
|
||||
|
||||
|
||||
def test_parse_arguments_disallows_other_actions_with_config_bootstrap():
|
||||
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
||||
|
||||
|
|
33
tests/unit/actions/config/test_bootstrap.py
Normal file
33
tests/unit/actions/config/test_bootstrap.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from flexmock import flexmock
|
||||
|
||||
from borgmatic.actions.config import bootstrap as module
|
||||
|
||||
|
||||
def test_run_bootstrap():
|
||||
bootstrap_arguments = flexmock(
|
||||
repository='repo',
|
||||
archive='archive',
|
||||
destination='dest',
|
||||
strip_components=1,
|
||||
progress=False,
|
||||
borgmatic_source_directory='/borgmatic',
|
||||
)
|
||||
global_arguments = flexmock(
|
||||
dry_run=False,
|
||||
)
|
||||
local_borg_version = flexmock()
|
||||
extract_process = flexmock(
|
||||
stdout=flexmock(
|
||||
read=lambda: '{"config_paths": ["/borgmatic/config.yaml"]}',
|
||||
),
|
||||
)
|
||||
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
|
||||
extract_process
|
||||
)
|
||||
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
|
||||
'archive'
|
||||
)
|
||||
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
|
||||
extract_process
|
||||
)
|
||||
module.run_bootstrap(bootstrap_arguments, global_arguments, local_borg_version)
|
|
@ -103,3 +103,20 @@ def test_run_create_bails_if_repository_does_not_match():
|
|||
remote_path=None,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_create_borgmatic_manifest_creates_manifest_file():
|
||||
flexmock(module.os.path).should_receive('expanduser').and_return('/home/user')
|
||||
flexmock(module.os.path).should_receive('join').and_return('/home/user/bootstrap/manifest.json')
|
||||
flexmock(module.os.path).should_receive('exists').and_return(False)
|
||||
flexmock(module.os).should_receive('makedirs').and_return(True)
|
||||
|
||||
flexmock(module.json).should_receive('dump').and_return(True)
|
||||
|
||||
module.create_borgmatic_manifest({}, 'test.yaml', False)
|
||||
|
||||
|
||||
def test_create_borgmatic_manifest_does_not_create_manifest_file_on_dry_run():
|
||||
flexmock(module.os.path).should_receive('expanduser').never()
|
||||
|
||||
module.create_borgmatic_manifest({}, 'test.yaml', True)
|
||||
|
|
|
@ -987,6 +987,22 @@ def test_collect_configuration_run_summary_logs_info_for_success_with_extract():
|
|||
assert {log.levelno for log in logs} == {logging.INFO}
|
||||
|
||||
|
||||
def test_collect_configuration_run_summary_logs_info_for_success_with_bootstrap():
|
||||
flexmock(module.validate).should_receive('guard_single_repository_selected').never()
|
||||
flexmock(module.validate).should_receive('guard_configuration_contains_repository').never()
|
||||
flexmock(module).should_receive('run_configuration').never()
|
||||
flexmock(module.borgmatic.actions.config.bootstrap).should_receive('run_bootstrap')
|
||||
arguments = {
|
||||
'bootstrap': flexmock(repository='repo'),
|
||||
'global': flexmock(monitoring_verbosity=1, dry_run=False),
|
||||
}
|
||||
|
||||
logs = tuple(
|
||||
module.collect_configuration_run_summary_logs({'test.yaml': {}}, arguments=arguments)
|
||||
)
|
||||
assert {log.levelno for log in logs} == {logging.INFO}
|
||||
|
||||
|
||||
def test_collect_configuration_run_summary_logs_extract_with_repository_error():
|
||||
flexmock(module.validate).should_receive('guard_configuration_contains_repository').and_raise(
|
||||
ValueError
|
||||
|
|
Loading…
Reference in a new issue