2022-08-12 23:59:03 +02:00
|
|
|
import logging
|
|
|
|
|
|
|
|
from flexmock import flexmock
|
|
|
|
|
|
|
|
from borgmatic.borg import rinfo as module
|
|
|
|
|
|
|
|
from ..test_verbosity import insert_logging_mock
|
|
|
|
|
|
|
|
|
2023-05-09 08:00:49 +02:00
|
|
|
def test_display_repository_info_calls_borg_with_flags():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--json', '--repo', 'repo'),
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
extra_environment=None,
|
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--repo', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_display_repository_info_without_borg_features_calls_borg_with_info_sub_command():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(False)
|
2022-08-14 07:07:15 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--json', 'repo'),
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
extra_environment=None,
|
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'info', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-05-09 08:00:49 +02:00
|
|
|
def test_display_repository_info_with_log_info_calls_borg_with_info_flag():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--info', '--json', '--repo', 'repo'),
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
extra_environment=None,
|
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--info', '--repo', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
insert_logging_mock(logging.INFO)
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_display_repository_info_with_log_info_and_json_suppresses_most_borg_output():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2022-10-15 01:19:26 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
2023-04-15 04:35:24 +02:00
|
|
|
('borg', 'rinfo', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
2023-07-10 20:16:18 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
).and_return('[]')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
2022-08-12 23:59:03 +02:00
|
|
|
|
|
|
|
insert_logging_mock(logging.INFO)
|
|
|
|
json_output = module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=True),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert json_output == '[]'
|
|
|
|
|
|
|
|
|
2023-05-09 08:00:49 +02:00
|
|
|
def test_display_repository_info_with_log_debug_calls_borg_with_debug_flag():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--debug', '--show-rc', '--json', '--repo', 'repo'),
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
extra_environment=None,
|
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--debug', '--show-rc', '--repo', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
insert_logging_mock(logging.DEBUG)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_display_repository_info_with_log_debug_and_json_suppresses_most_borg_output():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2022-10-15 01:19:26 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
2023-04-15 04:35:24 +02:00
|
|
|
('borg', 'rinfo', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
2023-07-10 20:16:18 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
).and_return('[]')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
2022-08-12 23:59:03 +02:00
|
|
|
|
|
|
|
insert_logging_mock(logging.DEBUG)
|
|
|
|
json_output = module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=True),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert json_output == '[]'
|
|
|
|
|
|
|
|
|
2023-05-09 08:00:49 +02:00
|
|
|
def test_display_repository_info_with_json_calls_borg_with_json_flag():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2022-10-15 01:19:26 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
2023-04-15 04:35:24 +02:00
|
|
|
('borg', 'rinfo', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
2023-07-10 20:16:18 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
).and_return('[]')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags').never()
|
2022-08-12 23:59:03 +02:00
|
|
|
|
|
|
|
json_output = module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=True),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
assert json_output == '[]'
|
|
|
|
|
|
|
|
|
|
|
|
def test_display_repository_info_with_local_path_calls_borg_via_local_path():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg1', 'rinfo', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg1', 'rinfo', '--repo', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg1',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
local_path='borg1',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2024-01-21 20:34:40 +01:00
|
|
|
def test_display_repository_info_with_exit_codes_calls_borg_using_them():
|
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
|
borg_exit_codes = flexmock()
|
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
|
|
|
borg_local_path='borg',
|
|
|
|
borg_exit_codes=borg_exit_codes,
|
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--repo', 'repo'),
|
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
|
|
|
borg_local_path='borg',
|
|
|
|
borg_exit_codes=borg_exit_codes,
|
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
|
|
|
repository_path='repo',
|
|
|
|
config={'borg_exit_codes': borg_exit_codes},
|
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
|
|
|
global_arguments=flexmock(log_json=False),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-05-09 08:00:49 +02:00
|
|
|
def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_flags():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--remote-path', 'borg1', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--remote-path', 'borg1', '--repo', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
remote_path='borg1',
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-05-09 08:00:49 +02:00
|
|
|
def test_display_repository_info_with_log_json_calls_borg_with_log_json_flags():
|
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--log-json', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2023-05-09 08:00:49 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--log-json', '--repo', 'repo'),
|
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-05-09 08:00:49 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config={},
|
2023-05-09 08:00:49 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
|
|
|
global_arguments=flexmock(log_json=True),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def test_display_repository_info_with_lock_wait_calls_borg_with_lock_wait_flags():
|
2022-12-02 21:12:10 +01:00
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
2023-07-09 08:14:30 +02:00
|
|
|
config = {'lock_wait': 5}
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.feature).should_receive('available').and_return(True)
|
2023-04-15 04:35:24 +02:00
|
|
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
|
|
(
|
|
|
|
'--repo',
|
|
|
|
'repo',
|
|
|
|
)
|
|
|
|
)
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
2023-10-27 07:12:13 +02:00
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
|
('borg', 'rinfo', '--lock-wait', '5', '--json', '--repo', 'repo'),
|
|
|
|
extra_environment=None,
|
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2023-10-27 07:12:13 +02:00
|
|
|
).and_return('[]')
|
|
|
|
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
2022-08-12 23:59:03 +02:00
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
('borg', 'rinfo', '--lock-wait', '5', '--repo', 'repo'),
|
2022-12-02 21:12:10 +01:00
|
|
|
output_log_level=module.borgmatic.logger.ANSWER,
|
2022-08-12 23:59:03 +02:00
|
|
|
borg_local_path='borg',
|
2024-01-21 20:34:40 +01:00
|
|
|
borg_exit_codes=None,
|
2022-08-12 23:59:03 +02:00
|
|
|
extra_environment=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
module.display_repository_info(
|
2023-03-26 20:22:25 +02:00
|
|
|
repository_path='repo',
|
2023-07-09 08:14:30 +02:00
|
|
|
config=config,
|
2022-08-12 23:59:03 +02:00
|
|
|
local_borg_version='2.3.4',
|
|
|
|
rinfo_arguments=flexmock(json=False),
|
2023-05-09 08:00:49 +02:00
|
|
|
global_arguments=flexmock(log_json=False),
|
2022-08-12 23:59:03 +02:00
|
|
|
)
|