Add configuration options for logging and verbosity (#793).

This commit is contained in:
Dan Helfman
2025-04-04 10:11:00 -07:00
parent 828ada085b
commit 49839e884a
47 changed files with 720 additions and 748 deletions
+4 -2
View File
@@ -1,7 +1,7 @@
2.0.0.dev0
* TL;DR: More flexible, completely revamped command hooks. All config options settable on the
command-line. Config option defaults for many command-line flags. New "key import" and "recreate"
actions. Almost everything is backwards compatible.
command-line. Config option defaults for many command-line flags (including verbosity!). New "key
import" and "recreate" actions. Almost everything is backwards compatible.
* #262: Add a "default_actions" option that supports disabling default actions when borgmatic is
run without any command-line arguments.
* #303: Deprecate the "--override" flag in favor of direct command-line flags for every borgmatic
@@ -23,6 +23,8 @@
preparation commands—even when something goes wrong.
* #790: BREAKING: Run all command hooks (both new and deprecated) respecting the
"working_directory" option if configured, meaning that hook commands are run in that directory.
* #793: Add configuration options for all verbosity and logging flags, so you don't have to set
verbosity on the command-line.
* #836: Add a custom command option for the SQLite hook.
* #837: Add custom command options for the MongoDB hook.
* #1010: When using Borg 2, don't pass the "--stats" flag to "borg prune".
+1 -1
View File
@@ -27,7 +27,7 @@ def break_lock(
(local_path, 'break-lock')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -30,7 +30,7 @@ def change_passphrase(
(local_path, 'key', 'change-passphrase')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -167,7 +167,7 @@ def check_archives(
+ make_check_name_flags(checks_subset, archive_filter_flags)
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ verbosity_flags
+ (('--progress',) if config.get('progress') else ())
+1 -1
View File
@@ -30,7 +30,7 @@ def compact_segments(
(local_path, 'compact')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--progress',) if config.get('progress') else ())
+ (('--cleanup-commits',) if cleanup_commits else ())
+1 -1
View File
@@ -287,7 +287,7 @@ def make_base_create_command(
+ (('--files-cache', files_cache) if files_cache else ())
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (
('--list', '--filter', list_filter_flags)
+1 -1
View File
@@ -32,7 +32,7 @@ def make_delete_command(
+ borgmatic.borg.flags.make_flags('dry-run', global_arguments.dry_run)
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
+ borgmatic.borg.flags.make_flags('log-json', global_arguments.log_json)
+ borgmatic.borg.flags.make_flags('log-json', config.get('log_json'))
+ borgmatic.borg.flags.make_flags('lock-wait', config.get('lock_wait'))
+ borgmatic.borg.flags.make_flags('list', config.get('list_details'))
+ (
+1 -1
View File
@@ -46,7 +46,7 @@ def export_key(
(local_path, 'key', 'export')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -39,7 +39,7 @@ def export_tar_archive(
(local_path, 'export-tar')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--list',) if config.get('list_details') else ())
+2 -2
View File
@@ -47,7 +47,7 @@ def extract_last_archive_dry_run(
full_extract_command = (
(local_path, 'extract', '--dry-run')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ verbosity_flags
+ list_flag
@@ -121,7 +121,7 @@ def extract_archive(
+ (('--remote-path', remote_path) if remote_path else ())
+ numeric_ids_flags
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--list', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -43,7 +43,7 @@ def import_key(
(local_path, 'key', 'import')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -37,7 +37,7 @@ def make_info_command(
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('umask', config.get('umask'))
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('log-json', config.get('log_json'))
+ flags.make_flags('lock-wait', config.get('lock_wait'))
+ (
(
+1 -1
View File
@@ -48,7 +48,7 @@ def make_list_command(
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('umask', config.get('umask'))
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('log-json', config.get('log_json'))
+ flags.make_flags('lock-wait', config.get('lock_wait'))
+ flags.make_flags_from_arguments(list_arguments, excludes=MAKE_FLAGS_EXCLUDES)
+ (
+1 -1
View File
@@ -30,7 +30,7 @@ def mount_archive(
(local_path, 'mount')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -73,7 +73,7 @@ def prune_archives(
+ make_prune_flags(config, prune_arguments, local_borg_version)
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (
('--stats',)
+1 -1
View File
@@ -43,7 +43,7 @@ def recreate_archive(
recreate_command = (
(local_path, 'recreate')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait is not None else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+1 -1
View File
@@ -82,7 +82,7 @@ def create_repository(
+ (('--make-parent-dirs',) if make_parent_directories else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug',) if logger.isEnabledFor(logging.DEBUG) else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--log-json',) if config.get('log_json') else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+1 -1
View File
@@ -37,7 +37,7 @@ def make_repo_delete_command(
+ borgmatic.borg.flags.make_flags('dry-run', global_arguments.dry_run)
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
+ borgmatic.borg.flags.make_flags('log-json', global_arguments.log_json)
+ borgmatic.borg.flags.make_flags('log-json', config.get('log_json'))
+ borgmatic.borg.flags.make_flags('lock-wait', config.get('lock_wait'))
+ borgmatic.borg.flags.make_flags('list', config.get('list_details'))
+ (
+1 -1
View File
@@ -44,7 +44,7 @@ def display_repository_info(
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('umask', config.get('umask'))
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('log-json', config.get('log_json'))
+ flags.make_flags('lock-wait', lock_wait)
+ (('--json',) if repo_info_arguments.json else ())
+ flags.make_repository_flags(repository_path, local_borg_version)
+2 -2
View File
@@ -40,7 +40,7 @@ def resolve_archive_name(
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('umask', config.get('umask'))
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('log-json', config.get('log_json'))
+ flags.make_flags('lock-wait', config.get('lock_wait'))
+ flags.make_flags('last', 1)
+ ('--short',)
@@ -102,7 +102,7 @@ def make_repo_list_command(
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('umask', config.get('umask'))
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('log-json', config.get('log_json'))
+ flags.make_flags('lock-wait', config.get('lock_wait'))
+ (
(
+1 -1
View File
@@ -31,7 +31,7 @@ def transfer_archives(
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('umask', config.get('umask'))
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('log-json', config.get('log_json'))
+ flags.make_flags('lock-wait', config.get('lock_wait'))
+ flags.make_flags('progress', config.get('progress'))
+ (
+9 -45
View File
@@ -526,6 +526,14 @@ def add_arguments_from_schema(arguments_group, schema, unparsed_arguments, names
default=None,
help=f'Set the --{flag_name} value to false.',
)
elif flag_name == 'verbosity':
arguments_group.add_argument(
'-v',
'--verbosity',
type=argument_type,
metavar=metavar,
help=description,
)
else:
arguments_group.add_argument(
f'--{flag_name}',
@@ -568,56 +576,12 @@ def make_parsers(schema, unparsed_arguments):
action='store_true',
help='Go through the motions, but do not actually write to any repositories',
)
global_group.add_argument(
'-v',
'--verbosity',
type=int,
choices=range(-2, 3),
default=0,
help='Display verbose progress to the console: -2 (disabled), -1 (errors only), 0 (responses to actions, the default), 1 (info about steps borgmatic is taking), or 2 (debug)',
)
global_group.add_argument(
'--syslog-verbosity',
type=int,
choices=range(-2, 3),
default=-2,
help='Log verbose progress to syslog: -2 (disabled, the default), -1 (errors only), 0 (responses to actions), 1 (info about steps borgmatic is taking), or 2 (debug)',
)
global_group.add_argument(
'--log-file-verbosity',
type=int,
choices=range(-2, 3),
default=1,
help='When --log-file is given, log verbose progress to file: -2 (disabled), -1 (errors only), 0 (responses to actions), 1 (info about steps borgmatic is taking, the default), or 2 (debug)',
)
global_group.add_argument(
'--monitoring-verbosity',
type=int,
choices=range(-2, 3),
default=1,
help='When a monitoring integration supporting logging is configured, log verbose progress to it: -2 (disabled), -1 (errors only), responses to actions (0), 1 (info about steps borgmatic is taking, the default), or 2 (debug)',
)
global_group.add_argument(
'--log-file',
type=str,
help='Write log messages to this file instead of syslog',
)
global_group.add_argument(
'--log-file-format',
type=str,
help='Python format string used for log messages written to the log file',
)
global_group.add_argument(
'--log-json',
action='store_true',
help='Write Borg log messages and console output as one JSON object per log line instead of formatted text',
)
global_group.add_argument(
'--override',
metavar='OPTION.SUBOPTION=VALUE',
dest='overrides',
action='append',
help='Configuration file option to override with specified value, see documentation for overriding list or key/value options, can specify flag multiple times',
help='Deprecated. Configuration file option to override with specified value, see documentation for overriding list or key/value options, can specify flag multiple times',
)
global_group.add_argument(
'--no-environment-interpolation',
+53 -22
View File
@@ -54,7 +54,7 @@ from borgmatic.logger import (
should_do_markup,
)
from borgmatic.signals import configure_signals
from borgmatic.verbosity import verbosity_to_log_level
from borgmatic.verbosity import get_verbosity, verbosity_to_log_level
logger = logging.getLogger(__name__)
@@ -217,7 +217,7 @@ def run_configuration(config_filename, config, config_paths, arguments):
dry_run=global_arguments.dry_run,
action_names=arguments.keys(),
configuration_filename=config_filename,
log_file=arguments['global'].log_file or '',
log_file=config.get('log_file', ''),
):
try:
local_borg_version = borg_version.local_borg_version(config, local_path)
@@ -296,7 +296,7 @@ def run_configuration(config_filename, config, config_paths, arguments):
borgmatic.config.paths.get_working_directory(config),
global_arguments.dry_run,
configuration_filename=config_filename,
log_file=arguments['global'].log_file or '',
log_file=config.get('log_file', ''),
repository=error_repository.get('path', '') if error_repository else '',
repository_label=error_repository.get('label', '') if error_repository else '',
error=encountered_error,
@@ -339,7 +339,7 @@ def run_actions(
hook_context = {
'configuration_filename': config_filename,
'repository_label': repository.get('label', ''),
'log_file': global_arguments.log_file if global_arguments.log_file else '',
'log_file': config.get('log_file', ''),
# Deprecated: For backwards compatibility with borgmatic < 1.6.0.
'repositories': ','.join([repo['path'] for repo in config['repositories']]),
'repository': repository_path,
@@ -848,12 +848,12 @@ def collect_highlander_action_summary_logs(configs, arguments, configuration_par
return
def collect_configuration_run_summary_logs(configs, config_paths, arguments):
def collect_configuration_run_summary_logs(configs, config_paths, arguments, log_file_path):
'''
Given a dict of configuration filename to corresponding parsed configuration, a sequence of
loaded configuration paths, and parsed command-line arguments as a dict from subparser name to a
parsed namespace of arguments, run each configuration file and yield a series of
logging.LogRecord instances containing summary information about each run.
loaded configuration paths, parsed command-line arguments as a dict from subparser name to a
parsed namespace of arguments, and the path of a log file (if any), run each configuration file
and yield a series of logging.LogRecord instances containing summary information about each run.
As a side effect of running through these configuration files, output their JSON results, if
any, to stdout.
@@ -888,7 +888,7 @@ def collect_configuration_run_summary_logs(configs, config_paths, arguments):
borgmatic.config.paths.get_working_directory(config),
arguments['global'].dry_run,
configuration_filename=config_filename,
log_file=arguments['global'].log_file or '',
log_file=log_file_path or '',
)
except (CalledProcessError, ValueError, OSError) as error:
yield from log_error_records('Error running before everything hook', error)
@@ -943,7 +943,7 @@ def collect_configuration_run_summary_logs(configs, config_paths, arguments):
borgmatic.config.paths.get_working_directory(config),
arguments['global'].dry_run,
configuration_filename=config_filename,
log_file=arguments['global'].log_file or '',
log_file=log_file_path or '',
)
except (CalledProcessError, ValueError, OSError) as error:
yield from log_error_records('Error running after everything hook', error)
@@ -960,9 +960,9 @@ def exit_with_help_link(): # pragma: no cover
def check_and_show_help_on_no_args(configs):
'''
Check if the borgmatic command is run without any arguments. If the configuration option
"default_actions" is set to False, show the help message. Otherwise, trigger the default backup
behavior.
Given a dict of configuration filename to corresponding parsed configuration, check if the
borgmatic command is run without any arguments. If the configuration option "default_actions" is
set to False, show the help message. Otherwise, trigger the default backup behavior.
'''
if len(sys.argv) == 1: # No arguments provided
default_actions = any(config.get('default_actions', True) for config in configs.values())
@@ -971,6 +971,33 @@ def check_and_show_help_on_no_args(configs):
sys.exit(0)
def get_singular_option_value(configs, option_name):
'''
Given a dict of configuration filename to corresponding parsed configuration, return the value
of the given option from the configuration files or None if it's not set.
Log and exit if there are conflicting values for the option across the configuration files.
'''
distinct_values = {
value
for config in configs.values()
for value in (config.get(option_name),)
if value is not None
}
if len(distinct_values) > 1:
configure_logging(logging.CRITICAL)
logger.critical(
f'The {option_name} option has conflicting values across configuration files: {", ".join(distinct_values)}'
)
exit_with_help_link()
try:
return tuple(distinct_values)[0]
except IndexError:
return None
def main(extra_summary_logs=[]): # pragma: no cover
configure_signals()
configure_delayed_logging()
@@ -1025,17 +1052,17 @@ def main(extra_summary_logs=[]): # pragma: no cover
any_json_flags = any(
getattr(sub_arguments, 'json', False) for sub_arguments in arguments.values()
)
color_enabled = should_do_markup(configs, any_json_flags)
log_file_path = get_singular_option_value(configs, 'log_file')
try:
configure_logging(
verbosity_to_log_level(global_arguments.verbosity),
verbosity_to_log_level(global_arguments.syslog_verbosity),
verbosity_to_log_level(global_arguments.log_file_verbosity),
verbosity_to_log_level(global_arguments.monitoring_verbosity),
global_arguments.log_file,
global_arguments.log_file_format,
color_enabled=color_enabled,
verbosity_to_log_level(get_verbosity(configs, 'verbosity')),
verbosity_to_log_level(get_verbosity(configs, 'syslog_verbosity')),
verbosity_to_log_level(get_verbosity(configs, 'log_file_verbosity')),
verbosity_to_log_level(get_verbosity(configs, 'monitoring_verbosity')),
log_file_path,
get_singular_option_value(configs, 'log_file_format'),
color_enabled=should_do_markup(configs, any_json_flags),
)
except (FileNotFoundError, PermissionError) as error:
configure_logging(logging.CRITICAL)
@@ -1051,7 +1078,11 @@ def main(extra_summary_logs=[]): # pragma: no cover
configs, arguments, configuration_parse_errors
)
)
or list(collect_configuration_run_summary_logs(configs, config_paths, arguments))
or list(
collect_configuration_run_summary_logs(
configs, config_paths, arguments, log_file_path
)
)
)
)
summary_logs_max_level = max(log.levelno for log in summary_logs)
+75 -113
View File
@@ -813,114 +813,77 @@ properties:
color:
type: boolean
description: |
Deprecated. Use "color" under "logging:" and "console:" instead.
Apply color to console output. Defaults to true.
example: false
logging:
type: object
additionalProperties: false
properties:
console:
type: object
additionalProperties: false
properties:
verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
Display verbose progress to the console: -2
(disabled), -1 (errors only), 0 (responses to
actions, the default), 1 (info about steps borgmatic
is taking), or 2 (debug).
example: 2
color:
type: boolean
description: |
Apply color to console output. Defaults to true.
example: false
syslog:
type: object
additionalProperties: false
properties:
verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
Log verbose progress to syslog: -2 (disabled, the
default), -1 (errors only), 0 (responses to
actions), 1 (info about steps borgmatic is taking),
or 2 (debug).
example: 2
file:
type: object
required: ['path']
additionalProperties: false
properties:
verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
Log verbose progress to file: -2 (disabled), -1
(errors only), 0 (responses to actions), 1 (info
about steps borgmatic is taking, the default), or 2
(debug).
example: 2
path:
type: string
description: |
Write log messages to this file instead of syslog.
example: /var/log/borgmatic/logfile.txt
format:
type: string
description: |
Python format string used for log messages written
to the log file.
example: "%(asctime)s %(message)s"
monitoring:
type: object
additionalProperties: false
properties:
verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
When a monitoring integration supporting logging is
configured, log verbose progress to it: -2
(disabled), -1 (errors only), responses to actions
(0), 1 (info about steps borgmatic is taking, the
default), or 2 (debug).
example: 2
json:
type: boolean
description: |
Write Borg log messages and console output as one JSON
object per log line instead of formatted text. Defaults to
false.
example: true
verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
Settings for where to log borgmatic output and how verbose those
logs should be.
example: false
Display verbose output to the console: -2 (disabled), -1 (errors
only), 0 (warnings and responses to actions, the default), 1 (info
about steps borgmatic is taking), or 2 (debug).
example: 2
syslog_verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
Log verbose output to syslog: -2 (disabled, the default), -1 (errors
only), 0 (warnings and responses to actions), 1 (info about steps
borgmatic is taking), or 2 (debug).
example: 2
log_file_verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
Log verbose output to file: -2 (disabled), -1 (errors only), 0
(warnings and responses to actions), 1 (info about steps borgmatic
is taking, the default), or 2 (debug).
example: 2
log_file:
type: string
description: |
Write log messages to the file at this path.
example: /var/log/borgmatic/logfile.txt
log_file_format:
type: string
description: |
Python format string used for log messages written to the log file.
example: "%(asctime)s %(message)s"
monitoring_verbosity:
type: integer
enum:
- -2
- -1
- 0
- 1
- 2
description: |
When a monitoring integration supporting logging is configured, log
verbose output to it: -2 (disabled), -1 (errors only), 0 (warnings
and responses to actions), 1 (info about steps borgmatic is taking,
the default), or 2 (debug).
example: 2
log_json:
type: boolean
description: |
Write Borg log messages and console output as one JSON object per
log line instead of formatted text. Defaults to false.
example: true
progress:
type: boolean
description: |
@@ -942,6 +905,13 @@ properties:
running supported actions. Corresponds to the "--list" flag on those
actions. Defaults to false.
example: true
default_actions:
type: boolean
description: |
Whether to apply default actions (create, prune, compact and check)
when no arguments are supplied to the borgmatic command. If set to
false, borgmatic displays the help message instead.
example: true
skip_actions:
type: array
items:
@@ -2912,11 +2882,3 @@ properties:
example: "1:7370001"
description: |
Configuration for integration with the KeePassXC password manager.
default_actions:
type: boolean
description: |
Whether to apply default actions (e.g., backup) when no arguments
are supplied to the borgmatic command. If set to true, borgmatic
triggers the default actions (create, prune, compact and check). If
set to false, borgmatic displays the help message instead.
example: true
+22
View File
@@ -22,3 +22,25 @@ def verbosity_to_log_level(verbosity):
VERBOSITY_SOME: logging.INFO,
VERBOSITY_LOTS: logging.DEBUG,
}.get(verbosity, logging.WARNING)
DEFAULT_VERBOSITIES = {
'verbosity': 0,
'syslog_verbosity': -2,
'log_file_verbosity': 1,
'monitoring_verbosity': 1,
}
def get_verbosity(configs, option_name):
'''
Given a dict from configuration filename to configuration dict, and the name of a configuration
verbosity option, return the maximum verbosity value from that option across the given
configuration files.
'''
try:
return max(
config.get(option_name, DEFAULT_VERBOSITIES[option_name]) for config in configs.values()
)
except ValueError:
return DEFAULT_VERBOSITIES[option_name]
+6 -56
View File
@@ -145,10 +145,6 @@ def test_parse_arguments_with_no_arguments_uses_defaults():
global_arguments = arguments['global']
assert global_arguments.config_paths == config_paths
assert global_arguments.verbosity == 0
assert global_arguments.syslog_verbosity == -2
assert global_arguments.log_file_verbosity == 1
assert global_arguments.monitoring_verbosity == 1
def test_parse_arguments_with_multiple_config_flags_parses_as_list():
@@ -158,10 +154,6 @@ def test_parse_arguments_with_multiple_config_flags_parses_as_list():
global_arguments = arguments['global']
assert global_arguments.config_paths == ['myconfig', 'otherconfig']
assert global_arguments.verbosity == 0
assert global_arguments.syslog_verbosity == -2
assert global_arguments.log_file_verbosity == 1
assert global_arguments.monitoring_verbosity == 1
def test_parse_arguments_with_action_after_config_path_omits_action():
@@ -199,48 +191,6 @@ def test_parse_arguments_with_action_and_positional_arguments_after_config_path_
assert arguments['borg'].options == ['key', 'export']
def test_parse_arguments_with_verbosity_overrides_default():
config_paths = ['default']
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
arguments = module.parse_arguments({}, '--verbosity', '1')
global_arguments = arguments['global']
assert global_arguments.config_paths == config_paths
assert global_arguments.verbosity == 1
assert global_arguments.syslog_verbosity == -2
assert global_arguments.log_file_verbosity == 1
assert global_arguments.monitoring_verbosity == 1
def test_parse_arguments_with_syslog_verbosity_overrides_default():
config_paths = ['default']
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
arguments = module.parse_arguments({}, '--syslog-verbosity', '2')
global_arguments = arguments['global']
assert global_arguments.config_paths == config_paths
assert global_arguments.verbosity == 0
assert global_arguments.syslog_verbosity == 2
assert global_arguments.log_file_verbosity == 1
assert global_arguments.monitoring_verbosity == 1
def test_parse_arguments_with_log_file_verbosity_overrides_default():
config_paths = ['default']
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
arguments = module.parse_arguments({}, '--log-file-verbosity', '-1')
global_arguments = arguments['global']
assert global_arguments.config_paths == config_paths
assert global_arguments.verbosity == 0
assert global_arguments.syslog_verbosity == -2
assert global_arguments.log_file_verbosity == -1
assert global_arguments.monitoring_verbosity == 1
def test_parse_arguments_with_single_override_parses():
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
@@ -320,19 +270,19 @@ def test_parse_arguments_with_help_and_action_shows_action_help(capsys):
def test_parse_arguments_with_action_before_global_options_parses_options():
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
arguments = module.parse_arguments({}, 'prune', '--verbosity', '2')
arguments = module.parse_arguments({}, 'prune', '--dry-run')
assert 'prune' in arguments
assert arguments['global'].verbosity == 2
assert arguments['global'].dry_run
def test_parse_arguments_with_global_options_before_action_parses_options():
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
arguments = module.parse_arguments({}, '--verbosity', '2', 'prune')
arguments = module.parse_arguments({}, '--dry-run', 'prune')
assert 'prune' in arguments
assert arguments['global'].verbosity == 2
assert arguments['global'].dry_run
def test_parse_arguments_with_prune_action_leaves_other_actions_disabled():
@@ -708,7 +658,7 @@ def test_parse_arguments_config_with_subaction_and_global_flags_at_start_does_no
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
module.parse_arguments(
{}, '--verbosity', '1', 'config', 'bootstrap', '--repository', 'repo.borg'
{}, '--dry-run', 'config', 'bootstrap', '--repository', 'repo.borg'
)
@@ -716,7 +666,7 @@ def test_parse_arguments_config_with_subaction_and_global_flags_at_end_does_not_
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
module.parse_arguments(
{}, 'config', 'bootstrap', '--repository', 'repo.borg', '--verbosity', '1'
{}, 'config', 'bootstrap', '--repository', 'repo.borg', '--dry-run'
)
+11 -11
View File
@@ -29,7 +29,7 @@ def test_break_lock_calls_borg_with_required_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -41,7 +41,7 @@ def test_break_lock_calls_borg_with_local_path():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -54,7 +54,7 @@ def test_break_lock_calls_borg_using_exit_codes():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -67,7 +67,7 @@ def test_break_lock_calls_borg_with_remote_path_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
@@ -80,7 +80,7 @@ def test_break_lock_calls_borg_with_umask_flags():
repository_path='repo',
config={'umask': '0770'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -90,9 +90,9 @@ def test_break_lock_calls_borg_with_log_json_flags():
module.break_lock(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -104,7 +104,7 @@ def test_break_lock_calls_borg_with_lock_wait_flags():
repository_path='repo',
config={'lock_wait': '5'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -117,7 +117,7 @@ def test_break_lock_with_log_info_calls_borg_with_info_parameter():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -130,7 +130,7 @@ def test_break_lock_with_log_debug_calls_borg_with_debug_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -142,5 +142,5 @@ def test_break_lock_calls_borg_with_working_directory():
repository_path='repo',
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+15 -14
View File
@@ -41,7 +41,7 @@ def test_change_passphrase_calls_borg_with_required_flags():
config={},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -54,7 +54,7 @@ def test_change_passphrase_calls_borg_with_local_path():
config={},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg1',
)
@@ -72,7 +72,7 @@ def test_change_passphrase_calls_borg_using_exit_codes():
config=config,
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -87,7 +87,7 @@ def test_change_passphrase_calls_borg_with_remote_path_flags():
config={},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
remote_path='borg1',
)
@@ -104,20 +104,21 @@ def test_change_passphrase_calls_borg_with_umask_flags():
config=config,
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
def test_change_passphrase_calls_borg_with_log_json_flags():
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
insert_execute_command_mock(('borg', 'key', 'change-passphrase', '--log-json', 'repo'))
config = {'log_json': True}
insert_execute_command_mock(('borg', 'key', 'change-passphrase', '--log-json', 'repo'), config=config)
module.change_passphrase(
repository_path='repo',
config={},
config=config,
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=True),
global_arguments=flexmock(dry_run=False),
)
@@ -133,7 +134,7 @@ def test_change_passphrase_calls_borg_with_lock_wait_flags():
config=config,
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -147,7 +148,7 @@ def test_change_passphrase_with_log_info_calls_borg_with_info_parameter():
config={},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -163,7 +164,7 @@ def test_change_passphrase_with_log_debug_calls_borg_with_debug_flags():
config={},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -177,7 +178,7 @@ def test_change_passphrase_with_dry_run_skips_borg_call():
config={},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=True, log_json=False),
global_arguments=flexmock(dry_run=True),
)
@@ -196,7 +197,7 @@ def test_change_passphrase_calls_borg_without_passphrase():
},
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -214,5 +215,5 @@ def test_change_passphrase_calls_borg_with_working_directory():
config=config,
local_borg_version='1.2.3',
change_passphrase_arguments=flexmock(),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
+27 -27
View File
@@ -277,7 +277,7 @@ def test_get_repository_id_with_valid_json_does_not_raise():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg',
remote_path=None,
)
@@ -294,7 +294,7 @@ def test_get_repository_id_with_json_error_raises():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg',
remote_path=None,
)
@@ -309,7 +309,7 @@ def test_get_repository_id_with_missing_json_keys_raises():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg',
remote_path=None,
)
@@ -344,7 +344,7 @@ def test_check_archives_with_progress_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -379,7 +379,7 @@ def test_check_archives_with_repair_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -414,7 +414,7 @@ def test_check_archives_with_max_duration_flag_passes_through_to_borg():
match_archives=None,
max_duration=33,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -449,7 +449,7 @@ def test_check_archives_with_max_duration_option_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -481,7 +481,7 @@ def test_check_archives_with_max_duration_option_and_archives_check_runs_reposit
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository', 'archives'},
archive_filter_flags=(),
)
@@ -513,7 +513,7 @@ def test_check_archives_with_max_duration_flag_and_archives_check_runs_repositor
match_archives=None,
max_duration=33,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository', 'archives'},
archive_filter_flags=(),
)
@@ -545,7 +545,7 @@ def test_check_archives_with_max_duration_option_and_data_check_runs_repository_
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository', 'data'},
archive_filter_flags=(),
)
@@ -577,7 +577,7 @@ def test_check_archives_with_max_duration_flag_and_data_check_runs_repository_ch
match_archives=None,
max_duration=33,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository', 'data'},
archive_filter_flags=(),
)
@@ -612,7 +612,7 @@ def test_check_archives_with_max_duration_flag_overrides_max_duration_option():
match_archives=None,
max_duration=44,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -645,7 +645,7 @@ def test_check_archives_calls_borg_with_parameters(checks):
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
)
@@ -671,7 +671,7 @@ def test_check_archives_with_data_check_implies_archives_check_calls_borg_with_p
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'data'},
archive_filter_flags=(),
)
@@ -698,7 +698,7 @@ def test_check_archives_with_log_info_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -725,7 +725,7 @@ def test_check_archives_with_log_debug_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -750,7 +750,7 @@ def test_check_archives_with_local_path_calls_borg_via_local_path():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
local_path='borg1',
@@ -777,7 +777,7 @@ def test_check_archives_with_exit_codes_calls_borg_using_them():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
)
@@ -802,7 +802,7 @@ def test_check_archives_with_remote_path_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
remote_path='borg1',
@@ -828,7 +828,7 @@ def test_check_archives_with_umask_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
)
@@ -836,7 +836,7 @@ def test_check_archives_with_umask_passes_through_to_borg():
def test_check_archives_with_log_json_passes_through_to_borg():
checks = {'repository'}
config = {}
config = {'log_json': True}
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'))
@@ -853,7 +853,7 @@ def test_check_archives_with_log_json_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
)
@@ -878,7 +878,7 @@ def test_check_archives_with_lock_wait_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
)
@@ -904,7 +904,7 @@ def test_check_archives_with_retention_prefix():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks=checks,
archive_filter_flags=(),
)
@@ -930,7 +930,7 @@ def test_check_archives_with_extra_borg_options_passes_through_to_borg():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
@@ -965,7 +965,7 @@ def test_check_archives_with_match_archives_passes_through_to_borg():
match_archives='foo-*',
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'archives'},
archive_filter_flags=('--match-archives', 'foo-*'),
)
@@ -993,7 +993,7 @@ def test_check_archives_calls_borg_with_working_directory():
match_archives=None,
max_duration=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
checks={'repository'},
archive_filter_flags=(),
)
+16 -16
View File
@@ -36,7 +36,7 @@ def test_compact_segments_calls_borg_with_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -49,7 +49,7 @@ def test_compact_segments_with_log_info_calls_borg_with_info_flag():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
dry_run=False,
)
@@ -63,7 +63,7 @@ def test_compact_segments_with_log_debug_calls_borg_with_debug_flag():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
dry_run=False,
)
@@ -75,7 +75,7 @@ def test_compact_segments_with_dry_run_skips_borg_call():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
dry_run=True,
)
@@ -89,7 +89,7 @@ def test_compact_segments_with_local_path_calls_borg_via_local_path():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -106,7 +106,7 @@ def test_compact_segments_with_exit_codes_calls_borg_using_them():
repository_path='repo',
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -119,7 +119,7 @@ def test_compact_segments_with_remote_path_calls_borg_with_remote_path_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
@@ -133,7 +133,7 @@ def test_compact_segments_with_progress_calls_borg_with_progress_flag():
repository_path='repo',
config={'progress': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -146,7 +146,7 @@ def test_compact_segments_with_cleanup_commits_calls_borg_with_cleanup_commits_f
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
cleanup_commits=True,
)
@@ -160,7 +160,7 @@ def test_compact_segments_with_threshold_calls_borg_with_threshold_flag():
repository_path='repo',
config={'compact_threshold': 20},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -174,7 +174,7 @@ def test_compact_segments_with_umask_calls_borg_with_umask_flags():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -185,9 +185,9 @@ def test_compact_segments_with_log_json_calls_borg_with_log_json_flags():
module.compact_segments(
dry_run=False,
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -201,7 +201,7 @@ def test_compact_segments_with_lock_wait_calls_borg_with_lock_wait_flags():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -214,7 +214,7 @@ def test_compact_segments_with_extra_borg_options_calls_borg_with_extra_options(
repository_path='repo',
config={'extra_borg_options': {'compact': '--extra --options'}},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -229,5 +229,5 @@ def test_compact_segments_calls_borg_with_working_directory():
repository_path='repo',
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+36 -35
View File
@@ -343,7 +343,7 @@ def test_make_base_create_produces_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -379,7 +379,7 @@ def test_make_base_create_command_includes_patterns_file_in_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -411,7 +411,7 @@ def test_make_base_create_command_with_store_config_false_omits_config_files():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -476,7 +476,7 @@ def test_make_base_create_command_includes_configuration_option_as_command_flag(
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -508,7 +508,7 @@ def test_make_base_create_command_includes_dry_run_in_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -539,7 +539,7 @@ def test_make_base_create_command_includes_local_path_in_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
local_path='borg1',
)
@@ -571,7 +571,7 @@ def test_make_base_create_command_includes_remote_path_in_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
remote_path='borg1',
)
@@ -600,10 +600,11 @@ def test_make_base_create_command_includes_log_json_in_borg_command():
config={
'source_directories': ['foo', 'bar'],
'repositories': ['repo'],
'log_json': True,
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -635,7 +636,7 @@ def test_make_base_create_command_includes_list_flags_in_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -687,7 +688,7 @@ def test_make_base_create_command_with_stream_processes_ignores_read_special_fal
},
patterns=patterns,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
stream_processes=flexmock(),
)
@@ -738,7 +739,7 @@ def test_make_base_create_command_without_patterns_and_with_stream_processes_ign
},
patterns=[],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
stream_processes=flexmock(),
)
@@ -773,7 +774,7 @@ def test_make_base_create_command_with_stream_processes_and_read_special_true_sk
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
stream_processes=flexmock(),
)
@@ -806,7 +807,7 @@ def test_make_base_create_command_includes_archive_name_format_in_borg_command()
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -837,7 +838,7 @@ def test_make_base_create_command_includes_default_archive_name_format_in_borg_c
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -869,7 +870,7 @@ def test_make_base_create_command_includes_archive_name_format_with_placeholders
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -901,7 +902,7 @@ def test_make_base_create_command_includes_repository_and_archive_name_format_wi
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -933,7 +934,7 @@ def test_make_base_create_command_includes_extra_borg_options_in_borg_command():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -957,7 +958,7 @@ def test_make_base_create_command_with_non_existent_directory_and_source_directo
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/run/borgmatic',
)
@@ -990,7 +991,7 @@ def test_create_archive_calls_borg_with_flags():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1024,7 +1025,7 @@ def test_create_archive_calls_borg_with_environment():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1058,7 +1059,7 @@ def test_create_archive_with_log_info_calls_borg_with_info_flag():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1090,7 +1091,7 @@ def test_create_archive_with_log_info_and_json_suppresses_most_borg_output():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
json=True,
)
@@ -1125,7 +1126,7 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_flag():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1157,7 +1158,7 @@ def test_create_archive_with_log_debug_and_json_suppresses_most_borg_output():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
json=True,
)
@@ -1194,7 +1195,7 @@ def test_create_archive_with_stats_and_dry_run_calls_borg_without_stats():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1230,7 +1231,7 @@ def test_create_archive_with_working_directory_calls_borg_with_working_directory
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1265,7 +1266,7 @@ def test_create_archive_with_exit_codes_calls_borg_using_them():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1299,7 +1300,7 @@ def test_create_archive_with_stats_calls_borg_with_stats_flag_and_answer_output_
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1337,7 +1338,7 @@ def test_create_archive_with_files_calls_borg_with_answer_output_log_level():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1372,7 +1373,7 @@ def test_create_archive_with_progress_and_log_info_calls_borg_with_progress_flag
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1406,7 +1407,7 @@ def test_create_archive_with_progress_calls_borg_with_progress_flag():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
@@ -1462,7 +1463,7 @@ def test_create_archive_with_progress_and_stream_processes_calls_borg_with_progr
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
stream_processes=processes,
)
@@ -1494,7 +1495,7 @@ def test_create_archive_with_json_calls_borg_with_json_flag():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
json=True,
)
@@ -1528,7 +1529,7 @@ def test_create_archive_with_stats_and_json_calls_borg_without_stats_flag():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
json=True,
)
@@ -1567,7 +1568,7 @@ def test_create_archive_calls_borg_with_working_directory():
},
patterns=[Pattern('foo'), Pattern('bar')],
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
borgmatic_runtime_directory='/borgmatic/run',
)
+13 -13
View File
@@ -22,7 +22,7 @@ def test_make_delete_command_includes_log_info():
config={},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -44,7 +44,7 @@ def test_make_delete_command_includes_log_debug():
config={},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -68,7 +68,7 @@ def test_make_delete_command_includes_dry_run():
config={},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=True, log_json=False),
global_arguments=flexmock(dry_run=True),
local_path='borg',
remote_path=None,
)
@@ -92,7 +92,7 @@ def test_make_delete_command_includes_remote_path():
config={},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path='borg1',
)
@@ -115,7 +115,7 @@ def test_make_delete_command_includes_umask():
config={'umask': '077'},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -136,10 +136,10 @@ def test_make_delete_command_includes_log_json():
command = module.make_delete_command(
repository={'path': 'repo'},
config={},
config={'log_json': True},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=True),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -163,7 +163,7 @@ def test_make_delete_command_includes_lock_wait():
config={'lock_wait': 5},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -187,7 +187,7 @@ def test_make_delete_command_with_list_config_calls_borg_with_list_flag():
config={'list_details': True},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=None, force=0, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -208,7 +208,7 @@ def test_make_delete_command_includes_force():
config={},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=1, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -229,7 +229,7 @@ def test_make_delete_command_includes_force_twice():
config={},
local_borg_version='1.2.3',
delete_arguments=flexmock(list_details=False, force=2, match_archives=None, archive=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -254,7 +254,7 @@ def test_make_delete_command_includes_archive():
delete_arguments=flexmock(
list_details=False, force=0, match_archives=None, archive='archive'
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -279,7 +279,7 @@ def test_make_delete_command_includes_match_archives():
delete_arguments=flexmock(
list_details=False, force=0, match_archives='sh:foo*', archive='archive'
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
+19 -19
View File
@@ -39,7 +39,7 @@ def test_export_key_calls_borg_with_required_flags():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -53,7 +53,7 @@ def test_export_key_calls_borg_with_local_path():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg1',
)
@@ -69,7 +69,7 @@ def test_export_key_calls_borg_using_exit_codes():
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -83,7 +83,7 @@ def test_export_key_calls_borg_with_remote_path_flags():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
remote_path='borg1',
)
@@ -98,7 +98,7 @@ def test_export_key_calls_borg_with_umask_flags():
config={'umask': '0770'},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -109,10 +109,10 @@ def test_export_key_calls_borg_with_log_json_flags():
module.export_key(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=True),
global_arguments=flexmock(dry_run=False),
)
@@ -126,7 +126,7 @@ def test_export_key_calls_borg_with_lock_wait_flags():
config={'lock_wait': '5'},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -141,7 +141,7 @@ def test_export_key_with_log_info_calls_borg_with_info_parameter():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -156,7 +156,7 @@ def test_export_key_with_log_debug_calls_borg_with_debug_flags():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -170,7 +170,7 @@ def test_export_key_calls_borg_with_paper_flags():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=True, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -184,7 +184,7 @@ def test_export_key_calls_borg_with_paper_flag():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=True, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -198,7 +198,7 @@ def test_export_key_calls_borg_with_qr_html_flag():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=True, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -212,7 +212,7 @@ def test_export_key_calls_borg_with_path_argument():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path='dest'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -227,7 +227,7 @@ def test_export_key_with_already_existent_path_raises():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path='dest'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -241,7 +241,7 @@ def test_export_key_with_stdout_path_calls_borg_without_path_argument():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path='-'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -255,7 +255,7 @@ def test_export_key_with_dry_run_skips_borg_call():
config={},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=True, log_json=False),
global_arguments=flexmock(dry_run=True),
)
@@ -269,7 +269,7 @@ def test_export_key_calls_borg_with_working_directory():
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -289,5 +289,5 @@ def test_export_key_calls_borg_with_path_argument_and_working_directory():
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
export_arguments=flexmock(paper=False, qr_html=False, path='dest'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
+17 -17
View File
@@ -48,7 +48,7 @@ def test_export_tar_archive_calls_borg_with_path_flags():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -70,7 +70,7 @@ def test_export_tar_archive_calls_borg_with_local_path_flags():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -95,7 +95,7 @@ def test_export_tar_archive_calls_borg_using_exit_codes():
destination_path='test.tar',
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -117,7 +117,7 @@ def test_export_tar_archive_calls_borg_with_remote_path_flags():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
@@ -140,7 +140,7 @@ def test_export_tar_archive_calls_borg_with_umask_flags():
destination_path='test.tar',
config={'umask': '0770'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -158,9 +158,9 @@ def test_export_tar_archive_calls_borg_with_log_json_flag():
archive='archive',
paths=None,
destination_path='test.tar',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -182,7 +182,7 @@ def test_export_tar_archive_calls_borg_with_lock_wait_flags():
destination_path='test.tar',
config={'lock_wait': '5'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -203,7 +203,7 @@ def test_export_tar_archive_with_log_info_calls_borg_with_info_flag():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -226,7 +226,7 @@ def test_export_tar_archive_with_log_debug_calls_borg_with_debug_flags():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -246,7 +246,7 @@ def test_export_tar_archive_calls_borg_with_dry_run_flag():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -268,7 +268,7 @@ def test_export_tar_archive_calls_borg_with_tar_filter_flags():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
tar_filter='bzip2',
)
@@ -292,7 +292,7 @@ def test_export_tar_archive_calls_borg_with_list_flag():
destination_path='test.tar',
config={'list_details': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -314,7 +314,7 @@ def test_export_tar_archive_calls_borg_with_strip_components_flag():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
strip_components=5,
)
@@ -335,7 +335,7 @@ def test_export_tar_archive_skips_abspath_for_remote_repository_flag():
destination_path='test.tar',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -355,7 +355,7 @@ def test_export_tar_archive_calls_borg_with_stdout_destination_path():
destination_path='-',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -378,5 +378,5 @@ def test_export_tar_archive_calls_borg_with_working_directory():
destination_path='test.tar',
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+33 -33
View File
@@ -29,7 +29,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_last_archive():
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
)
@@ -42,7 +42,7 @@ def test_extract_last_archive_dry_run_without_any_archives_should_not_raise():
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
)
@@ -59,7 +59,7 @@ def test_extract_last_archive_dry_run_with_log_info_calls_borg_with_info_paramet
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
)
@@ -78,7 +78,7 @@ def test_extract_last_archive_dry_run_with_log_debug_calls_borg_with_debug_param
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
)
@@ -94,7 +94,7 @@ def test_extract_last_archive_dry_run_calls_borg_via_local_path():
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
local_path='borg1',
@@ -114,7 +114,7 @@ def test_extract_last_archive_dry_run_calls_borg_using_exit_codes():
module.extract_last_archive_dry_run(
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
)
@@ -132,7 +132,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_remote_path_flags():
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
remote_path='borg1',
@@ -147,9 +147,9 @@ def test_extract_last_archive_dry_run_calls_borg_with_log_json_flag():
)
module.extract_last_archive_dry_run(
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=None,
)
@@ -167,7 +167,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_lock_wait_flags():
module.extract_last_archive_dry_run(
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
repository_path='repo',
lock_wait=5,
)
@@ -192,7 +192,7 @@ def test_extract_archive_calls_borg_with_path_flags():
paths=['path1', 'path2'],
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -215,7 +215,7 @@ def test_extract_archive_calls_borg_with_local_path():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -242,7 +242,7 @@ def test_extract_archive_calls_borg_with_exit_codes():
paths=None,
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -265,7 +265,7 @@ def test_extract_archive_calls_borg_with_remote_path_flags():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
@@ -296,7 +296,7 @@ def test_extract_archive_calls_borg_with_numeric_ids_parameter(feature_available
paths=None,
config={'numeric_ids': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -319,7 +319,7 @@ def test_extract_archive_calls_borg_with_umask_flags():
paths=None,
config={'umask': '0770'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -337,9 +337,9 @@ def test_extract_archive_calls_borg_with_log_json_flags():
repository='repo',
archive='archive',
paths=None,
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -362,7 +362,7 @@ def test_extract_archive_calls_borg_with_lock_wait_flags():
paths=None,
config={'lock_wait': '5'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -386,7 +386,7 @@ def test_extract_archive_with_log_info_calls_borg_with_info_parameter():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -412,7 +412,7 @@ def test_extract_archive_with_log_debug_calls_borg_with_debug_flags():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -435,7 +435,7 @@ def test_extract_archive_calls_borg_with_dry_run_parameter():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -458,7 +458,7 @@ def test_extract_archive_calls_borg_with_destination_path():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
destination_path='/dest',
)
@@ -482,7 +482,7 @@ def test_extract_archive_calls_borg_with_strip_components():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
strip_components=5,
)
@@ -516,7 +516,7 @@ def test_extract_archive_calls_borg_with_strip_components_calculated_from_all():
paths=['foo/bar/baz.txt', 'foo/bar.txt'],
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
strip_components='all',
)
@@ -550,7 +550,7 @@ def test_extract_archive_calls_borg_with_strip_components_calculated_from_all_wi
paths=['/foo/bar/baz.txt', '/foo/bar.txt'],
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
strip_components='all',
)
@@ -575,7 +575,7 @@ def test_extract_archive_with_strip_components_all_and_no_paths_raises():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
strip_components='all',
)
@@ -608,7 +608,7 @@ def test_extract_archive_calls_borg_with_progress_flag():
paths=None,
config={'progress': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -623,7 +623,7 @@ def test_extract_archive_with_progress_and_extract_to_stdout_raises():
paths=None,
config={'progress': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
extract_to_stdout=True,
)
@@ -659,7 +659,7 @@ def test_extract_archive_calls_borg_with_stdout_parameter_and_returns_process():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
extract_to_stdout=True,
)
== process
@@ -693,7 +693,7 @@ def test_extract_archive_skips_abspath_for_remote_repository():
paths=None,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -717,7 +717,7 @@ def test_extract_archive_uses_configured_working_directory_in_repo_path_and_dest
paths=None,
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
destination_path='dest',
)
@@ -740,5 +740,5 @@ def test_extract_archive_uses_configured_working_directory_in_repo_path_when_des
paths=None,
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+17 -17
View File
@@ -38,7 +38,7 @@ def test_import_key_calls_borg_with_required_flags():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -53,7 +53,7 @@ def test_import_key_calls_borg_with_local_path():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg1',
)
@@ -70,7 +70,7 @@ def test_import_key_calls_borg_using_exit_codes():
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -85,7 +85,7 @@ def test_import_key_calls_borg_with_remote_path_flags():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
remote_path='borg1',
)
@@ -101,7 +101,7 @@ def test_import_key_calls_borg_with_umask_flags():
config={'umask': '0770'},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -113,10 +113,10 @@ def test_import_key_calls_borg_with_log_json_flags():
module.import_key(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=True),
global_arguments=flexmock(dry_run=False),
)
@@ -131,7 +131,7 @@ def test_import_key_calls_borg_with_lock_wait_flags():
config={'lock_wait': '5'},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -147,7 +147,7 @@ def test_import_key_with_log_info_calls_borg_with_info_parameter():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -163,7 +163,7 @@ def test_import_key_with_log_debug_calls_borg_with_debug_flags():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -178,7 +178,7 @@ def test_import_key_calls_borg_with_paper_flags():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=True, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -193,7 +193,7 @@ def test_import_key_calls_borg_with_path_argument():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path='source'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -209,7 +209,7 @@ def test_import_key_with_non_existent_path_raises():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path='source'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -224,7 +224,7 @@ def test_import_key_with_stdin_path_calls_borg_without_path_argument():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path='-'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -239,7 +239,7 @@ def test_import_key_with_dry_run_skips_borg_call():
config={},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=True, log_json=False),
global_arguments=flexmock(dry_run=True),
)
@@ -254,7 +254,7 @@ def test_import_key_calls_borg_with_working_directory():
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path=None),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
@@ -275,5 +275,5 @@ def test_import_key_calls_borg_with_path_argument_and_working_directory():
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
import_arguments=flexmock(paper=False, path='source'),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
)
+23 -23
View File
@@ -20,7 +20,7 @@ def test_make_info_command_constructs_borg_info_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -42,7 +42,7 @@ def test_make_info_command_with_log_info_passes_through_to_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -64,7 +64,7 @@ def test_make_info_command_with_log_info_and_json_omits_borg_logging_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=True, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -86,7 +86,7 @@ def test_make_info_command_with_log_debug_passes_through_to_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -107,7 +107,7 @@ def test_make_info_command_with_log_debug_and_json_omits_borg_logging_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=True, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -128,7 +128,7 @@ def test_make_info_command_with_json_passes_through_to_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=True, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -149,7 +149,7 @@ def test_make_info_command_with_archive_uses_match_archives_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive='archive', json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -170,7 +170,7 @@ def test_make_info_command_with_local_path_passes_through_to_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg1',
remote_path=None,
@@ -194,7 +194,7 @@ def test_make_info_command_with_remote_path_passes_through_to_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path='borg1',
@@ -217,7 +217,7 @@ def test_make_info_command_with_umask_passes_through_to_command():
repository_path='repo',
config={'umask': '077'},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -239,9 +239,9 @@ def test_make_info_command_with_log_json_passes_through_to_command():
command = module.make_info_command(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -266,7 +266,7 @@ def test_make_info_command_with_lock_wait_passes_through_to_command():
repository_path='repo',
config=config,
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -290,7 +290,7 @@ def test_make_info_command_transforms_prefix_into_match_archives_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix='foo'),
local_path='borg',
remote_path=None,
@@ -314,7 +314,7 @@ def test_make_info_command_prefers_prefix_over_archive_name_format():
repository_path='repo',
config={'archive_name_format': 'bar-{now}'}, # noqa: FS003
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix='foo'),
local_path='borg',
remote_path=None,
@@ -335,7 +335,7 @@ def test_make_info_command_transforms_archive_name_format_into_match_archives_fl
repository_path='repo',
config={'archive_name_format': 'bar-{now}'}, # noqa: FS003
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -360,7 +360,7 @@ def test_make_info_command_with_match_archives_option_passes_through_to_command(
'match_archives': 'sh:foo-*',
},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
local_path='borg',
remote_path=None,
@@ -382,7 +382,7 @@ def test_make_info_command_with_match_archives_flag_passes_through_to_command():
repository_path='repo',
config={'archive_name_format': 'bar-{now}', 'match_archives': 'sh:foo-*'}, # noqa: FS003
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives='sh:foo-*'),
local_path='borg',
remote_path=None,
@@ -408,7 +408,7 @@ def test_make_info_command_passes_arguments_through_to_command(argument_name):
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(
archive=None, json=False, prefix=None, match_archives=None, **{argument_name: 'value'}
),
@@ -443,7 +443,7 @@ def test_make_info_command_with_date_based_matching_passes_through_to_command():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=info_arguments,
local_path='borg',
remote_path=None,
@@ -478,7 +478,7 @@ def test_display_archives_info_calls_two_commands():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
)
@@ -498,7 +498,7 @@ def test_display_archives_info_with_json_calls_json_command_only():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=True, prefix=None, match_archives=None),
)
== json_output
@@ -533,6 +533,6 @@ def test_display_archives_info_calls_borg_with_working_directory():
repository_path='repo',
config={'working_directory': '/working/dir'},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
)
+27 -27
View File
@@ -20,7 +20,7 @@ def test_make_list_command_includes_log_info():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--info', 'repo')
@@ -37,7 +37,7 @@ def test_make_list_command_includes_json_but_not_info():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--json', 'repo')
@@ -54,7 +54,7 @@ def test_make_list_command_includes_log_debug():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--debug', '--show-rc', 'repo')
@@ -71,7 +71,7 @@ def test_make_list_command_includes_json_but_not_debug():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--json', 'repo')
@@ -87,7 +87,7 @@ def test_make_list_command_includes_json():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--json', 'repo')
@@ -102,10 +102,10 @@ def test_make_list_command_includes_log_json():
command = module.make_list_command(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--log-json', 'repo')
@@ -123,7 +123,7 @@ def test_make_list_command_includes_lock_wait():
config={'lock_wait': 5},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--lock-wait', '5', 'repo')
@@ -141,7 +141,7 @@ def test_make_list_command_includes_archive():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive='archive', paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', 'repo::archive')
@@ -159,7 +159,7 @@ def test_make_list_command_includes_archive_and_path():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive='archive', paths=['var/lib'], json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', 'repo::archive', 'var/lib')
@@ -175,7 +175,7 @@ def test_make_list_command_includes_local_path():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg2',
)
@@ -198,7 +198,7 @@ def test_make_list_command_includes_remote_path():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg2',
)
@@ -217,7 +217,7 @@ def test_make_list_command_includes_umask():
config={'umask': '077'},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--umask', '077', 'repo')
@@ -233,7 +233,7 @@ def test_make_list_command_includes_short():
config={},
local_borg_version='1.2.3',
list_arguments=flexmock(archive=None, paths=None, json=False, short=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--short', 'repo')
@@ -272,7 +272,7 @@ def test_make_list_command_includes_additional_flags(argument_name):
format=None,
**{argument_name: 'value'},
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--' + argument_name.replace('_', '-'), 'value', 'repo')
@@ -316,7 +316,7 @@ def test_capture_archive_listing_does_not_raise():
archive='archive',
config={},
local_borg_version=flexmock(),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -335,7 +335,7 @@ def test_list_archive_calls_borg_with_flags():
first=None,
last=None,
)
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
flexmock(module.feature).should_receive('available').and_return(False)
flexmock(module).should_receive('make_list_command').with_args(
@@ -382,7 +382,7 @@ def test_list_archive_with_archive_and_json_errors():
config={},
local_borg_version='1.2.3',
list_arguments=list_arguments,
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -401,7 +401,7 @@ def test_list_archive_calls_borg_with_local_path():
first=None,
last=None,
)
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
flexmock(module.feature).should_receive('available').and_return(False)
flexmock(module).should_receive('make_list_command').with_args(
@@ -450,7 +450,7 @@ def test_list_archive_calls_borg_using_exit_codes():
first=None,
last=None,
)
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
flexmock(module.feature).should_receive('available').and_return(False)
borg_exit_codes = flexmock()
@@ -539,7 +539,7 @@ def test_list_archive_calls_borg_multiple_times_with_find_paths():
config={},
local_borg_version='1.2.3',
list_arguments=list_arguments,
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -558,7 +558,7 @@ def test_list_archive_calls_borg_with_archive():
first=None,
last=None,
)
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
flexmock(module.feature).should_receive('available').and_return(False)
flexmock(module).should_receive('make_list_command').with_args(
@@ -618,7 +618,7 @@ def test_list_archive_without_archive_delegates_to_list_repository():
config={},
local_borg_version='1.2.3',
list_arguments=list_arguments,
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -649,7 +649,7 @@ def test_list_archive_with_borg_features_without_archive_delegates_to_list_repos
config={},
local_borg_version='1.2.3',
list_arguments=list_arguments,
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -669,7 +669,7 @@ def test_list_archive_with_archive_ignores_archive_filter_flag(
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
flexmock(module.logger).answer = lambda message: None
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
default_filter_flags = {
'prefix': None,
'match_archives': None,
@@ -741,7 +741,7 @@ def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes
}
altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
glob_paths = ('**/*foo.txt*/**',)
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.repo_list).should_receive('make_repo_list_command').with_args(
@@ -855,7 +855,7 @@ def test_list_archive_calls_borg_with_working_directory():
first=None,
last=None,
)
global_arguments = flexmock(log_json=False)
global_arguments = flexmock()
flexmock(module.feature).should_receive('available').and_return(False)
flexmock(module).should_receive('make_list_command').with_args(
+17 -17
View File
@@ -33,7 +33,7 @@ def test_mount_archive_calls_borg_with_required_flags():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -56,7 +56,7 @@ def test_mount_archive_with_borg_features_calls_borg_with_repository_and_match_a
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -74,7 +74,7 @@ def test_mount_archive_without_archive_calls_borg_with_repository_flags_only():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -94,7 +94,7 @@ def test_mount_archive_calls_borg_with_path_flags():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -112,7 +112,7 @@ def test_mount_archive_calls_borg_with_local_path():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -135,7 +135,7 @@ def test_mount_archive_calls_borg_using_exit_codes():
mount_arguments=mount_arguments,
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -155,7 +155,7 @@ def test_mount_archive_calls_borg_with_remote_path_flags():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
@@ -174,7 +174,7 @@ def test_mount_archive_calls_borg_with_umask_flags():
mount_arguments=mount_arguments,
config={'umask': '0770'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -190,9 +190,9 @@ def test_mount_archive_calls_borg_with_log_json_flags():
repository_path='repo',
archive='archive',
mount_arguments=mount_arguments,
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -210,7 +210,7 @@ def test_mount_archive_calls_borg_with_lock_wait_flags():
mount_arguments=mount_arguments,
config={'lock_wait': '5'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -229,7 +229,7 @@ def test_mount_archive_with_log_info_calls_borg_with_info_parameter():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -248,7 +248,7 @@ def test_mount_archive_with_log_debug_calls_borg_with_debug_flags():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -275,7 +275,7 @@ def test_mount_archive_calls_borg_with_foreground_parameter():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -295,7 +295,7 @@ def test_mount_archive_calls_borg_with_options_flags():
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -359,7 +359,7 @@ def test_mount_archive_with_date_based_matching_calls_borg_with_date_based_flags
mount_arguments=mount_arguments,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -375,5 +375,5 @@ def test_mount_archive_calls_borg_with_working_directory():
mount_arguments=mount_arguments,
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+17 -17
View File
@@ -195,7 +195,7 @@ def test_prune_archives_calls_borg_with_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -217,7 +217,7 @@ def test_prune_archives_with_log_info_calls_borg_with_info_flag():
config={},
dry_run=False,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -239,7 +239,7 @@ def test_prune_archives_with_log_debug_calls_borg_with_debug_flag():
config={},
dry_run=False,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -260,7 +260,7 @@ def test_prune_archives_with_dry_run_calls_borg_with_dry_run_flag():
config={},
dry_run=True,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -281,7 +281,7 @@ def test_prune_archives_with_local_path_calls_borg_via_local_path():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
prune_arguments=prune_arguments,
)
@@ -308,7 +308,7 @@ def test_prune_archives_with_exit_codes_calls_borg_using_them():
repository_path='repo',
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -329,7 +329,7 @@ def test_prune_archives_with_remote_path_calls_borg_with_remote_path_flags():
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
prune_arguments=prune_arguments,
)
@@ -351,7 +351,7 @@ def test_prune_archives_with_stats_config_calls_borg_with_stats_flag():
repository_path='repo',
config={'statistics': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -372,7 +372,7 @@ def test_prune_archives_with_list_config_calls_borg_with_list_flag():
repository_path='repo',
config={'list_details': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -394,7 +394,7 @@ def test_prune_archives_with_umask_calls_borg_with_umask_flags():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -413,9 +413,9 @@ def test_prune_archives_with_log_json_calls_borg_with_log_json_flag():
module.prune_archives(
dry_run=False,
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -437,7 +437,7 @@ def test_prune_archives_with_lock_wait_calls_borg_with_lock_wait_flags():
repository_path='repo',
config=config,
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -458,7 +458,7 @@ def test_prune_archives_with_extra_borg_options_calls_borg_with_extra_options():
repository_path='repo',
config={'extra_borg_options': {'prune': '--extra --options'}},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -527,7 +527,7 @@ def test_prune_archives_with_date_based_matching_calls_borg_with_date_based_flag
repository_path='repo',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -550,7 +550,7 @@ def test_prune_archives_calls_borg_with_working_directory():
repository_path='repo',
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
@@ -571,6 +571,6 @@ def test_prune_archives_calls_borg_without_stats_when_feature_is_not_available()
repository_path='repo',
config={'statistics': True},
local_borg_version='2.0.0b10',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
prune_arguments=prune_arguments,
)
+24 -24
View File
@@ -51,7 +51,7 @@ def test_recreate_archive_dry_run_skips_execution():
config={},
local_borg_version='1.2.3',
recreate_arguments=recreate_arguments,
global_arguments=flexmock(log_json=False, dry_run=True),
global_arguments=flexmock(dry_run=True),
local_path='borg',
)
@@ -86,7 +86,7 @@ def test_recreate_calls_borg_with_required_flags():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
patterns=None,
@@ -121,7 +121,7 @@ def test_recreate_with_remote_path():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path='borg1',
patterns=None,
@@ -156,7 +156,7 @@ def test_recreate_with_lock_wait():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -192,7 +192,7 @@ def test_recreate_with_log_info():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -227,7 +227,7 @@ def test_recreate_with_log_debug():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -252,7 +252,7 @@ def test_recreate_with_log_json():
module.recreate_archive(
repository='repo',
archive='archive',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
recreate_arguments=flexmock(
list=None,
@@ -261,7 +261,7 @@ def test_recreate_with_log_json():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=True),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -297,7 +297,7 @@ def test_recreate_with_list_config_calls_borg_with_list_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -334,7 +334,7 @@ def test_recreate_with_patterns_from_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=['pattern1', 'pattern2'],
)
@@ -368,7 +368,7 @@ def test_recreate_with_exclude_flags():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -402,7 +402,7 @@ def test_recreate_with_target_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -438,7 +438,7 @@ def test_recreate_with_comment_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -474,7 +474,7 @@ def test_recreate_with_timestamp_flag():
timestamp='2023-10-01T12:00:00',
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -508,7 +508,7 @@ def test_recreate_with_compression_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -544,7 +544,7 @@ def test_recreate_with_chunker_params_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -578,7 +578,7 @@ def test_recreate_with_recompress_flag():
timestamp=None,
match_archives=None,
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -612,7 +612,7 @@ def test_recreate_with_match_archives_star():
timestamp=None,
match_archives='*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -646,7 +646,7 @@ def test_recreate_with_match_archives_regex():
timestamp=None,
match_archives='re:.*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -680,7 +680,7 @@ def test_recreate_with_match_archives_shell():
timestamp=None,
match_archives='sh:*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -712,7 +712,7 @@ def test_recreate_with_match_archives_and_feature_available_calls_borg_with_matc
timestamp=None,
match_archives='foo-*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -746,7 +746,7 @@ def test_recreate_with_archives_flag_and_feature_available_calls_borg_with_match
timestamp=None,
match_archives='foo-*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -776,7 +776,7 @@ def test_recreate_with_match_archives_and_feature_not_available_calls_borg_witho
timestamp=None,
match_archives='foo-*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
@@ -806,7 +806,7 @@ def test_recreate_with_archives_flags_and_feature_not_available_calls_borg_with_
timestamp=None,
match_archives='foo-*',
),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
patterns=None,
)
+23 -23
View File
@@ -59,7 +59,7 @@ def test_create_repository_calls_borg_with_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -80,7 +80,7 @@ def test_create_repository_with_dry_run_skips_borg_call():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -106,7 +106,7 @@ def test_create_repository_raises_for_borg_repo_create_error():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -126,7 +126,7 @@ def test_create_repository_skips_creation_when_repository_already_exists():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -147,7 +147,7 @@ def test_create_repository_errors_when_repository_with_differing_encryption_mode
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey-blake2',
)
@@ -163,7 +163,7 @@ def test_create_repository_raises_for_unknown_repo_info_command_error():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -186,7 +186,7 @@ def test_create_repository_with_source_repository_calls_borg_with_other_repo_fla
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
source_repository='other.borg',
)
@@ -208,7 +208,7 @@ def test_create_repository_with_copy_crypt_key_calls_borg_with_copy_crypt_key_fl
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
copy_crypt_key=True,
)
@@ -230,7 +230,7 @@ def test_create_repository_with_append_only_calls_borg_with_append_only_flag():
repository_path='repo',
config={'append_only': True},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
append_only=True,
)
@@ -252,7 +252,7 @@ def test_create_repository_with_append_only_config_calls_borg_with_append_only_f
repository_path='repo',
config={'append_only': True},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
append_only=True,
)
@@ -276,7 +276,7 @@ def test_create_repository_with_storage_quota_calls_borg_with_storage_quota_flag
repository_path='repo',
config={'storage_quota': '5G'},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
storage_quota='5G',
)
@@ -298,7 +298,7 @@ def test_create_repository_with_make_parent_dirs_calls_borg_with_make_parent_dir
repository_path='repo',
config={'make_parent_directories': True},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
make_parent_directories=True,
)
@@ -321,7 +321,7 @@ def test_create_repository_with_log_info_calls_borg_with_info_flag():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -343,7 +343,7 @@ def test_create_repository_with_log_debug_calls_borg_with_debug_flag():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -362,9 +362,9 @@ def test_create_repository_with_log_json_calls_borg_with_log_json_flag():
module.create_repository(
dry_run=False,
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -385,7 +385,7 @@ def test_create_repository_with_lock_wait_calls_borg_with_lock_wait_flag():
repository_path='repo',
config={'lock_wait': 5},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -406,7 +406,7 @@ def test_create_repository_with_local_path_calls_borg_via_local_path():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
local_path='borg1',
)
@@ -431,7 +431,7 @@ def test_create_repository_with_exit_codes_calls_borg_using_them():
repository_path='repo',
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -454,7 +454,7 @@ def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
remote_path='borg1',
)
@@ -476,7 +476,7 @@ def test_create_repository_with_umask_calls_borg_with_umask_flag():
repository_path='repo',
config={'umask': '077'},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -499,7 +499,7 @@ def test_create_repository_with_extra_borg_options_calls_borg_with_extra_options
repository_path='repo',
config={'extra_borg_options': {'repo-create': '--extra --options'}},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
@@ -522,6 +522,6 @@ def test_create_repository_calls_borg_with_working_directory():
repository_path='repo',
config={'working_directory': '/working/dir'},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
encryption_mode='repokey',
)
+13 -13
View File
@@ -20,7 +20,7 @@ def test_make_repo_delete_command_with_feature_available_runs_borg_repo_delete()
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -41,7 +41,7 @@ def test_make_repo_delete_command_without_feature_available_runs_borg_delete():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -63,7 +63,7 @@ def test_make_repo_delete_command_includes_log_info():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -85,7 +85,7 @@ def test_make_repo_delete_command_includes_log_debug():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -109,7 +109,7 @@ def test_make_repo_delete_command_includes_dry_run():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=True, log_json=False),
global_arguments=flexmock(dry_run=True),
local_path='borg',
remote_path=None,
)
@@ -133,7 +133,7 @@ def test_make_repo_delete_command_includes_remote_path():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path='borg1',
)
@@ -156,7 +156,7 @@ def test_make_repo_delete_command_includes_umask():
config={'umask': '077'},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -177,10 +177,10 @@ def test_make_repo_delete_command_includes_log_json():
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
config={'log_json': True},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=True),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -204,7 +204,7 @@ def test_make_repo_delete_command_includes_lock_wait():
config={'lock_wait': 5},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -228,7 +228,7 @@ def test_make_repo_delete_command_includes_list():
config={'list_details': True},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=True, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -249,7 +249,7 @@ def test_make_repo_delete_command_includes_force():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=1),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
@@ -270,7 +270,7 @@ def test_make_repo_delete_command_includes_force_twice():
config={},
local_borg_version='1.2.3',
repo_delete_arguments=flexmock(list_details=False, force=2),
global_arguments=flexmock(dry_run=False, log_json=False),
global_arguments=flexmock(dry_run=False),
local_path='borg',
remote_path=None,
)
+15 -15
View File
@@ -44,7 +44,7 @@ def test_display_repository_info_calls_borg_with_flags():
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -80,7 +80,7 @@ def test_display_repository_info_without_borg_features_calls_borg_with_info_sub_
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -121,7 +121,7 @@ def test_display_repository_info_with_log_info_calls_borg_with_info_flag():
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -155,7 +155,7 @@ def test_display_repository_info_with_log_info_and_json_suppresses_most_borg_out
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert json_output == '[]'
@@ -199,7 +199,7 @@ def test_display_repository_info_with_log_debug_calls_borg_with_debug_flag():
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -233,7 +233,7 @@ def test_display_repository_info_with_log_debug_and_json_suppresses_most_borg_ou
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert json_output == '[]'
@@ -268,7 +268,7 @@ def test_display_repository_info_with_json_calls_borg_with_json_flag():
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=True),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert json_output == '[]'
@@ -311,7 +311,7 @@ def test_display_repository_info_with_local_path_calls_borg_via_local_path():
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
@@ -354,7 +354,7 @@ def test_display_repository_info_with_exit_codes_calls_borg_using_them():
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -395,7 +395,7 @@ def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_fl
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
@@ -437,7 +437,7 @@ def test_display_repository_info_with_umask_calls_borg_with_umask_flags():
config={'umask': '077'},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path=None,
)
@@ -479,10 +479,10 @@ def test_display_repository_info_with_log_json_calls_borg_with_log_json_flags():
module.display_repository_info(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -524,7 +524,7 @@ def test_display_repository_info_with_lock_wait_calls_borg_with_lock_wait_flags(
config=config,
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -567,5 +567,5 @@ def test_display_repository_info_calls_borg_with_working_directory():
config={},
local_borg_version='2.3.4',
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+31 -31
View File
@@ -25,7 +25,7 @@ def test_resolve_archive_name_passes_through_non_latest_archive_name():
archive,
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== archive
)
@@ -49,7 +49,7 @@ def test_resolve_archive_name_calls_borg_with_flags():
'latest',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -74,7 +74,7 @@ def test_resolve_archive_name_with_log_info_calls_borg_without_info_flag():
'latest',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -99,7 +99,7 @@ def test_resolve_archive_name_with_log_debug_calls_borg_without_debug_flag():
'latest',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -123,7 +123,7 @@ def test_resolve_archive_name_with_local_path_calls_borg_via_local_path():
'latest',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg1',
)
== expected_archive
@@ -149,7 +149,7 @@ def test_resolve_archive_name_with_exit_codes_calls_borg_using_them():
'latest',
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -173,7 +173,7 @@ def test_resolve_archive_name_with_remote_path_calls_borg_with_remote_path_flags
'latest',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg1',
)
== expected_archive
@@ -198,7 +198,7 @@ def test_resolve_archive_name_with_umask_calls_borg_with_umask_flags():
'latest',
config={'umask': '077'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -221,7 +221,7 @@ def test_resolve_archive_name_without_archives_raises():
'latest',
config={},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -242,9 +242,9 @@ def test_resolve_archive_name_with_log_json_calls_borg_with_log_json_flags():
module.resolve_archive_name(
'repo',
'latest',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -269,7 +269,7 @@ def test_resolve_archive_name_with_lock_wait_calls_borg_with_lock_wait_flags():
'latest',
config={'lock_wait': 'okay'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -295,7 +295,7 @@ def test_resolve_archive_name_calls_borg_with_working_directory():
'latest',
config={'working_directory': '/working/dir'},
local_borg_version='1.2.3',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
== expected_archive
)
@@ -317,7 +317,7 @@ def test_make_repo_list_command_includes_log_info():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--info', 'repo')
@@ -339,7 +339,7 @@ def test_make_repo_list_command_includes_json_but_not_info():
repo_list_arguments=flexmock(
archive=None, paths=None, json=True, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--json', 'repo')
@@ -361,7 +361,7 @@ def test_make_repo_list_command_includes_log_debug():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--debug', '--show-rc', 'repo')
@@ -383,7 +383,7 @@ def test_make_repo_list_command_includes_json_but_not_debug():
repo_list_arguments=flexmock(
archive=None, paths=None, json=True, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--json', 'repo')
@@ -404,7 +404,7 @@ def test_make_repo_list_command_includes_json():
repo_list_arguments=flexmock(
archive=None, paths=None, json=True, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--json', 'repo')
@@ -422,12 +422,12 @@ def test_make_repo_list_command_includes_log_json():
command = module.make_repo_list_command(
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='1.2.3',
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--log-json', 'repo')
@@ -450,7 +450,7 @@ def test_make_repo_list_command_includes_lock_wait():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--lock-wait', '5', 'repo')
@@ -471,7 +471,7 @@ def test_make_repo_list_command_includes_local_path():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg2',
)
@@ -495,7 +495,7 @@ def test_make_repo_list_command_includes_remote_path():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg2',
)
@@ -519,7 +519,7 @@ def test_make_repo_list_command_includes_umask():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--umask', '077', 'repo')
@@ -540,7 +540,7 @@ def test_make_repo_list_command_transforms_prefix_into_match_archives():
config={},
local_borg_version='1.2.3',
repo_list_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--match-archives', 'sh:foo*', 'repo')
@@ -559,7 +559,7 @@ def test_make_repo_list_command_prefers_prefix_over_archive_name_format():
config={'archive_name_format': 'bar-{now}'}, # noqa: FS003
local_borg_version='1.2.3',
repo_list_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--match-archives', 'sh:foo*', 'repo')
@@ -580,7 +580,7 @@ def test_make_repo_list_command_transforms_archive_name_format_into_match_archiv
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--match-archives', 'sh:bar-*', 'repo')
@@ -601,7 +601,7 @@ def test_make_repo_list_command_includes_short():
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None, short=True
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--short', 'repo')
@@ -643,7 +643,7 @@ def test_make_repo_list_command_includes_additional_flags(argument_name):
format=None,
**{argument_name: 'value'},
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--' + argument_name.replace('_', '-'), 'value', 'repo')
@@ -675,7 +675,7 @@ def test_make_repo_list_command_with_match_archives_calls_borg_with_match_archiv
find_paths=None,
format=None,
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == ('borg', 'list', '--match-archives', 'foo-*', 'repo')
@@ -746,7 +746,7 @@ def test_make_repo_list_command_with_date_based_matching_calls_borg_with_date_ba
older='1m',
oldest='1w',
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
assert command == (
+19 -19
View File
@@ -35,7 +35,7 @@ def test_transfer_archives_calls_borg_with_flags():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -69,7 +69,7 @@ def test_transfer_archives_with_dry_run_calls_borg_with_dry_run_flag():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -100,7 +100,7 @@ def test_transfer_archives_with_log_info_calls_borg_with_info_flag():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -132,7 +132,7 @@ def test_transfer_archives_with_log_debug_calls_borg_with_debug_flag():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -165,7 +165,7 @@ def test_transfer_archives_with_archive_calls_borg_with_match_archives_flag():
transfer_arguments=flexmock(
archive='archive', progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -198,7 +198,7 @@ def test_transfer_archives_with_match_archives_calls_borg_with_match_archives_fl
transfer_arguments=flexmock(
archive=None, progress=None, match_archives='sh:foo*', source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -231,7 +231,7 @@ def test_transfer_archives_with_archive_name_format_calls_borg_with_match_archiv
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -262,7 +262,7 @@ def test_transfer_archives_with_local_path_calls_borg_via_local_path():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
local_path='borg2',
)
@@ -295,7 +295,7 @@ def test_transfer_archives_with_exit_codes_calls_borg_using_them():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -329,7 +329,7 @@ def test_transfer_archives_with_remote_path_calls_borg_with_remote_path_flags():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
remote_path='borg2',
)
@@ -363,7 +363,7 @@ def test_transfer_archives_with_umask_calls_borg_with_umask_flags():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -392,12 +392,12 @@ def test_transfer_archives_with_log_json_calls_borg_with_log_json_flags():
module.transfer_archives(
dry_run=False,
repository_path='repo',
config={},
config={'log_json': True},
local_borg_version='2.3.4',
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=True),
global_arguments=flexmock(),
)
@@ -432,7 +432,7 @@ def test_transfer_archives_with_lock_wait_calls_borg_with_lock_wait_flags():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -466,7 +466,7 @@ def test_transfer_archives_with_progress_calls_borg_with_progress_flags():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -505,7 +505,7 @@ def test_transfer_archives_passes_through_arguments_to_borg(argument_name):
source_repository=None,
**{argument_name: 'value'},
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -538,7 +538,7 @@ def test_transfer_archives_with_source_repository_calls_borg_with_other_repo_fla
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository='other'
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
@@ -580,7 +580,7 @@ def test_transfer_archives_with_date_based_matching_calls_borg_with_date_based_f
repository_path='repo',
config={},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
transfer_arguments=flexmock(
archive=None,
progress=None,
@@ -622,5 +622,5 @@ def test_transfer_archives_calls_borg_with_working_directory():
transfer_arguments=flexmock(
archive=None, progress=None, match_archives=None, source_repository=None
),
global_arguments=flexmock(log_json=False),
global_arguments=flexmock(),
)
+116 -77
View File
@@ -421,7 +421,7 @@ def test_run_configuration_runs_actions_for_each_repository():
expected_results[1:]
)
config = {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock())}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)}
results = list(module.run_configuration('test.yaml', config, ['/tmp/test.yaml'], arguments))
@@ -437,7 +437,7 @@ def test_run_configuration_with_skip_actions_does_not_raise():
flexmock(module).should_receive('Log_prefix').and_return(flexmock())
flexmock(module).should_receive('run_actions').and_return(flexmock()).and_return(flexmock())
config = {'repositories': [{'path': 'foo'}, {'path': 'bar'}], 'skip_actions': ['compact']}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock())}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)}
list(module.run_configuration('test.yaml', config, ['/tmp/test.yaml'], arguments))
@@ -452,7 +452,7 @@ def test_run_configuration_with_invalid_borg_version_errors():
flexmock(module).should_receive('run_actions').never()
config = {'repositories': [{'path': 'foo'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'prune': flexmock(),
}
@@ -472,7 +472,7 @@ def test_run_configuration_logs_actions_error():
flexmock(module.command).should_receive('filter_hooks')
flexmock(module.command).should_receive('execute_hooks')
config = {'repositories': [{'path': 'foo'}]}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock())}
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)}
results = list(module.run_configuration('test.yaml', config, ['/tmp/test.yaml'], arguments))
@@ -493,7 +493,7 @@ def test_run_configuration_skips_remaining_actions_for_actions_soft_failure_but_
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
config = {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -514,7 +514,7 @@ def test_run_configuration_does_not_call_monitoring_hooks_if_monitoring_hooks_ar
config = {'repositories': [{'path': 'foo'}]}
arguments = {
'global': flexmock(monitoring_verbosity=-2, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=-2, dry_run=False),
'create': flexmock(),
}
results = list(module.run_configuration('test.yaml', config, ['/tmp/test.yaml'], arguments))
@@ -537,7 +537,7 @@ def test_run_configuration_logs_on_error_hook_error():
flexmock(module).should_receive('run_actions').and_raise(OSError)
config = {'repositories': [{'path': 'foo'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -560,7 +560,7 @@ def test_run_configuration_logs_on_before_command_hook_error():
flexmock(module).should_receive('run_actions').never()
config = {'repositories': [{'path': 'foo'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -583,7 +583,7 @@ def test_run_configuration_logs_on_monitoring_hook_error():
flexmock(module).should_receive('run_actions').never()
config = {'repositories': [{'path': 'foo'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -607,7 +607,7 @@ def test_run_configuration_bails_for_on_error_hook_soft_failure():
flexmock(module).should_receive('run_actions').and_raise(OSError)
config = {'repositories': [{'path': 'foo'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -630,7 +630,7 @@ def test_run_configuration_retries_soft_error():
flexmock(module.command).should_receive('execute_hooks').never()
config = {'repositories': [{'path': 'foo'}], 'retries': 1}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -663,7 +663,7 @@ def test_run_configuration_retries_hard_error():
flexmock(module.command).should_receive('execute_hooks')
config = {'repositories': [{'path': 'foo'}], 'retries': 1}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -691,7 +691,7 @@ def test_run_configuration_retries_repositories_in_order():
flexmock(module.command).should_receive('execute_hooks')
config = {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -735,7 +735,7 @@ def test_run_configuration_retries_round_robin():
'retries': 1,
}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -777,7 +777,7 @@ def test_run_configuration_with_one_retry():
'retries': 1,
}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -830,7 +830,7 @@ def test_run_configuration_with_retry_wait_does_backoff_after_each_retry():
'retry_wait': 10,
}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -879,7 +879,7 @@ def test_run_configuration_with_multiple_repositories_retries_with_timeout():
'retry_wait': 10,
}
arguments = {
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
'create': flexmock(),
}
@@ -897,7 +897,7 @@ def test_run_actions_runs_repo_create():
tuple(
module.run_actions(
arguments={
'global': flexmock(dry_run=False, log_file='foo'),
'global': flexmock(dry_run=False),
'repo-create': flexmock(),
},
config_filename=flexmock(),
@@ -931,7 +931,7 @@ def test_run_actions_adds_label_file_to_hook_context():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file=None), 'create': flexmock()},
arguments={'global': flexmock(dry_run=False), 'create': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -952,7 +952,7 @@ def test_run_actions_adds_log_file_to_hook_context():
flexmock(borgmatic.actions.create).should_receive('run_create').with_args(
config_filename=object,
repository={'path': 'repo'},
config={'repositories': []},
config={'repositories': [], 'log_file': 'foo'},
config_paths=[],
local_borg_version=object,
create_arguments=object,
@@ -964,9 +964,9 @@ def test_run_actions_adds_log_file_to_hook_context():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'create': flexmock()},
arguments={'global': flexmock(dry_run=False), 'create': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config={'repositories': [], 'log_file': 'foo'},
config_paths=[],
local_path=flexmock(),
remote_path=flexmock(),
@@ -985,7 +985,7 @@ def test_run_actions_runs_transfer():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'transfer': flexmock()},
arguments={'global': flexmock(dry_run=False), 'transfer': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1006,7 +1006,7 @@ def test_run_actions_runs_create():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'create': flexmock()},
arguments={'global': flexmock(dry_run=False), 'create': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1027,7 +1027,7 @@ def test_run_actions_with_skip_actions_skips_create():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'create': flexmock()},
arguments={'global': flexmock(dry_run=False), 'create': flexmock()},
config_filename=flexmock(),
config={'repositories': [], 'skip_actions': ['create']},
config_paths=[],
@@ -1048,7 +1048,7 @@ def test_run_actions_runs_recreate():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'recreate': flexmock()},
arguments={'global': flexmock(dry_run=False), 'recreate': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1068,7 +1068,7 @@ def test_run_actions_with_skip_actions_skips_recreate():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'recreate': flexmock()},
arguments={'global': flexmock(dry_run=False), 'recreate': flexmock()},
config_filename=flexmock(),
config={'repositories': [], 'skip_actions': ['recreate']},
config_paths=[],
@@ -1088,7 +1088,7 @@ def test_run_actions_runs_prune():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'prune': flexmock()},
arguments={'global': flexmock(dry_run=False), 'prune': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1108,7 +1108,7 @@ def test_run_actions_with_skip_actions_skips_prune():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'prune': flexmock()},
arguments={'global': flexmock(dry_run=False), 'prune': flexmock()},
config_filename=flexmock(),
config={'repositories': [], 'skip_actions': ['prune']},
config_paths=[],
@@ -1128,7 +1128,7 @@ def test_run_actions_runs_compact():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'compact': flexmock()},
arguments={'global': flexmock(dry_run=False), 'compact': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1148,7 +1148,7 @@ def test_run_actions_with_skip_actions_skips_compact():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'compact': flexmock()},
arguments={'global': flexmock(dry_run=False), 'compact': flexmock()},
config_filename=flexmock(),
config={'repositories': [], 'skip_actions': ['compact']},
config_paths=[],
@@ -1169,7 +1169,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'check': flexmock()},
arguments={'global': flexmock(dry_run=False), 'check': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1190,7 +1190,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'check': flexmock()},
arguments={'global': flexmock(dry_run=False), 'check': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1211,7 +1211,7 @@ def test_run_actions_with_skip_actions_skips_check():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'check': flexmock()},
arguments={'global': flexmock(dry_run=False), 'check': flexmock()},
config_filename=flexmock(),
config={'repositories': [], 'skip_actions': ['check']},
config_paths=[],
@@ -1231,7 +1231,7 @@ def test_run_actions_runs_extract():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'extract': flexmock()},
arguments={'global': flexmock(dry_run=False), 'extract': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1251,7 +1251,7 @@ def test_run_actions_runs_export_tar():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'export-tar': flexmock()},
arguments={'global': flexmock(dry_run=False), 'export-tar': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1271,7 +1271,7 @@ def test_run_actions_runs_mount():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'mount': flexmock()},
arguments={'global': flexmock(dry_run=False), 'mount': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1291,7 +1291,7 @@ def test_run_actions_runs_restore():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'restore': flexmock()},
arguments={'global': flexmock(dry_run=False), 'restore': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1312,7 +1312,7 @@ def test_run_actions_runs_repo_list():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'repo-list': flexmock()},
arguments={'global': flexmock(dry_run=False), 'repo-list': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1334,7 +1334,7 @@ def test_run_actions_runs_list():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'list': flexmock()},
arguments={'global': flexmock(dry_run=False), 'list': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1356,7 +1356,7 @@ def test_run_actions_runs_repo_info():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'repo-info': flexmock()},
arguments={'global': flexmock(dry_run=False), 'repo-info': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1378,7 +1378,7 @@ def test_run_actions_runs_info():
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'info': flexmock()},
arguments={'global': flexmock(dry_run=False), 'info': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1399,7 +1399,7 @@ def test_run_actions_runs_break_lock():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'break-lock': flexmock()},
arguments={'global': flexmock(dry_run=False), 'break-lock': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1419,7 +1419,7 @@ def test_run_actions_runs_export_key():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'export': flexmock()},
arguments={'global': flexmock(dry_run=False), 'export': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1439,7 +1439,7 @@ def test_run_actions_runs_import_key():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'import': flexmock()},
arguments={'global': flexmock(dry_run=False), 'import': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1460,7 +1460,7 @@ def test_run_actions_runs_change_passphrase():
tuple(
module.run_actions(
arguments={
'global': flexmock(dry_run=False, log_file='foo'),
'global': flexmock(dry_run=False),
'change-passphrase': flexmock(),
},
config_filename=flexmock(),
@@ -1482,7 +1482,7 @@ def test_run_actions_runs_delete():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'delete': flexmock()},
arguments={'global': flexmock(dry_run=False), 'delete': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1503,7 +1503,7 @@ def test_run_actions_runs_repo_delete():
tuple(
module.run_actions(
arguments={
'global': flexmock(dry_run=False, log_file='foo'),
'global': flexmock(dry_run=False),
'repo-delete': flexmock(),
},
config_filename=flexmock(),
@@ -1525,7 +1525,7 @@ def test_run_actions_runs_borg():
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'borg': flexmock()},
arguments={'global': flexmock(dry_run=False), 'borg': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@@ -1547,7 +1547,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
tuple(
module.run_actions(
arguments={
'global': flexmock(dry_run=False, log_file='foo'),
'global': flexmock(dry_run=False),
'borg': flexmock(),
'restore': flexmock(),
},
@@ -1856,11 +1856,14 @@ def test_collect_configuration_run_summary_logs_info_for_success():
flexmock(module.command).should_receive('execute_hooks')
flexmock(module).should_receive('Log_prefix').and_return(flexmock())
flexmock(module).should_receive('run_configuration').and_return([])
arguments = {'global': flexmock(dry_run=False, log_file=flexmock())}
arguments = {'global': flexmock(dry_run=False)}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -1875,12 +1878,15 @@ def test_collect_configuration_run_summary_executes_hooks_for_create():
flexmock(module).should_receive('run_configuration').and_return([])
arguments = {
'create': flexmock(),
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -1895,12 +1901,15 @@ def test_collect_configuration_run_summary_logs_info_for_success_with_extract():
flexmock(module).should_receive('run_configuration').and_return([])
arguments = {
'extract': flexmock(repository='repo'),
'global': flexmock(dry_run=False, log_file=flexmock()),
'global': flexmock(dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -1913,11 +1922,14 @@ def test_collect_configuration_run_summary_logs_extract_with_repository_error():
)
expected_logs = (flexmock(),)
flexmock(module).should_receive('log_error_records').and_return(expected_logs)
arguments = {'extract': flexmock(repository='repo', log_file=flexmock())}
arguments = {'extract': flexmock(repository='repo')}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -1932,12 +1944,15 @@ def test_collect_configuration_run_summary_logs_info_for_success_with_mount():
flexmock(module).should_receive('run_configuration').and_return([])
arguments = {
'mount': flexmock(repository='repo'),
'global': flexmock(dry_run=False, log_file=flexmock()),
'global': flexmock(dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -1952,12 +1967,15 @@ def test_collect_configuration_run_summary_logs_mount_with_repository_error():
flexmock(module).should_receive('log_error_records').and_return(expected_logs)
arguments = {
'mount': flexmock(repository='repo'),
'global': flexmock(dry_run=False, log_file=flexmock()),
'global': flexmock(dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -1968,12 +1986,14 @@ def test_collect_configuration_run_summary_logs_missing_configs_error():
flexmock(module.validate).should_receive('guard_configuration_contains_repository')
flexmock(module.command).should_receive('filter_hooks')
flexmock(module.command).should_receive('execute_hooks')
arguments = {'global': flexmock(config_paths=[], log_file=flexmock())}
arguments = {'global': flexmock(config_paths=[])}
expected_logs = (flexmock(),)
flexmock(module).should_receive('log_error_records').and_return(expected_logs)
logs = tuple(
module.collect_configuration_run_summary_logs({}, config_paths=[], arguments=arguments)
module.collect_configuration_run_summary_logs(
{}, config_paths=[], arguments=arguments, log_file_path=None
)
)
assert logs == expected_logs
@@ -1987,12 +2007,15 @@ def test_collect_configuration_run_summary_logs_pre_hook_error():
flexmock(module).should_receive('log_error_records').and_return(expected_logs)
arguments = {
'create': flexmock(),
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -2009,12 +2032,15 @@ def test_collect_configuration_run_summary_logs_post_hook_error():
flexmock(module).should_receive('log_error_records').and_return(expected_logs)
arguments = {
'create': flexmock(),
'global': flexmock(monitoring_verbosity=1, dry_run=False, log_file=flexmock()),
'global': flexmock(monitoring_verbosity=1, dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -2029,12 +2055,15 @@ def test_collect_configuration_run_summary_logs_for_list_with_archive_and_reposi
flexmock(module).should_receive('log_error_records').and_return(expected_logs)
arguments = {
'list': flexmock(repository='repo', archive='test'),
'global': flexmock(dry_run=False, log_file=flexmock()),
'global': flexmock(dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -2049,12 +2078,15 @@ def test_collect_configuration_run_summary_logs_info_for_success_with_list():
flexmock(module).should_receive('run_configuration').and_return([])
arguments = {
'list': flexmock(repository='repo', archive=None),
'global': flexmock(dry_run=False, log_file=flexmock()),
'global': flexmock(dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -2070,11 +2102,14 @@ def test_collect_configuration_run_summary_logs_run_configuration_error_logs():
[logging.makeLogRecord(dict(levelno=logging.CRITICAL, levelname='CRITICAL', msg='Error'))]
)
flexmock(module).should_receive('log_error_records').and_return([])
arguments = {'global': flexmock(dry_run=False, log_file=flexmock())}
arguments = {'global': flexmock(dry_run=False)}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -2093,12 +2128,15 @@ def test_collect_configuration_run_summary_logs_run_umount_error():
)
arguments = {
'umount': flexmock(mount_point='/mnt'),
'global': flexmock(dry_run=False, log_file=flexmock()),
'global': flexmock(dry_run=False),
}
logs = tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}}, config_paths=['/tmp/test.yaml'], arguments=arguments
{'test.yaml': {}},
config_paths=['/tmp/test.yaml'],
arguments=arguments,
log_file_path=None,
)
)
@@ -2116,13 +2154,14 @@ def test_collect_configuration_run_summary_logs_outputs_merged_json_results():
stdout = flexmock()
stdout.should_receive('write').with_args('["foo", "bar", "baz"]').once()
flexmock(module.sys).stdout = stdout
arguments = {'global': flexmock(dry_run=False, log_file=flexmock())}
arguments = {'global': flexmock(dry_run=False)}
tuple(
module.collect_configuration_run_summary_logs(
{'test.yaml': {}, 'test2.yaml': {}},
config_paths=['/tmp/test.yaml', '/tmp/test2.yaml'],
arguments=arguments,
log_file_path=None,
)
)