remove optional label for repos from tests

This commit is contained in:
Divyansh Singh 2023-03-26 16:59:29 +05:30
parent d6dfb8753a
commit b511e679ae
7 changed files with 86 additions and 100 deletions

View file

@ -107,8 +107,7 @@ def run_configuration(config_filename, config, arguments):
while not repo_queue.empty(): while not repo_queue.empty():
repository, retry_num = repo_queue.get() repository, retry_num = repo_queue.get()
if isinstance(repository, str): logger.debug(f'{repository["path"]}: Running actions for repository')
repository = {'path': repository}
timeout = retry_num * retry_wait timeout = retry_num * retry_wait
if timeout: if timeout:
logger.warning(f'{config_filename}: Sleeping {timeout}s before next retry') logger.warning(f'{config_filename}: Sleeping {timeout}s before next retry')
@ -261,8 +260,6 @@ def run_actions(
invalid. invalid.
''' '''
add_custom_log_levels() add_custom_log_levels()
if isinstance(repository, str):
repository = {'path': repository}
repository_path = os.path.expanduser(repository['path']) repository_path = os.path.expanduser(repository['path'])
global_arguments = arguments['global'] global_arguments = arguments['global']
dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else '' dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''

View file

@ -80,17 +80,11 @@ def normalize(config_filename, config):
updated_repository_path = os.path.abspath( updated_repository_path = os.path.abspath(
repository_path.partition('file://')[-1] repository_path.partition('file://')[-1]
) )
config['location']['repositories'].append( config['location']['repositories'].append(
{ dict(repository_dict, path=updated_repository_path,)
'path': updated_repository_path,
'label': repository_dict.get('label', ''),
}
) )
elif repository_path.startswith('ssh://'): elif repository_path.startswith('ssh://'):
config['location']['repositories'].append( config['location']['repositories'].append(repository_dict)
{'path': repository_path, 'label': repository_dict.get('label', '')}
)
else: else:
rewritten_repository_path = f"ssh://{repository_path.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}" rewritten_repository_path = f"ssh://{repository_path.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}"
logs.append( logs.append(
@ -103,14 +97,9 @@ def normalize(config_filename, config):
) )
) )
config['location']['repositories'].append( config['location']['repositories'].append(
{ dict(repository_dict, path=rewritten_repository_path,)
'path': rewritten_repository_path,
'label': repository_dict.get('label', ''),
}
) )
else: else:
config['location']['repositories'].append( config['location']['repositories'].append(repository_dict)
{'path': repository_path, 'label': repository_dict.get('label', '')}
)
return logs return logs

View file

@ -53,7 +53,7 @@ properties:
type: string type: string
description: | description: |
Optional label for the repository. This Optional label for the repository. This
can be used with the --repository option can be used with the --repository flag
to select a repository to backup to. to select a repository to backup to.
If not specified, the repository path is If not specified, the repository path is
used as the label. used as the label.

View file

@ -138,7 +138,7 @@ def normalize_repository_path(repository):
def repositories_match(first, second): def repositories_match(first, second):
''' '''
Given two repository dicts with keys 'path' (relative and/or absolute), Given two repository dicts with keys 'path' (relative and/or absolute),
and 'label', return whether they match. and 'label', or two repository paths, return whether they match.
''' '''
if isinstance(first, str): if isinstance(first, str):
first = {'path': first, 'label': first} first = {'path': first, 'label': first}

View file

