mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 02:03:01 +02:00
Fix broken tests.
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import asyncio
|
||||
|
||||
import borgmatic.actions.browse.app
|
||||
import borgmatic.actions.browse.panels
|
||||
|
||||
import pytest
|
||||
from flexmock import flexmock
|
||||
|
||||
|
||||
pytestmark = pytest.mark.asyncio(loop_scope="module")
|
||||
loop: asyncio.AbstractEventLoop
|
||||
|
||||
|
||||
async def test_browse_app_with_multiple_configs_uses_configuration_files_list():
|
||||
app = borgmatic.actions.browse.app.Browse_app(
|
||||
@@ -9,6 +18,7 @@ async def test_browse_app_with_multiple_configs_uses_configuration_files_list():
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
header = app.query_one(selector='Header')
|
||||
@@ -31,6 +41,7 @@ async def test_browse_app_with_one_config_uses_repositories_list():
|
||||
'test1.yaml': {'repositories': [{'path': 'test1.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
header = app.query_one(selector='Header')
|
||||
@@ -51,6 +62,7 @@ async def test_browse_app_key_toggles_logs_panel():
|
||||
'test1.yaml': {'repositories': [{'path': 'test1.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
logs_panel = app.query_one('#logs')
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
import asyncio
|
||||
|
||||
import borgmatic.actions.browse.app
|
||||
import borgmatic.actions.browse.carousel
|
||||
import borgmatic.actions.browse.logs
|
||||
import borgmatic.actions.browse.panels
|
||||
import borgmatic.actions.browse.workers
|
||||
|
||||
import pytest
|
||||
from flexmock import flexmock
|
||||
|
||||
import textual.widgets.option_list
|
||||
|
||||
|
||||
pytestmark = pytest.mark.asyncio(loop_scope="module")
|
||||
loop: asyncio.AbstractEventLoop
|
||||
|
||||
|
||||
async def test_carousel_previous_action_with_multiple_configs_does_not_raise():
|
||||
app = borgmatic.actions.browse.app.Browse_app(
|
||||
configs={
|
||||
@@ -15,6 +23,7 @@ async def test_carousel_previous_action_with_multiple_configs_does_not_raise():
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('left')
|
||||
@@ -26,6 +35,7 @@ async def test_carousel_previous_action_with_one_config_does_not_raise():
|
||||
'test1.yaml': {'repositories': [{'path': 'test1.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('left')
|
||||
@@ -38,6 +48,7 @@ async def test_carousel_next_action_with_multiple_configs_advances_panels():
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('enter')
|
||||
@@ -64,6 +75,7 @@ async def test_carousel_next_action_with_one_config_advances_to_next_panel():
|
||||
'test1.yaml': {'repositories': [{'path': 'test1.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
flexmock(borgmatic.actions.browse.workers).should_receive('add_repository_archives')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
@@ -92,6 +104,7 @@ async def test_carousel_next_action_and_previous_action_returns_to_original_pane
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('enter')
|
||||
@@ -120,6 +133,7 @@ async def test_carousel_next_action_and_previous_action_and_next_action_reuses_n
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
flexmock(borgmatic.actions.browse.carousel).should_call('make_next_panel').once()
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
@@ -150,6 +164,7 @@ async def test_carousel_next_action_with_no_next_panel_does_not_advance():
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
flexmock(borgmatic.actions.browse.carousel).should_receive('make_next_panel').and_return(None)
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
@@ -173,6 +188,7 @@ async def test_carousel_next_action_and_previous_action_and_down_truncates_next_
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('enter')
|
||||
@@ -197,6 +213,7 @@ async def test_carousel_down_does_not_raise():
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('down')
|
||||
@@ -219,6 +236,7 @@ async def test_carousel_up_does_not_raise():
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('down')
|
||||
@@ -241,6 +259,7 @@ async def test_carousel_next_action_and_select_dot_dot_returns_to_original_panel
|
||||
'test2.yaml': {'repositories': [{'path': 'test2.borg'}]},
|
||||
}
|
||||
)
|
||||
flexmock(borgmatic.actions.browse.logs).should_receive('log_to_widget')
|
||||
|
||||
async with app.run_test() as pilot:
|
||||
await pilot.press('enter')
|
||||
|
||||
@@ -57,6 +57,8 @@ def test_make_rename_command_includes_log_debug():
|
||||
|
||||
|
||||
def test_make_rename_command_includes_dry_run():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_rename_command(
|
||||
dry_run=True,
|
||||
repository_name='repo',
|
||||
@@ -79,6 +81,8 @@ def test_make_rename_command_includes_dry_run():
|
||||
|
||||
|
||||
def test_make_rename_command_includes_remote_path():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_rename_command(
|
||||
dry_run=False,
|
||||
repository_name='repo',
|
||||
@@ -102,6 +106,8 @@ def test_make_rename_command_includes_remote_path():
|
||||
|
||||
|
||||
def test_make_rename_command_includes_umask():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_rename_command(
|
||||
dry_run=False,
|
||||
repository_name='repo',
|
||||
@@ -125,6 +131,8 @@ def test_make_rename_command_includes_umask():
|
||||
|
||||
|
||||
def test_make_rename_command_includes_log_json():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_rename_command(
|
||||
dry_run=False,
|
||||
repository_name='repo',
|
||||
@@ -140,6 +148,8 @@ def test_make_rename_command_includes_log_json():
|
||||
|
||||
|
||||
def test_make_rename_command_includes_lock_wait():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_rename_command(
|
||||
dry_run=False,
|
||||
repository_name='repo',
|
||||
@@ -163,6 +173,8 @@ def test_make_rename_command_includes_lock_wait():
|
||||
|
||||
|
||||
def test_make_rename_command_includes_extra_borg_options():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_rename_command(
|
||||
dry_run=False,
|
||||
repository_name='repo',
|
||||
|
||||
@@ -22,6 +22,7 @@ def test_run_arbitrary_borg_calls_borg_with_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -99,6 +100,7 @@ def test_run_arbitrary_borg_with_lock_wait_calls_borg_with_lock_wait_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -123,6 +125,7 @@ def test_run_arbitrary_borg_with_archive_calls_borg_with_archive_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -148,6 +151,7 @@ def test_run_arbitrary_borg_with_local_path_calls_borg_via_local_path():
|
||||
borg_local_path='borg1',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -174,6 +178,7 @@ def test_run_arbitrary_borg_with_exit_codes_calls_borg_using_them():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -200,6 +205,7 @@ def test_run_arbitrary_borg_with_remote_path_calls_borg_with_remote_path_flags()
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -227,6 +233,7 @@ def test_run_arbitrary_borg_with_remote_path_injection_attack_gets_escaped():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -252,6 +259,7 @@ def test_run_arbitrary_borg_passes_borg_specific_flags_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -276,6 +284,7 @@ def test_run_arbitrary_borg_omits_dash_dash_in_flags_passed_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -300,6 +309,7 @@ def test_run_arbitrary_borg_without_borg_specific_flags_does_not_raise():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
@@ -376,6 +386,7 @@ def test_run_arbitrary_borg_calls_borg_with_working_directory():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -24,6 +24,7 @@ def insert_execute_command_mock(command, working_directory=None, borg_exit_codes
|
||||
def test_break_lock_calls_borg_with_required_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'break-lock', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -36,6 +37,7 @@ def test_break_lock_calls_borg_with_required_flags():
|
||||
def test_break_lock_calls_borg_with_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg1', 'break-lock', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -49,6 +51,7 @@ def test_break_lock_calls_borg_with_local_path():
|
||||
def test_break_lock_calls_borg_using_exit_codes():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg1', 'break-lock', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -64,6 +67,7 @@ def test_break_lock_calls_borg_with_remote_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'break-lock', '--remote-path', 'borg1', '--log-json', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -77,6 +81,7 @@ def test_break_lock_calls_borg_with_remote_path_flags():
|
||||
def test_break_lock_calls_borg_with_umask_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'break-lock', '--umask', '0770', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -89,6 +94,7 @@ def test_break_lock_calls_borg_with_umask_flags():
|
||||
def test_break_lock_calls_borg_with_lock_wait_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'break-lock', '--log-json', '--lock-wait', '5', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -103,6 +109,7 @@ def test_break_lock_calls_borg_with_extra_borg_options():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'break-lock', '--log-json', '--extra', 'value with space', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
@@ -145,6 +152,7 @@ def test_break_lock_calls_borg_with_working_directory():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'break-lock', '--log-json', 'repo'), working_directory='/working/dir'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.break_lock(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -35,6 +35,7 @@ def insert_execute_command_mock(
|
||||
def test_change_passphrase_calls_borg_with_required_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'key', 'change-passphrase', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -48,6 +49,7 @@ def test_change_passphrase_calls_borg_with_required_flags():
|
||||
def test_change_passphrase_calls_borg_with_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg1', 'key', 'change-passphrase', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -68,6 +70,7 @@ def test_change_passphrase_calls_borg_using_exit_codes():
|
||||
config=config,
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -83,6 +86,7 @@ def test_change_passphrase_calls_borg_with_remote_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'change-passphrase', '--remote-path', 'borg1', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -101,6 +105,7 @@ def test_change_passphrase_calls_borg_with_umask_flags():
|
||||
('borg', 'key', 'change-passphrase', '--umask', '0770', 'repo'),
|
||||
config=config,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -118,6 +123,7 @@ def test_change_passphrase_calls_borg_with_lock_wait_flags():
|
||||
('borg', 'key', 'change-passphrase', '--lock-wait', '5', 'repo'),
|
||||
config=config,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -135,6 +141,7 @@ def test_change_passphrase_calls_borg_with_extra_borg_options():
|
||||
('borg', 'key', 'change-passphrase', '--extra', 'value with space', 'repo'),
|
||||
config=config,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -179,6 +186,7 @@ def test_change_passphrase_with_dry_run_skips_borg_call():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').never()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -195,6 +203,7 @@ def test_change_passphrase_calls_borg_without_passphrase():
|
||||
('borg', 'key', 'change-passphrase', 'repo'),
|
||||
config={'option': 'foo'},
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
@@ -217,6 +226,7 @@ def test_change_passphrase_calls_borg_with_working_directory():
|
||||
config=config,
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.change_passphrase(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -337,6 +337,7 @@ def test_check_archives_with_progress_passes_through_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -373,6 +374,7 @@ def test_check_archives_with_log_json_and_progress_passes_through_both_to_borg()
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -409,6 +411,7 @@ def test_check_archives_with_repair_passes_through_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -445,6 +448,7 @@ def test_check_archives_with_log_json_and_repair_passes_through_both_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -481,6 +485,7 @@ def test_check_archives_with_max_duration_flag_passes_through_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -517,6 +522,7 @@ def test_check_archives_with_max_duration_option_passes_through_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -550,6 +556,7 @@ def test_check_archives_with_max_duration_option_and_archives_check_runs_reposit
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--max-duration', '33', '--repository-only', '--log-json', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -583,6 +590,7 @@ def test_check_archives_with_max_duration_flag_and_archives_check_runs_repositor
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--max-duration', '33', '--repository-only', '--log-json', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -619,6 +627,7 @@ def test_check_archives_with_max_duration_option_and_data_check_runs_repository_
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--max-duration', '33', '--repository-only', '--log-json', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -655,6 +664,7 @@ def test_check_archives_with_max_duration_flag_and_data_check_runs_repository_ch
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--max-duration', '33', '--repository-only', '--log-json', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -691,6 +701,7 @@ def test_check_archives_with_max_duration_flag_overrides_max_duration_option():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -724,6 +735,7 @@ def test_check_archives_calls_borg_with_parameters(checks):
|
||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'check', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -751,6 +763,7 @@ def test_check_archives_with_data_check_implies_archives_check_calls_borg_with_p
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'check', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -777,8 +790,8 @@ def test_check_archives_with_log_info_passes_through_to_borg():
|
||||
(),
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.INFO)
|
||||
insert_execute_command_mock(('borg', 'check', '--log-json', '--info', 'repo'))
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -805,8 +818,8 @@ def test_check_archives_with_log_debug_passes_through_to_borg():
|
||||
(),
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
insert_execute_command_mock(('borg', 'check', '--log-json', '--debug', '--show-rc', 'repo'))
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -832,6 +845,7 @@ def test_check_archives_with_local_path_calls_borg_via_local_path():
|
||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg1', 'check', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -861,6 +875,7 @@ def test_check_archives_with_exit_codes_calls_borg_using_them():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--log-json', 'repo'), borg_exit_codes=borg_exit_codes
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -886,6 +901,7 @@ def test_check_archives_with_remote_path_passes_through_to_borg():
|
||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'check', '--remote-path', 'borg1', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -912,6 +928,7 @@ def test_check_archives_with_umask_passes_through_to_borg():
|
||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'check', '--umask', '077', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -937,6 +954,7 @@ def test_check_archives_with_lock_wait_passes_through_to_borg():
|
||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'check', '--log-json', '--lock-wait', '5', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -963,6 +981,7 @@ def test_check_archives_with_retention_prefix():
|
||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'check', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -992,6 +1011,7 @@ def test_check_archives_with_extra_borg_options_passes_through_to_borg():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--log-json', '--extra', '--options', 'value with space', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -1028,6 +1048,7 @@ def test_check_archives_with_match_archives_passes_through_to_borg():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=[{'code': 1, 'treat_as': 'error'}],
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
@@ -1059,6 +1080,7 @@ def test_check_archives_calls_borg_with_working_directory():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'check', '--log-json', 'repo'), working_directory='/working/dir'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.check_archives(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -33,6 +33,7 @@ COMPACT_COMMAND = ('borg', 'compact')
|
||||
def test_compact_segments_calls_borg_with_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock((*COMPACT_COMMAND, '--log-json', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -83,6 +84,7 @@ def test_compact_segments_with_dry_run_skips_borg_call_when_feature_unavailable(
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').never()
|
||||
flexmock(module).should_receive('execute_command').never()
|
||||
flexmock(module.logger).should_receive('info').with_args('Skipping compact (dry run)').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
repository_path='repo',
|
||||
@@ -102,6 +104,7 @@ def test_compact_segments_with_dry_run_executes_borg_call_when_feature_available
|
||||
flexmock(module.environment).should_receive('make_environment').once()
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').once()
|
||||
flexmock(module).should_receive('execute_command').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
repository_path='repo',
|
||||
@@ -115,6 +118,7 @@ def test_compact_segments_with_dry_run_executes_borg_call_when_feature_available
|
||||
def test_compact_segments_with_local_path_calls_borg_via_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg1', *COMPACT_COMMAND[1:], '--log-json', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -134,6 +138,7 @@ def test_compact_segments_with_exit_codes_calls_borg_using_them():
|
||||
logging.INFO,
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -149,6 +154,7 @@ def test_compact_segments_with_remote_path_calls_borg_with_remote_path_flags():
|
||||
insert_execute_command_mock(
|
||||
(*COMPACT_COMMAND, '--remote-path', 'borg1', '--log-json', 'repo'), logging.INFO
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -163,6 +169,7 @@ def test_compact_segments_with_remote_path_calls_borg_with_remote_path_flags():
|
||||
def test_compact_segments_with_progress_calls_borg_with_progress_flag():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock((*COMPACT_COMMAND, '--progress', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -178,6 +185,7 @@ def test_compact_segments_with_log_json_and_progress_calls_borg_with_both_flags(
|
||||
insert_execute_command_mock(
|
||||
(*COMPACT_COMMAND, '--log-json', '--progress', 'repo'), logging.INFO
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -193,6 +201,7 @@ def test_compact_segments_with_cleanup_commits_calls_borg_with_cleanup_commits_f
|
||||
insert_execute_command_mock(
|
||||
(*COMPACT_COMMAND, '--log-json', '--cleanup-commits', 'repo'), logging.INFO
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -209,6 +218,7 @@ def test_compact_segments_with_threshold_calls_borg_with_threshold_flag():
|
||||
insert_execute_command_mock(
|
||||
(*COMPACT_COMMAND, '--log-json', '--threshold', '20', 'repo'), logging.INFO
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -225,6 +235,7 @@ def test_compact_segments_with_umask_calls_borg_with_umask_flags():
|
||||
insert_execute_command_mock(
|
||||
(*COMPACT_COMMAND, '--umask', '077', '--log-json', 'repo'), logging.INFO
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -241,6 +252,7 @@ def test_compact_segments_with_lock_wait_calls_borg_with_lock_wait_flags():
|
||||
insert_execute_command_mock(
|
||||
(*COMPACT_COMMAND, '--log-json', '--lock-wait', '5', 'repo'), logging.INFO
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -257,6 +269,7 @@ def test_compact_segments_with_extra_borg_options_calls_borg_with_extra_options(
|
||||
(*COMPACT_COMMAND, '--log-json', '--extra', '--options', 'value with space', 'repo'),
|
||||
logging.INFO,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
@@ -274,6 +287,7 @@ def test_compact_segments_calls_borg_with_working_directory():
|
||||
logging.INFO,
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
|
||||
@@ -1265,6 +1265,7 @@ def test_create_archive_calls_borg_with_flags():
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1299,6 +1300,7 @@ def test_create_archive_calls_borg_with_environment():
|
||||
working_directory=None,
|
||||
environment=environment,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1504,6 +1506,7 @@ def test_create_archive_with_working_directory_calls_borg_with_working_directory
|
||||
working_directory='/working/dir',
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1539,6 +1542,7 @@ def test_create_archive_with_exit_codes_calls_borg_using_them():
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1573,6 +1577,7 @@ def test_create_archive_with_stats_calls_borg_with_stats_flag_and_answer_output_
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1611,6 +1616,7 @@ def test_create_archive_with_files_calls_borg_with_answer_output_log_level():
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1680,6 +1686,7 @@ def test_create_archive_with_progress_calls_borg_with_progress_flag():
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1731,6 +1738,7 @@ def test_create_archive_with_progress_and_stream_processes_calls_borg_with_progr
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
).and_yield()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1764,6 +1772,7 @@ def test_create_archive_with_json_calls_borg_with_json_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield('[]')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
json_output = module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1798,6 +1807,7 @@ def test_create_archive_with_stats_and_json_calls_borg_without_stats_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield('[]')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
json_output = module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1834,6 +1844,7 @@ def test_create_archive_with_comment_calls_borg_with_comment_flag():
|
||||
working_directory=None,
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
@@ -1871,6 +1882,7 @@ def test_create_archive_calls_borg_with_working_directory():
|
||||
working_directory='/working/dir',
|
||||
environment=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
|
||||
@@ -9,13 +9,13 @@ from ..test_verbosity import insert_logging_mock
|
||||
|
||||
|
||||
def test_make_delete_command_includes_log_info():
|
||||
insert_logging_mock(logging.INFO)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -31,13 +31,13 @@ def test_make_delete_command_includes_log_info():
|
||||
|
||||
|
||||
def test_make_delete_command_includes_log_debug():
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -63,6 +63,7 @@ def test_make_delete_command_includes_dry_run():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -88,6 +89,7 @@ def test_make_delete_command_includes_remote_path():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -111,6 +113,7 @@ def test_make_delete_command_includes_umask():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -136,6 +139,7 @@ def test_make_delete_command_includes_lock_wait():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -157,6 +161,7 @@ def test_make_delete_command_includes_extra_borg_options():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -182,6 +187,7 @@ def test_make_delete_command_with_list_config_calls_borg_with_list_flag():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -203,6 +209,7 @@ def test_make_delete_command_includes_force():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -224,6 +231,7 @@ def test_make_delete_command_includes_force_twice():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -247,6 +255,7 @@ def test_make_delete_command_includes_archive():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -275,6 +284,7 @@ def test_make_delete_command_includes_match_archives():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_delete_command(
|
||||
repository={'path': 'repo'},
|
||||
@@ -307,6 +317,7 @@ def test_delete_archives_with_archive_calls_borg_delete():
|
||||
)
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.delete_archives(
|
||||
repository={'path': 'repo'},
|
||||
@@ -327,6 +338,7 @@ def test_delete_archives_with_match_archives_calls_borg_delete():
|
||||
)
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.delete_archives(
|
||||
repository={'path': 'repo'},
|
||||
@@ -348,6 +360,7 @@ def test_delete_archives_with_archive_related_argument_calls_borg_delete(argumen
|
||||
)
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.delete_archives(
|
||||
repository={'path': 'repo'},
|
||||
@@ -367,6 +380,7 @@ def test_delete_archives_without_archive_related_argument_calls_borg_repo_delete
|
||||
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').never()
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').never()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.delete_archives(
|
||||
repository={'path': 'repo'},
|
||||
@@ -403,6 +417,7 @@ def test_delete_archives_calls_borg_delete_with_working_directory():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.delete_archives(
|
||||
repository={'path': 'repo'},
|
||||
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
from flexmock import flexmock
|
||||
|
||||
from borgmatic.borg import diff as module
|
||||
from ..test_verbosity import insert_logging_mock
|
||||
|
||||
LOGGING_ANSWER = flexmock()
|
||||
|
||||
@@ -40,6 +41,7 @@ def test_diff_calls_borg_with_archives():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -94,6 +96,7 @@ def test_diff_with_local_path_calls_borg_with_it():
|
||||
borg_local_path='borg6',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -150,6 +153,7 @@ def test_diff_with_remote_path_calls_borg_with_it():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -206,6 +210,7 @@ def test_diff_with_lock_wait_calls_borg_with_it():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -262,6 +267,7 @@ def test_diff_with_log_level_info_calls_borg_with_info_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -319,6 +325,7 @@ def test_diff_with_log_level_debug_calls_borg_with_debug_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -376,6 +383,7 @@ def test_diff_with_only_patterns_calls_borg_with_configured_pattern_paths():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -434,6 +442,7 @@ def test_diff_with_exclude_config_calls_borg_with_exclude_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -489,6 +498,7 @@ def test_diff_with_numeric_ids_calls_borg_with_numeric_ids_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -549,6 +559,7 @@ def test_diff_with_numeric_ids_and_feature_not_available_calls_borg_with_numeric
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -604,6 +615,7 @@ def test_diff_with_same_chunker_params_calls_borg_with_it():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -660,6 +672,7 @@ def test_diff_with_sort_keys_calls_borg_with_formatted_sort_by_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -715,6 +728,7 @@ def test_diff_with_content_only_calls_borg_with_it():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -771,6 +785,7 @@ def test_diff_with_extra_borg_options_calls_borg_with_them():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
@@ -828,6 +843,7 @@ def test_diff_without_separate_repository_archive_feature_available_calls_borg_j
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
|
||||
@@ -36,6 +36,7 @@ def test_export_key_calls_borg_with_required_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -50,6 +51,7 @@ def test_export_key_calls_borg_with_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg1', 'key', 'export', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -66,6 +68,7 @@ def test_export_key_calls_borg_using_exit_codes():
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
borg_exit_codes = flexmock()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', 'repo'), borg_exit_codes=borg_exit_codes)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -80,6 +83,7 @@ def test_export_key_calls_borg_with_remote_path_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--remote-path', 'borg1', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -95,6 +99,7 @@ def test_export_key_calls_borg_with_umask_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--umask', '0770', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -109,6 +114,7 @@ def test_export_key_calls_borg_with_lock_wait_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--lock-wait', '5', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -123,6 +129,7 @@ def test_export_key_calls_borg_with_extra_borg_options():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--extra', 'value with space', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -167,6 +174,7 @@ def test_export_key_calls_borg_with_paper_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--paper', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -181,6 +189,7 @@ def test_export_key_calls_borg_with_paper_flag():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--paper', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -195,6 +204,7 @@ def test_export_key_calls_borg_with_qr_html_flag():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', '--qr-html', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -211,6 +221,7 @@ def test_export_key_calls_borg_with_path_argument():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'export', '--log-json', 'repo', 'dest'), output_file=None
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -240,6 +251,7 @@ def test_export_key_with_stdout_path_calls_borg_without_path_argument():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -268,6 +280,7 @@ def test_export_key_calls_borg_with_working_directory():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'export', 'repo'), working_directory='/working/dir')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
@@ -288,6 +301,7 @@ def test_export_key_calls_borg_with_path_argument_and_working_directory():
|
||||
output_file=None,
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_key(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -39,6 +39,7 @@ def test_export_tar_archive_calls_borg_with_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'export-tar', '--log-json', 'repo::archive', 'test.tar', 'path1', 'path2'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -62,6 +63,7 @@ def test_export_tar_archive_calls_borg_with_local_path_flags():
|
||||
('borg1', 'export-tar', '--log-json', 'repo::archive', 'test.tar'),
|
||||
borg_local_path='borg1',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -87,6 +89,7 @@ def test_export_tar_archive_calls_borg_using_exit_codes():
|
||||
('borg', 'export-tar', '--log-json', 'repo::archive', 'test.tar'),
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -109,6 +112,7 @@ def test_export_tar_archive_calls_borg_with_remote_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'export-tar', '--remote-path', 'borg1', '--log-json', 'repo::archive', 'test.tar'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -132,6 +136,7 @@ def test_export_tar_archive_calls_borg_with_umask_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'export-tar', '--umask', '0770', '--log-json', 'repo::archive', 'test.tar'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -154,6 +159,7 @@ def test_export_tar_archive_calls_borg_with_lock_wait_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'export-tar', '--log-json', '--lock-wait', '5', 'repo::archive', 'test.tar'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -184,6 +190,7 @@ def test_export_tar_archive_calls_borg_with_extra_borg_options():
|
||||
'test.tar',
|
||||
),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -272,6 +279,7 @@ def test_export_tar_archive_calls_borg_with_tar_filter_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'export-tar', '--log-json', '--tar-filter', 'bzip2', 'repo::archive', 'test.tar'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -296,6 +304,7 @@ def test_export_tar_archive_calls_borg_with_list_flag():
|
||||
('borg', 'export-tar', '--log-json', '--list', 'repo::archive', 'test.tar'),
|
||||
output_log_level=logging.ANSWER,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -326,6 +335,7 @@ def test_export_tar_archive_calls_borg_with_strip_components_flag():
|
||||
'test.tar',
|
||||
),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -349,6 +359,7 @@ def test_export_tar_archive_skips_abspath_for_remote_repository_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'export-tar', '--log-json', 'server:repo::archive', 'test.tar')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -369,6 +380,7 @@ def test_export_tar_archive_calls_borg_with_stdout_destination_path():
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'export-tar', 'repo::archive', '-'), capture=False)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
@@ -392,6 +404,7 @@ def test_export_tar_archive_calls_borg_with_working_directory():
|
||||
('borg', 'export-tar', '--log-json', 'repo::archive', 'test.tar'),
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
|
||||
@@ -25,6 +25,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_last_archive():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -38,6 +39,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_last_archive():
|
||||
def test_extract_last_archive_dry_run_without_any_archives_should_not_raise():
|
||||
flexmock(module.repo_list).should_receive('resolve_archive_name').and_raise(ValueError)
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -53,10 +55,10 @@ def test_extract_last_archive_dry_run_with_log_info_calls_borg_with_info_paramet
|
||||
insert_execute_command_mock(
|
||||
('borg', 'extract', '--dry-run', '--log-json', '--info', 'repo::archive')
|
||||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -81,10 +83,10 @@ def test_extract_last_archive_dry_run_with_log_debug_calls_borg_with_debug_param
|
||||
'repo::archive',
|
||||
),
|
||||
)
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -109,6 +111,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_progress_flag():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={'progress': True},
|
||||
@@ -125,6 +128,7 @@ def test_extract_last_archive_dry_run_calls_borg_via_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -146,6 +150,7 @@ def test_extract_last_archive_dry_run_calls_borg_using_exit_codes():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={'borg_exit_codes': borg_exit_codes},
|
||||
@@ -164,6 +169,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_remote_path_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -183,6 +189,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_lock_wait_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={},
|
||||
@@ -209,6 +216,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_extra_borg_options():
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={'extra_borg_options': {'extract': '--extra "value with space"'}},
|
||||
@@ -231,6 +239,7 @@ def test_extract_archive_calls_borg_with_path_flags():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -254,6 +263,7 @@ def test_extract_archive_calls_borg_with_local_path():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -282,6 +292,7 @@ def test_extract_archive_calls_borg_with_exit_codes():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -307,6 +318,7 @@ def test_extract_archive_calls_borg_with_remote_path_flags():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -338,6 +350,7 @@ def test_extract_archive_calls_borg_with_numeric_ids_parameter(feature_available
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -363,6 +376,7 @@ def test_extract_archive_calls_borg_with_umask_flags():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -388,6 +402,7 @@ def test_extract_archive_calls_borg_with_lock_wait_flags():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -413,6 +428,7 @@ def test_extract_archive_calls_borg_with_extra_borg_options():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -428,7 +444,6 @@ def test_extract_archive_calls_borg_with_extra_borg_options():
|
||||
def test_extract_archive_with_log_info_calls_borg_with_info_parameter():
|
||||
flexmock(module.os.path).should_receive('abspath').and_return('repo')
|
||||
insert_execute_command_mock(('borg', 'extract', '--log-json', '--info', 'repo::archive'))
|
||||
insert_logging_mock(logging.INFO)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
@@ -437,6 +452,7 @@ def test_extract_archive_with_log_info_calls_borg_with_info_parameter():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -454,7 +470,6 @@ def test_extract_archive_with_log_debug_calls_borg_with_debug_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'extract', '--log-json', '--debug', '--list', '--show-rc', 'repo::archive'),
|
||||
)
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
@@ -463,6 +478,7 @@ def test_extract_archive_with_log_debug_calls_borg_with_debug_flags():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -486,6 +502,7 @@ def test_extract_archive_calls_borg_with_dry_run_parameter():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=True,
|
||||
@@ -511,6 +528,7 @@ def test_extract_archive_calls_borg_with_destination_path():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -537,6 +555,7 @@ def test_extract_archive_calls_borg_with_strip_components():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -572,6 +591,7 @@ def test_extract_archive_calls_borg_with_strip_components_calculated_from_all():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -607,6 +627,7 @@ def test_extract_archive_calls_borg_with_strip_components_calculated_from_all_wi
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -631,6 +652,7 @@ def test_extract_archive_with_strip_components_all_and_no_paths_raises():
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
flexmock(module).should_receive('execute_command').never()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
module.extract_archive(
|
||||
@@ -665,6 +687,7 @@ def test_extract_archive_calls_borg_with_progress_flag():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -697,6 +720,7 @@ def test_extract_archive_with_log_json_and_progress_calls_borg_with_both_flags()
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -731,6 +755,7 @@ def test_extract_archive_calls_borg_with_extract_to_stdout_returns_process():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.extract_archive(
|
||||
@@ -769,6 +794,7 @@ def test_extract_archive_with_progress_and_extract_to_stdout_ignores_progress():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.extract_archive(
|
||||
@@ -804,6 +830,7 @@ def test_extract_archive_skips_abspath_for_remote_repository():
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).and_return('repo')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -829,6 +856,7 @@ def test_extract_archive_uses_configured_working_directory_in_repo_path_and_dest
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).with_args('repo', '/working/dir').and_return('/working/dir/repo').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
@@ -852,6 +880,7 @@ def test_extract_archive_uses_configured_working_directory_in_repo_path_when_des
|
||||
flexmock(module.borgmatic.config.validate).should_receive(
|
||||
'normalize_repository_path',
|
||||
).with_args('repo', '/working/dir').and_return('/working/dir/repo').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.extract_archive(
|
||||
dry_run=False,
|
||||
|
||||
@@ -32,6 +32,7 @@ def test_import_key_calls_borg_with_required_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'import', '--log-json', 'repo', '-'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -47,6 +48,7 @@ def test_import_key_calls_borg_with_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg1', 'key', 'import', '--log-json', 'repo', '-'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -66,6 +68,7 @@ def test_import_key_calls_borg_using_exit_codes():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--log-json', 'repo', '-'), borg_exit_codes=borg_exit_codes
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -83,6 +86,7 @@ def test_import_key_calls_borg_with_remote_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--remote-path', 'borg1', '--log-json', 'repo', '-')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -101,6 +105,7 @@ def test_import_key_calls_borg_with_umask_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--umask', '0770', '--log-json', 'repo', '-')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -118,6 +123,7 @@ def test_import_key_calls_borg_with_lock_wait_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--log-json', '--lock-wait', '5', 'repo', '-')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -135,6 +141,7 @@ def test_import_key_calls_borg_with_extra_borg_options():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--log-json', '--extra', 'value with space', 'repo', '-')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -184,6 +191,7 @@ def test_import_key_calls_borg_with_paper_flags():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'import', '--log-json', '--paper', 'repo', '-'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -201,6 +209,7 @@ def test_import_key_calls_borg_with_path_argument():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--log-json', 'repo', 'source'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -232,6 +241,7 @@ def test_import_key_with_stdin_path_calls_borg_without_path_argument():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.os.path).should_receive('exists').never()
|
||||
insert_execute_command_mock(('borg', 'key', 'import', '--log-json', 'repo', '-'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -264,6 +274,7 @@ def test_import_key_calls_borg_with_working_directory():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'key', 'import', '--log-json', 'repo', '-'), working_directory='/working/dir'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
@@ -284,6 +295,7 @@ def test_import_key_calls_borg_with_path_argument_and_working_directory():
|
||||
('borg', 'key', 'import', '--log-json', 'repo', 'source'),
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.import_key(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -17,6 +17,7 @@ def test_make_info_command_constructs_borg_info_command():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -112,6 +113,7 @@ def test_make_info_command_with_log_debug_and_json_omits_borg_logging_flags():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -135,6 +137,7 @@ def test_make_info_command_with_json_passes_through_to_command():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -158,6 +161,7 @@ def test_make_info_command_with_archive_uses_match_archives_flags():
|
||||
).and_return(('--match-archives', 'archive'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -189,6 +193,7 @@ def test_make_info_command_with_local_path_passes_through_to_command():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -216,6 +221,7 @@ def test_make_info_command_with_remote_path_passes_through_to_command():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -241,6 +247,7 @@ def test_make_info_command_with_umask_passes_through_to_command():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -268,6 +275,7 @@ def test_make_info_command_with_lock_wait_passes_through_to_command():
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
config = {'lock_wait': 5}
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -292,6 +300,7 @@ def test_make_info_command_with_extra_borg_options_passes_through_to_command():
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
config = {'extra_borg_options': {'info': '--extra "value with space"'}}
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -327,6 +336,7 @@ def test_make_info_command_transforms_prefix_into_match_archives_flags():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -362,6 +372,7 @@ def test_make_info_command_prefers_prefix_over_archive_name_format():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -393,6 +404,7 @@ def test_make_info_command_transforms_archive_name_format_into_match_archives_fl
|
||||
).and_return(('--match-archives', 'sh:bar-*'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -425,6 +437,7 @@ def test_make_info_command_with_match_archives_option_passes_through_to_command(
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -460,6 +473,7 @@ def test_make_info_command_with_match_archives_flag_passes_through_to_command():
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -496,6 +510,7 @@ def test_make_info_command_passes_arguments_through_to_command(argument_name):
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
@@ -537,6 +552,7 @@ def test_make_info_command_with_date_based_matching_passes_through_to_command():
|
||||
older='1m',
|
||||
oldest='1w',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_info_command(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -78,6 +78,7 @@ def test_make_list_command_includes_json_but_not_debug():
|
||||
|
||||
|
||||
def test_make_list_command_includes_json():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
@@ -94,6 +95,7 @@ def test_make_list_command_includes_json():
|
||||
|
||||
|
||||
def test_make_list_command_includes_lock_wait():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(()).and_return(
|
||||
('--lock-wait', '5'),
|
||||
).and_return(())
|
||||
@@ -112,6 +114,7 @@ def test_make_list_command_includes_lock_wait():
|
||||
|
||||
|
||||
def test_make_list_command_includes_format():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(()).and_return(
|
||||
()
|
||||
).and_return(('--format', 'stuff'))
|
||||
@@ -130,6 +133,7 @@ def test_make_list_command_includes_format():
|
||||
|
||||
|
||||
def test_make_list_command_includes_extra_borg_options():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
@@ -146,6 +150,7 @@ def test_make_list_command_includes_extra_borg_options():
|
||||
|
||||
|
||||
def test_make_list_command_includes_archive():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
@@ -164,6 +169,7 @@ def test_make_list_command_includes_archive():
|
||||
|
||||
|
||||
def test_make_list_command_includes_archive_and_path():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
@@ -182,6 +188,7 @@ def test_make_list_command_includes_archive_and_path():
|
||||
|
||||
|
||||
def test_make_list_command_includes_local_path():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
@@ -199,6 +206,7 @@ def test_make_list_command_includes_local_path():
|
||||
|
||||
|
||||
def test_make_list_command_includes_remote_path():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
||||
'remote-path',
|
||||
@@ -223,6 +231,7 @@ def test_make_list_command_includes_remote_path():
|
||||
|
||||
|
||||
def test_make_list_command_includes_umask():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').replace_with(
|
||||
lambda name, value: (f'--{name}', value) if value else (),
|
||||
)
|
||||
@@ -241,6 +250,7 @@ def test_make_list_command_includes_umask():
|
||||
|
||||
|
||||
def test_make_list_command_includes_short():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--short',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
@@ -271,6 +281,7 @@ def test_make_list_command_includes_short():
|
||||
),
|
||||
)
|
||||
def test_make_list_command_includes_additional_flags(argument_name):
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(
|
||||
(f"--{argument_name.replace('_', '-')}", 'value'),
|
||||
|
||||
@@ -25,6 +25,7 @@ def test_mount_archive_calls_borg_with_required_flags():
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_execute_command_mock(('borg', 'mount', '--log-json', 'repo', '/mnt'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -48,6 +49,7 @@ def test_mount_archive_with_borg_features_calls_borg_with_repository_and_match_a
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--log-json', '--repo', 'repo', '--match-archives', 'archive', '/mnt'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -66,6 +68,7 @@ def test_mount_archive_without_archive_calls_borg_with_repository_flags_only():
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'mount', '--log-json', 'repo::archive', '/mnt'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -86,6 +89,7 @@ def test_mount_archive_calls_borg_with_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--log-json', 'repo::archive', '/mnt', 'path1', 'path2')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(
|
||||
mount_point='/mnt',
|
||||
@@ -109,6 +113,7 @@ def test_mount_archive_calls_borg_with_local_path():
|
||||
('repo::archive',),
|
||||
)
|
||||
insert_execute_command_mock(('borg1', 'mount', '--log-json', 'repo::archive', '/mnt'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -132,6 +137,7 @@ def test_mount_archive_calls_borg_using_exit_codes():
|
||||
('borg', 'mount', '--log-json', 'repo::archive', '/mnt'),
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -152,6 +158,7 @@ def test_mount_archive_calls_borg_with_remote_path_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--remote-path', 'borg1', '--log-json', 'repo::archive', '/mnt'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -173,6 +180,7 @@ def test_mount_archive_calls_borg_with_umask_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--umask', '0770', '--log-json', 'repo::archive', '/mnt')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -193,6 +201,7 @@ def test_mount_archive_calls_borg_with_lock_wait_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--log-json', '--lock-wait', '5', 'repo::archive', '/mnt')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -213,6 +222,7 @@ def test_mount_archive_calls_borg_with_extra_borg_options():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--log-json', '--extra', 'value with space', 'repo::archive', '/mnt')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
@@ -280,6 +290,7 @@ def test_mount_archive_calls_borg_with_foreground_parameter():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=True)
|
||||
module.mount_archive(
|
||||
@@ -300,6 +311,7 @@ def test_mount_archive_calls_borg_with_options_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--log-json', '-o', 'super_mount', 'repo::archive', '/mnt')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(
|
||||
mount_point='/mnt',
|
||||
@@ -361,6 +373,7 @@ def test_mount_archive_with_date_based_matching_calls_borg_with_date_based_flags
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(
|
||||
mount_point='/mnt',
|
||||
@@ -388,6 +401,7 @@ def test_mount_archive_calls_borg_with_working_directory():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'mount', '--log-json', 'repo', '/mnt'), working_directory='/working/dir'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
||||
module.mount_archive(
|
||||
|
||||
@@ -244,6 +244,7 @@ def test_prune_archives_calls_borg_with_flags():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -312,6 +313,7 @@ def test_prune_archives_with_dry_run_calls_borg_with_dry_run_flag():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, '--dry-run', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -334,6 +336,7 @@ def test_prune_archives_with_local_path_calls_borg_via_local_path():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock(('borg1', *PRUNE_COMMAND[1:], 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -362,6 +365,7 @@ def test_prune_archives_with_exit_codes_calls_borg_using_them():
|
||||
logging.INFO,
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -384,6 +388,7 @@ def test_prune_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, '--remote-path', 'borg1', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -407,6 +412,7 @@ def test_prune_archives_with_stats_config_calls_borg_with_stats_flag():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, '--stats', 'repo'), module.borgmatic.logger.ANSWER)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=None, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -429,6 +435,7 @@ def test_prune_archives_with_list_config_calls_borg_with_list_flag():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, '--list', 'repo'), module.borgmatic.logger.ANSWER)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=None)
|
||||
module.prune_archives(
|
||||
@@ -452,6 +459,7 @@ def test_prune_archives_with_umask_calls_borg_with_umask_flags():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, '--umask', '077', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -475,6 +483,7 @@ def test_prune_archives_with_lock_wait_calls_borg_with_lock_wait_flags():
|
||||
'1.2.3',
|
||||
).and_return(False)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, '--lock-wait', '5', 'repo'), logging.INFO)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -500,6 +509,7 @@ def test_prune_archives_with_extra_borg_options_calls_borg_with_extra_options():
|
||||
(*PRUNE_COMMAND, '--extra', '--options', 'value with space', 'repo'),
|
||||
logging.INFO,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -569,6 +579,7 @@ def test_prune_archives_with_date_based_matching_calls_borg_with_date_based_flag
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(
|
||||
statistics=False,
|
||||
@@ -602,6 +613,7 @@ def test_prune_archives_calls_borg_with_working_directory():
|
||||
logging.INFO,
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
||||
module.prune_archives(
|
||||
@@ -624,6 +636,7 @@ def test_prune_archives_calls_borg_without_stats_when_feature_is_not_available()
|
||||
'2.0.0b10',
|
||||
).and_return(True)
|
||||
insert_execute_command_mock((*PRUNE_COMMAND, 'repo'), logging.ANSWER)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
prune_arguments = flexmock(statistics=True, list_details=False)
|
||||
module.prune_archives(
|
||||
|
||||
@@ -35,6 +35,7 @@ def test_recreate_calls_borg_with_required_flags():
|
||||
),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -70,6 +71,7 @@ def test_recreate_with_dry_run_calls_borg_with_dry_run_flag():
|
||||
),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', '--dry-run', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -107,6 +109,7 @@ def test_recreate_with_remote_path():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--remote-path', 'borg1', '--log-json', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -144,6 +147,7 @@ def test_recreate_with_lock_wait():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--lock-wait', '5', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -180,6 +184,7 @@ def test_recreate_with_extra_borg_options():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--extra', 'value with space', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -214,7 +219,6 @@ def test_recreate_with_log_info():
|
||||
),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', '--info', '--repo', 'repo'))
|
||||
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.recreate_archive(
|
||||
@@ -291,6 +295,7 @@ def test_recreate_with_list_config_calls_borg_with_list_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--list', '--filter', 'AME+-', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -328,6 +333,7 @@ def test_recreate_with_patterns_from_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--patterns-from', 'patterns_file', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -366,6 +372,7 @@ def test_recreate_with_exclude_flags():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--exclude', 'pattern', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -402,6 +409,7 @@ def test_recreate_with_target_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--target', 'new-archive', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -446,6 +454,7 @@ def test_recreate_with_comment_flag():
|
||||
'repo',
|
||||
),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -482,6 +491,7 @@ def test_recreate_with_timestamp_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--timestamp', '2023-10-01T12:00:00', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -518,6 +528,7 @@ def test_recreate_with_compression_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--compression', 'lz4', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -554,6 +565,7 @@ def test_recreate_with_chunker_params_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--chunker-params', '19,23,21,4095', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -590,6 +602,7 @@ def test_recreate_with_recompress_flag():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--recompress', 'always', '--repo', 'repo')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -624,6 +637,7 @@ def test_recreate_with_match_archives_star():
|
||||
),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -658,6 +672,7 @@ def test_recreate_with_match_archives_regex():
|
||||
),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -692,6 +707,7 @@ def test_recreate_with_match_archives_shell():
|
||||
),
|
||||
)
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -728,6 +744,7 @@ def test_recreate_with_match_archives_and_feature_available_calls_borg_with_matc
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--repo', 'repo', '--match-archives', 'foo-*')
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -764,6 +781,7 @@ def test_recreate_with_archives_flag_and_feature_available_calls_borg_with_match
|
||||
insert_execute_command_mock(
|
||||
('borg', 'recreate', '--log-json', '--repo', 'repo', '--match-archives', 'archive'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -794,6 +812,7 @@ def test_recreate_with_match_archives_and_feature_not_available_calls_borg_witho
|
||||
)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_archive_flags').never()
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
@@ -824,6 +843,7 @@ def test_recreate_with_archives_flags_and_feature_not_available_calls_borg_with_
|
||||
).and_return(('repo::archive',))
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').never()
|
||||
insert_execute_command_mock(('borg', 'recreate', '--log-json', 'repo::archive'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
|
||||
@@ -50,6 +50,7 @@ def insert_repo_create_command_mock(
|
||||
def test_create_repository_calls_borg_with_flags():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -177,6 +178,7 @@ def test_create_repository_with_source_repository_calls_borg_with_other_repo_fla
|
||||
insert_repo_create_command_mock(
|
||||
(*REPO_CREATE_COMMAND, '--other-repo', 'other.borg', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -199,6 +201,7 @@ def test_create_repository_with_source_repository_calls_borg_with_other_repo_fla
|
||||
def test_create_repository_with_copy_crypt_key_calls_borg_with_copy_crypt_key_flag():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--copy-crypt-key', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -221,6 +224,7 @@ def test_create_repository_with_copy_crypt_key_calls_borg_with_copy_crypt_key_fl
|
||||
def test_create_repository_with_append_only_calls_borg_with_append_only_flag():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--append-only', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -243,6 +247,7 @@ def test_create_repository_with_append_only_calls_borg_with_append_only_flag():
|
||||
def test_create_repository_with_append_only_config_calls_borg_with_append_only_flag():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--append-only', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -267,6 +272,7 @@ def test_create_repository_with_storage_quota_calls_borg_with_storage_quota_flag
|
||||
insert_repo_create_command_mock(
|
||||
(*REPO_CREATE_COMMAND, '--storage-quota', '5G', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -289,6 +295,7 @@ def test_create_repository_with_storage_quota_calls_borg_with_storage_quota_flag
|
||||
def test_create_repository_with_make_parent_dirs_calls_borg_with_make_parent_dirs_flag():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--make-parent-dirs', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -355,6 +362,7 @@ def test_create_repository_with_log_debug_calls_borg_with_debug_flag():
|
||||
def test_create_repository_with_lock_wait_calls_borg_with_lock_wait_flag():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--lock-wait', '5', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -376,6 +384,7 @@ def test_create_repository_with_lock_wait_calls_borg_with_lock_wait_flag():
|
||||
def test_create_repository_with_local_path_calls_borg_via_local_path():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock(('borg1', *REPO_CREATE_COMMAND[1:], '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -402,6 +411,7 @@ def test_create_repository_with_exit_codes_calls_borg_using_them():
|
||||
('borg', *REPO_CREATE_COMMAND[1:], '--repo', 'repo'),
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -425,6 +435,7 @@ def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
|
||||
insert_repo_create_command_mock(
|
||||
(*REPO_CREATE_COMMAND, '--remote-path', 'borg1', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -447,6 +458,7 @@ def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
|
||||
def test_create_repository_with_umask_calls_borg_with_umask_flag():
|
||||
insert_repo_info_command_not_found_mock()
|
||||
insert_repo_create_command_mock((*REPO_CREATE_COMMAND, '--umask', '077', '--repo', 'repo'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -470,6 +482,7 @@ def test_create_repository_calls_borg_with_extra_borg_options():
|
||||
insert_repo_create_command_mock(
|
||||
(*REPO_CREATE_COMMAND, '--extra', '--options', 'value with space', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -494,6 +507,7 @@ def test_create_repository_calls_borg_with_extra_borg_options_from_deprecated_in
|
||||
insert_repo_create_command_mock(
|
||||
(*REPO_CREATE_COMMAND, '--extra', '--options', 'value with space', '--repo', 'repo'),
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
@@ -518,6 +532,7 @@ def test_create_repository_calls_borg_with_working_directory():
|
||||
(*REPO_CREATE_COMMAND, '--repo', 'repo'),
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
||||
(
|
||||
|
||||
@@ -8,6 +8,7 @@ from ..test_verbosity import insert_logging_mock
|
||||
|
||||
|
||||
def test_make_repo_delete_command_with_feature_available_runs_borg_repo_delete():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
@@ -30,6 +31,7 @@ def test_make_repo_delete_command_with_feature_available_runs_borg_repo_delete()
|
||||
|
||||
|
||||
def test_make_repo_delete_command_without_feature_available_runs_borg_delete():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(False)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
@@ -98,6 +100,7 @@ def test_make_repo_delete_command_includes_log_debug():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_dry_run():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
||||
@@ -124,6 +127,7 @@ def test_make_repo_delete_command_includes_dry_run():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_remote_path():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
||||
@@ -150,6 +154,7 @@ def test_make_repo_delete_command_includes_remote_path():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_umask():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').replace_with(
|
||||
lambda name, value: (f'--{name}', value) if value else (),
|
||||
@@ -174,6 +179,7 @@ def test_make_repo_delete_command_includes_umask():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_lock_wait():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
||||
@@ -200,6 +206,7 @@ def test_make_repo_delete_command_includes_lock_wait():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_without_feature_available_includes_delete_extra_borg_options():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(False)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
@@ -222,6 +229,7 @@ def test_make_repo_delete_command_without_feature_available_includes_delete_extr
|
||||
|
||||
|
||||
def test_make_repo_delete_command_with_feature_available_includes_delete_extra_borg_options():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
@@ -244,6 +252,7 @@ def test_make_repo_delete_command_with_feature_available_includes_delete_extra_b
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_list():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
||||
@@ -270,6 +279,7 @@ def test_make_repo_delete_command_includes_list():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_force():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
@@ -292,6 +302,7 @@ def test_make_repo_delete_command_includes_force():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_includes_force_twice():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
@@ -314,6 +325,7 @@ def test_make_repo_delete_command_includes_force_twice():
|
||||
|
||||
|
||||
def test_make_repo_delete_command_with_output_file_omits_log_json():
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
|
||||
@@ -38,6 +38,7 @@ def test_display_repository_info_calls_borg_with_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -74,6 +75,7 @@ def test_display_repository_info_without_borg_features_calls_borg_with_info_sub_
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -116,6 +118,7 @@ def test_display_repository_info_with_log_info_calls_borg_with_info_flag():
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
config={},
|
||||
@@ -148,8 +151,8 @@ def test_display_repository_info_with_log_info_and_json_suppresses_most_borg_out
|
||||
borg_exit_codes=None,
|
||||
).and_yield('[]')
|
||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
||||
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
json_output = module.display_repository_info(
|
||||
repository_path='repo',
|
||||
config={},
|
||||
@@ -226,8 +229,8 @@ def test_display_repository_info_with_log_debug_and_json_suppresses_most_borg_ou
|
||||
borg_exit_codes=None,
|
||||
).and_yield('[]')
|
||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
||||
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
json_output = module.display_repository_info(
|
||||
repository_path='repo',
|
||||
config={},
|
||||
@@ -262,6 +265,7 @@ def test_display_repository_info_with_json_calls_borg_with_json_flag():
|
||||
borg_exit_codes=None,
|
||||
).and_yield('[]')
|
||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
json_output = module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -305,6 +309,7 @@ def test_display_repository_info_with_local_path_calls_borg_via_local_path():
|
||||
borg_local_path='borg1',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -348,6 +353,7 @@ def test_display_repository_info_with_exit_codes_calls_borg_using_them():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -389,6 +395,7 @@ def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_fl
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -431,6 +438,7 @@ def test_display_repository_info_with_umask_calls_borg_with_umask_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -467,6 +475,7 @@ def test_display_repository_info_with_lock_wait_calls_borg_with_lock_wait_flags(
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -509,6 +518,7 @@ def test_display_repository_info_without_feature_available_calls_borg_with_info_
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -561,6 +571,7 @@ def test_display_repository_info_with_feature_available_calls_borg_with_repo_inf
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
@@ -604,6 +615,7 @@ def test_display_repository_info_calls_borg_with_working_directory():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.display_repository_info(
|
||||
repository_path='repo',
|
||||
|
||||
@@ -126,6 +126,7 @@ def test_get_latest_archive_calls_borg_with_flags():
|
||||
environment=None,
|
||||
working_directory=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -218,6 +219,7 @@ def test_get_latest_archive_with_local_path_calls_borg_via_local_path():
|
||||
borg_local_path='borg1',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -250,6 +252,7 @@ def test_get_latest_archive_with_exit_codes_calls_borg_using_them():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -283,6 +286,7 @@ def test_get_latest_archive_with_remote_path_calls_borg_with_remote_path_flags()
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -317,6 +321,7 @@ def test_get_latest_archive_with_umask_calls_borg_with_umask_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -346,6 +351,7 @@ def test_get_latest_archive_without_archives_raises():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': []}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
module.get_latest_archive(
|
||||
@@ -377,6 +383,7 @@ def test_get_latest_archive_with_lock_wait_calls_borg_with_lock_wait_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -409,6 +416,7 @@ def test_get_latest_archive_with_match_archives_calls_borg_with_match_archives_f
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -447,6 +455,7 @@ def test_get_latest_archive_calls_borg_with_list_extra_borg_options():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -485,6 +494,7 @@ def test_get_latest_archive_with_feature_available_calls_borg_with_repo_list_ext
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -518,6 +528,7 @@ def test_get_latest_archive_with_consider_checkpoints_calls_borg_with_consider_c
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -552,6 +563,7 @@ def test_get_latest_archive_with_consider_checkpoints_and_feature_available_call
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -585,6 +597,7 @@ def test_get_latest_archive_calls_borg_with_working_directory():
|
||||
environment=None,
|
||||
working_directory='/working/dir',
|
||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
assert (
|
||||
module.get_latest_archive(
|
||||
@@ -758,6 +771,7 @@ def test_make_repo_list_command_includes_lock_wait():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -787,6 +801,7 @@ def test_make_repo_list_command_includes_list_extra_borg_options():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -816,6 +831,7 @@ def test_make_repo_list_command_with_feature_available_includes_repo_list_extra_
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -845,6 +861,7 @@ def test_make_repo_list_command_includes_local_path():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -877,6 +894,7 @@ def test_make_repo_list_command_includes_remote_path():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -909,6 +927,7 @@ def test_make_repo_list_command_includes_umask():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -940,6 +959,7 @@ def test_make_repo_list_command_transforms_prefix_into_match_archives():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -962,6 +982,7 @@ def test_make_repo_list_command_prefers_prefix_over_archive_name_format():
|
||||
flexmock(module.flags).should_receive('make_match_archives_flags').never()
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -986,6 +1007,7 @@ def test_make_repo_list_command_transforms_archive_name_format_into_match_archiv
|
||||
).and_return(('--match-archives', 'sh:bar-*'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -1017,6 +1039,7 @@ def test_make_repo_list_command_includes_format_from_command_line():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -1047,6 +1070,7 @@ def test_make_repo_list_command_includes_short():
|
||||
).and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--short',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -1091,6 +1115,7 @@ def test_make_repo_list_command_includes_additional_flags(argument_name):
|
||||
(f"--{argument_name.replace('_', '-')}", 'value'),
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -1134,6 +1159,7 @@ def test_make_repo_list_command_with_match_archives_calls_borg_with_match_archiv
|
||||
).and_return(('--match-archives', 'foo-*'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -1161,6 +1187,7 @@ def test_list_repository_calls_borg_command():
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module).should_receive('execute_command_and_capture_output').and_yield('').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
||||
|
||||
module.list_repository(
|
||||
@@ -1178,6 +1205,7 @@ def test_list_repository_with_json_calls_borg_json_command_only():
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
||||
flexmock(module).should_receive('execute_command_and_capture_output').and_yield('{}')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
||||
|
||||
assert (
|
||||
@@ -1204,6 +1232,7 @@ def test_make_repo_list_command_with_date_based_matching_calls_borg_with_date_ba
|
||||
('--newer', '1d', '--newest', '1y', '--older', '1m', '--oldest', '1w'),
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
command = module.make_repo_list_command(
|
||||
repository_path='repo',
|
||||
@@ -1256,6 +1285,7 @@ def test_list_repository_calls_borg_with_working_directory():
|
||||
borg_local_path=object,
|
||||
borg_exit_codes=object,
|
||||
).and_yield('').once()
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
||||
|
||||
module.list_repository(
|
||||
|
||||
@@ -26,6 +26,7 @@ def test_transfer_archives_calls_borg_with_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -63,6 +64,7 @@ def test_transfer_archives_with_dry_run_calls_borg_with_dry_run_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=True,
|
||||
@@ -98,6 +100,7 @@ def test_transfer_archives_with_log_info_calls_borg_with_info_flag():
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository_path='repo',
|
||||
@@ -170,6 +173,7 @@ def test_transfer_archives_with_archive_calls_borg_with_match_archives_flag():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -208,6 +212,7 @@ def test_transfer_archives_with_match_archives_calls_borg_with_match_archives_fl
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -246,6 +251,7 @@ def test_transfer_archives_with_archive_name_format_calls_borg_with_match_archiv
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -280,6 +286,7 @@ def test_transfer_archives_with_local_path_calls_borg_via_local_path():
|
||||
borg_local_path='borg2',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -316,6 +323,7 @@ def test_transfer_archives_with_exit_codes_calls_borg_using_them():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -354,6 +362,7 @@ def test_transfer_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -391,6 +400,7 @@ def test_transfer_archives_with_umask_calls_borg_with_umask_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -429,6 +439,7 @@ def test_transfer_archives_with_lock_wait_calls_borg_with_lock_wait_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -464,6 +475,7 @@ def test_transfer_archives_calls_borg_with_extra_borg_options():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -501,6 +513,7 @@ def test_transfer_archives_with_progress_calls_borg_with_progress_flags():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -538,6 +551,7 @@ def test_transfer_archives_with_log_json_and_progress_calls_borg_with_both_flags
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -576,6 +590,7 @@ def test_transfer_archives_passes_through_arguments_to_borg(argument_name):
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -613,6 +628,7 @@ def test_transfer_archives_with_source_repository_calls_borg_with_other_repo_fla
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -662,6 +678,7 @@ def test_transfer_archives_with_date_based_matching_calls_borg_with_date_based_f
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
@@ -701,6 +718,7 @@ def test_transfer_archives_calls_borg_with_working_directory():
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
|
||||
@@ -26,6 +26,7 @@ def insert_execute_command_mock(
|
||||
|
||||
def test_unmount_archive_calls_borg_with_required_parameters():
|
||||
insert_execute_command_mock(('borg', 'umount', '--log-json', '/mnt'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.unmount_archive(config={}, mount_point='/mnt')
|
||||
|
||||
@@ -49,6 +50,7 @@ def test_unmount_archive_calls_borg_with_extra_borg_options():
|
||||
('borg', 'umount', '--log-json', '--extra', 'value with space', '/mnt'),
|
||||
borg_local_path='borg',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.unmount_archive(
|
||||
config={'extra_borg_options': {'umount': '--extra "value with space"'}}, mount_point='/mnt'
|
||||
@@ -57,6 +59,7 @@ def test_unmount_archive_calls_borg_with_extra_borg_options():
|
||||
|
||||
def test_unmount_archive_calls_borg_with_local_path():
|
||||
insert_execute_command_mock(('borg1', 'umount', '--log-json', '/mnt'), borg_local_path='borg1')
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.unmount_archive(config={}, mount_point='/mnt', local_path='borg1')
|
||||
|
||||
@@ -66,6 +69,7 @@ def test_unmount_archive_calls_borg_with_exit_codes():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'umount', '--log-json', '/mnt'), borg_exit_codes=borg_exit_codes
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.unmount_archive(config={'borg_exit_codes': borg_exit_codes}, mount_point='/mnt')
|
||||
|
||||
@@ -74,5 +78,6 @@ def test_unmount_archive_calls_borg_with_working_directory():
|
||||
insert_execute_command_mock(
|
||||
('borg', 'umount', '--log-json', '/mnt'), working_directory='/working/dir'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
|
||||
module.unmount_archive(config={'working_directory': '/working/dir'}, mount_point='/mnt')
|
||||
|
||||
@@ -32,6 +32,7 @@ def insert_execute_command_and_capture_output_mock(
|
||||
|
||||
def test_local_borg_version_calls_borg_with_required_parameters():
|
||||
insert_execute_command_and_capture_output_mock(('borg', '--version', '--log-json'))
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
|
||||
assert module.local_borg_version({}) == VERSION
|
||||
@@ -59,6 +60,7 @@ def test_local_borg_version_with_local_borg_path_calls_borg_with_it():
|
||||
insert_execute_command_and_capture_output_mock(
|
||||
('borg1', '--version', '--log-json'), borg_local_path='borg1'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
|
||||
assert module.local_borg_version({}, 'borg1') == VERSION
|
||||
@@ -70,6 +72,7 @@ def test_local_borg_version_with_borg_exit_codes_calls_using_with_them():
|
||||
('borg', '--version', '--log-json'),
|
||||
borg_exit_codes=borg_exit_codes,
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
|
||||
assert module.local_borg_version({'borg_exit_codes': borg_exit_codes}) == VERSION
|
||||
@@ -79,6 +82,7 @@ def test_local_borg_version_with_invalid_version_raises():
|
||||
insert_execute_command_and_capture_output_mock(
|
||||
('borg', '--version', '--log-json'), version_output='wtf'
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
@@ -90,6 +94,7 @@ def test_local_borg_version_calls_borg_with_working_directory():
|
||||
('borg', '--version', '--log-json'),
|
||||
working_directory='/working/dir',
|
||||
)
|
||||
insert_logging_mock(logging.WARNING)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
|
||||
assert module.local_borg_version({'working_directory': '/working/dir'}) == VERSION
|
||||
|
||||
Reference in New Issue
Block a user