@ -65,7 +65,7 @@ def test_parse_configuration_transforms_file_into_mapping():
assert config == { assert config == {
'location': { 'location': {
'source_directories': ['/home', '/etc'], 'source_directories': ['/home', '/etc'],
'repositories': [{'path': 'hostname.borg', 'label': ''}], 'repositories': [{'path': 'hostname.borg'}],
}, },
'retention': {'keep_daily': 7, 'keep_hourly': 24, 'keep_minutely': 60}, 'retention': {'keep_daily': 7, 'keep_hourly': 24, 'keep_minutely': 60},
'consistency': {'checks': [{'name': 'repository'}, {'name': 'archives'}]}, 'consistency': {'checks': [{'name': 'repository'}, {'name': 'archives'}]},
@ -92,7 +92,7 @@ def test_parse_configuration_passes_through_quoted_punctuation():
assert config == { assert config == {
'location': { 'location': {
'source_directories': [f'/home/{string.punctuation}'], 'source_directories': [f'/home/{string.punctuation}'],
'repositories': [{'path': 'test.borg', 'label': ''}], 'repositories': [{'path': 'test.borg'}],
} }
} }
assert logs == [] assert logs == []
@ -154,10 +154,7 @@ def test_parse_configuration_inlines_include():
config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml') config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
assert config == { assert config == {
'location': { 'location': {'source_directories': ['/home'], 'repositories': [{'path': 'hostname.borg'}]},
'source_directories': ['/home'],
'repositories': [{'path': 'hostname.borg', 'label': ''}],
},
'retention': {'keep_daily': 7, 'keep_hourly': 24}, 'retention': {'keep_daily': 7, 'keep_hourly': 24},
} }
assert logs == [] assert logs == []
@ -191,10 +188,7 @@ def test_parse_configuration_merges_include():
config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml') config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
assert config == { assert config == {
'location': { 'location': {'source_directories': ['/home'], 'repositories': [{'path': 'hostname.borg'}]},
'source_directories': ['/home'],
'repositories': [{'path': 'hostname.borg', 'label': ''}],
},
'retention': {'keep_daily': 1, 'keep_hourly': 24}, 'retention': {'keep_daily': 1, 'keep_hourly': 24},
} }
assert logs == [] assert logs == []
@ -256,7 +250,7 @@ def test_parse_configuration_applies_overrides():
assert config == { assert config == {
'location': { 'location': {
'source_directories': ['/home'], 'source_directories': ['/home'],
'repositories': [{'path': 'hostname.borg', 'label': ''}], 'repositories': [{'path': 'hostname.borg'}],
'local_path': 'borg2', 'local_path': 'borg2',
} }
} }
@ -282,7 +276,7 @@ def test_parse_configuration_applies_normalization():
assert config == { assert config == {
'location': { 'location': {
'source_directories': ['/home'], 'source_directories': ['/home'],
'repositories': [{'path': 'hostname.borg', 'label': ''}], 'repositories': [{'path': 'hostname.borg'}],
'exclude_if_present': ['.nobackup'], 'exclude_if_present': ['.nobackup'],
} }
} }

View file

@ -15,7 +15,7 @@ def test_run_configuration_runs_actions_for_each_repository():
flexmock(module).should_receive('run_actions').and_return(expected_results[:1]).and_return( flexmock(module).should_receive('run_actions').and_return(expected_results[:1]).and_return(
expected_results[1:] expected_results[1:]
) )
config = {'location': {'repositories': ['foo', 'bar']}} config = {'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1)} arguments = {'global': flexmock(monitoring_verbosity=1)}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -75,7 +75,7 @@ def test_run_configuration_logs_actions_error():
expected_results = [flexmock()] expected_results = [flexmock()]
flexmock(module).should_receive('log_error_records').and_return(expected_results) flexmock(module).should_receive('log_error_records').and_return(expected_results)
flexmock(module).should_receive('run_actions').and_raise(OSError) flexmock(module).should_receive('run_actions').and_raise(OSError)
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -91,7 +91,7 @@ def test_run_configuration_bails_for_actions_soft_failure():
flexmock(module).should_receive('run_actions').and_raise(error) flexmock(module).should_receive('run_actions').and_raise(error)
flexmock(module).should_receive('log_error_records').never() flexmock(module).should_receive('log_error_records').never()
flexmock(module.command).should_receive('considered_soft_failure').and_return(True) flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -108,7 +108,7 @@ def test_run_configuration_logs_monitor_log_error():
expected_results = [flexmock()] expected_results = [flexmock()]
flexmock(module).should_receive('log_error_records').and_return(expected_results) flexmock(module).should_receive('log_error_records').and_return(expected_results)
flexmock(module).should_receive('run_actions').and_return([]) flexmock(module).should_receive('run_actions').and_return([])
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -126,7 +126,7 @@ def test_run_configuration_bails_for_monitor_log_soft_failure():
flexmock(module).should_receive('log_error_records').never() flexmock(module).should_receive('log_error_records').never()
flexmock(module).should_receive('run_actions').and_return([]) flexmock(module).should_receive('run_actions').and_return([])
flexmock(module.command).should_receive('considered_soft_failure').and_return(True) flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -143,7 +143,7 @@ def test_run_configuration_logs_monitor_finish_error():
expected_results = [flexmock()] expected_results = [flexmock()]
flexmock(module).should_receive('log_error_records').and_return(expected_results) flexmock(module).should_receive('log_error_records').and_return(expected_results)
flexmock(module).should_receive('run_actions').and_return([]) flexmock(module).should_receive('run_actions').and_return([])
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -161,7 +161,7 @@ def test_run_configuration_bails_for_monitor_finish_soft_failure():
flexmock(module).should_receive('log_error_records').never() flexmock(module).should_receive('log_error_records').never()
flexmock(module).should_receive('run_actions').and_return([]) flexmock(module).should_receive('run_actions').and_return([])
flexmock(module.command).should_receive('considered_soft_failure').and_return(True) flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -178,7 +178,7 @@ def test_run_configuration_logs_on_error_hook_error():
expected_results[:1] expected_results[:1]
).and_return(expected_results[1:]) ).and_return(expected_results[1:])
flexmock(module).should_receive('run_actions').and_raise(OSError) flexmock(module).should_receive('run_actions').and_raise(OSError)
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -194,7 +194,7 @@ def test_run_configuration_bails_for_on_error_hook_soft_failure():
expected_results = [flexmock()] expected_results = [flexmock()]
flexmock(module).should_receive('log_error_records').and_return(expected_results) flexmock(module).should_receive('log_error_records').and_return(expected_results)
flexmock(module).should_receive('run_actions').and_raise(OSError) flexmock(module).should_receive('run_actions').and_raise(OSError)
config = {'location': {'repositories': ['foo']}} config = {'location': {'repositories': [{'path': 'foo'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
@ -209,7 +209,7 @@ def test_run_configuration_retries_soft_error():
flexmock(module.command).should_receive('execute_hook') flexmock(module.command).should_receive('execute_hook')
flexmock(module).should_receive('run_actions').and_raise(OSError).and_return([]) flexmock(module).should_receive('run_actions').and_raise(OSError).and_return([])
flexmock(module).should_receive('log_error_records').and_return([flexmock()]).once() flexmock(module).should_receive('log_error_records').and_return([flexmock()]).once()
config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 1}} config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
assert results == [] assert results == []
@ -231,7 +231,7 @@ def test_run_configuration_retries_hard_error():
flexmock(module).should_receive('log_error_records').with_args( flexmock(module).should_receive('log_error_records').with_args(
'foo: Error running actions for repository', OSError, 'foo: Error running actions for repository', OSError,
).and_return(error_logs) ).and_return(error_logs)
config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 1}} config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
assert results == error_logs assert results == error_logs
@ -249,41 +249,41 @@ def test_run_configuration_repos_ordered():
flexmock(module).should_receive('log_error_records').with_args( flexmock(module).should_receive('log_error_records').with_args(
'bar: Error running actions for repository', OSError 'bar: Error running actions for repository', OSError
).and_return(expected_results[1:]).ordered() ).and_return(expected_results[1:]).ordered()
config = {'location': {'repositories': ['foo', 'bar']}} config = {'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
assert results == expected_results assert results == expected_results
def test_run_configuration_retries_round_robbin(): # def test_run_configuration_retries_round_robin():
flexmock(module).should_receive('verbosity_to_log_level').and_return(logging.INFO) # flexmock(module).should_receive('verbosity_to_log_level').and_return(logging.INFO)
flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock()) # flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock())
flexmock(module.command).should_receive('execute_hook') # flexmock(module.command).should_receive('execute_hook')
flexmock(module).should_receive('run_actions').and_raise(OSError).times(4) # flexmock(module).should_receive('run_actions').and_raise(OSError).times(4)
flexmock(module).should_receive('log_error_records').with_args( # flexmock(module).should_receive('log_error_records').with_args(
'foo: Error running actions for repository', # 'foo: Error running actions for repository',
OSError, # OSError,
levelno=logging.WARNING, # levelno=logging.WARNING,
log_command_error_output=True, # log_command_error_output=True,
).and_return([flexmock()]).ordered() # ).and_return([flexmock()]).ordered()
flexmock(module).should_receive('log_error_records').with_args( # flexmock(module).should_receive('log_error_records').with_args(
'bar: Error running actions for repository', # 'bar: Error running actions for repository',
OSError, # OSError,
levelno=logging.WARNING, # levelno=logging.WARNING,
log_command_error_output=True, # log_command_error_output=True,
).and_return([flexmock()]).ordered() # ).and_return([flexmock()]).ordered()
foo_error_logs = [flexmock()] # foo_error_logs = [flexmock()]
flexmock(module).should_receive('log_error_records').with_args( # flexmock(module).should_receive('log_error_records').with_args(
'foo: Error running actions for repository', OSError # 'foo: Error running actions for repository', OSError
).and_return(foo_error_logs).ordered() # ).and_return(foo_error_logs).ordered()
bar_error_logs = [flexmock()] # bar_error_logs = [flexmock()]
flexmock(module).should_receive('log_error_records').with_args( # flexmock(module).should_receive('log_error_records').with_args(
'bar: Error running actions for repository', OSError # 'bar: Error running actions for repository', OSError
).and_return(bar_error_logs).ordered() # ).and_return(bar_error_logs).ordered()
config = {'location': {'repositories': ['foo', 'bar']}, 'storage': {'retries': 1}} # config = {'location': {'repositories': [{'path':'foo','path':'bar'}]}, 'storage': {'retries': 1}}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} # arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) # results = list(module.run_configuration('test.yaml', config, arguments))
assert results == foo_error_logs + bar_error_logs # assert results == foo_error_logs + bar_error_logs
def test_run_configuration_retries_one_passes(): def test_run_configuration_retries_one_passes():
@ -309,7 +309,10 @@ def test_run_configuration_retries_one_passes():
flexmock(module).should_receive('log_error_records').with_args( flexmock(module).should_receive('log_error_records').with_args(
'bar: Error running actions for repository', OSError 'bar: Error running actions for repository', OSError
).and_return(error_logs).ordered() ).and_return(error_logs).ordered()
config = {'location': {'repositories': ['foo', 'bar']}, 'storage': {'retries': 1}} config = {
'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
'storage': {'retries': 1},
}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
assert results == error_logs assert results == error_logs
@ -348,7 +351,10 @@ def test_run_configuration_retry_wait():
flexmock(module).should_receive('log_error_records').with_args( flexmock(module).should_receive('log_error_records').with_args(
'foo: Error running actions for repository', OSError 'foo: Error running actions for repository', OSError
).and_return(error_logs).ordered() ).and_return(error_logs).ordered()
config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 3, 'retry_wait': 10}} config = {
'location': {'repositories': [{'path': 'foo'}]},
'storage': {'retries': 3, 'retry_wait': 10},
}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
results = list(module.run_configuration('test.yaml', config, arguments)) results = list(module.run_configuration('test.yaml', config, arguments))
assert results == error_logs assert results == error_logs
@ -384,7 +390,7 @@ def test_run_configuration_retries_timeout_multiple_repos():
'bar: Error running actions for repository', OSError 'bar: Error running actions for repository', OSError
).and_return(error_logs).ordered() ).and_return(error_logs).ordered()
config = { config = {
'location': {'repositories': ['foo', 'bar']}, 'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
'storage': {'retries': 1, 'retry_wait': 10}, 'storage': {'retries': 1, 'retry_wait': 10},
} }
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()} arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
@ -409,7 +415,7 @@ def test_run_actions_runs_rcreate():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -431,7 +437,7 @@ def test_run_actions_runs_transfer():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -454,7 +460,7 @@ def test_run_actions_runs_create():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
assert result == (expected,) assert result == (expected,)
@ -477,7 +483,7 @@ def test_run_actions_runs_prune():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -499,7 +505,7 @@ def test_run_actions_runs_compact():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -522,7 +528,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -545,7 +551,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -567,7 +573,7 @@ def test_run_actions_runs_extract():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -589,7 +595,7 @@ def test_run_actions_runs_export_tar():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -611,7 +617,7 @@ def test_run_actions_runs_mount():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -633,7 +639,7 @@ def test_run_actions_runs_restore():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -656,7 +662,7 @@ def test_run_actions_runs_rlist():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
assert result == (expected,) assert result == (expected,)
@ -680,7 +686,7 @@ def test_run_actions_runs_list():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
assert result == (expected,) assert result == (expected,)
@ -704,7 +710,7 @@ def test_run_actions_runs_rinfo():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
assert result == (expected,) assert result == (expected,)
@ -728,7 +734,7 @@ def test_run_actions_runs_info():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
assert result == (expected,) assert result == (expected,)
@ -751,7 +757,7 @@ def test_run_actions_runs_break_lock():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -773,7 +779,7 @@ def test_run_actions_runs_borg():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )
@ -800,7 +806,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
local_path=flexmock(), local_path=flexmock(),
remote_path=flexmock(), remote_path=flexmock(),
local_borg_version=flexmock(), local_borg_version=flexmock(),
repository='repo', repository={'path': 'repo'},
) )
) )

View file

@ -69,27 +69,27 @@ from borgmatic.config import normalize as module
), ),
( (
{'location': {'repositories': ['foo@bar:/repo']}}, {'location': {'repositories': ['foo@bar:/repo']}},
{'location': {'repositories': [{'path': 'ssh://foo@bar/repo', 'label': ''}]}}, {'location': {'repositories': [{'path': 'ssh://foo@bar/repo'}]}},
True, True,
), ),
( (
{'location': {'repositories': ['foo@bar:repo']}}, {'location': {'repositories': ['foo@bar:repo']}},
{'location': {'repositories': [{'path': 'ssh://foo@bar/./repo', 'label': ''}]}}, {'location': {'repositories': [{'path': 'ssh://foo@bar/./repo'}]}},
True, True,
), ),
( (
{'location': {'repositories': ['foo@bar:~/repo']}}, {'location': {'repositories': ['foo@bar:~/repo']}},
{'location': {'repositories': [{'path': 'ssh://foo@bar/~/repo', 'label': ''}]}}, {'location': {'repositories': [{'path': 'ssh://foo@bar/~/repo'}]}},
True, True,
), ),
( (
{'location': {'repositories': ['ssh://foo@bar:1234/repo']}}, {'location': {'repositories': ['ssh://foo@bar:1234/repo']}},
{'location': {'repositories': [{'path': 'ssh://foo@bar:1234/repo', 'label': ''}]}}, {'location': {'repositories': [{'path': 'ssh://foo@bar:1234/repo'}]}},
False, False,
), ),
( (
{'location': {'repositories': ['file:///repo']}}, {'location': {'repositories': ['file:///repo']}},
{'location': {'repositories': [{'path': '/repo', 'label': ''}]}}, {'location': {'repositories': [{'path': '/repo'}]}},
False, False,
), ),
), ),