예제 #1
0
def test_display_archives_info_with_log_info_calls_borg_with_info_parameter():
    insert_subprocess_mock(INFO_COMMAND + ('--info',))
    insert_logging_mock(logging.INFO)
    module.display_archives_info(
        repository='repo',
        storage_config={},
    )
예제 #2
0
def test_list_archives_with_log_debug_calls_borg_with_debug_parameter():
    insert_subprocess_mock(LIST_COMMAND + ('--debug', '--show-rc'))
    insert_logging_mock(logging.DEBUG)

    module.list_archives(
        repository='repo',
        storage_config={},
    )
예제 #3
0
def test_prune_archives_with_log_debug_calls_borg_with_debug_parameter():
    retention_config = flexmock()
    flexmock(module).should_receive('_make_prune_flags').with_args(
        retention_config).and_return(BASE_PRUNE_FLAGS, )
    insert_subprocess_mock(PRUNE_COMMAND +
                           ('--stats', '--debug', '--list', '--show-rc'))
    insert_logging_mock(logging.DEBUG)

    module.prune_archives(
        repository='repo',
        storage_config={},
        dry_run=False,
        retention_config=retention_config,
    )
예제 #4
0
def test_extract_last_archive_dry_run_with_log_debug_should_call_borg_with_debug_parameter(
):
    flexmock(sys.stdout).encoding = 'utf-8'
    insert_subprocess_check_output_mock(
        ('borg', 'list', '--short', 'repo', '--debug', '--show-rc'),
        result='archive1\narchive2\n'.encode('utf-8'),
    )
    insert_subprocess_mock(('borg', 'extract', '--dry-run', 'repo::archive2',
                            '--debug', '--show-rc', '--list'), )
    insert_logging_mock(logging.DEBUG)

    module.extract_last_archive_dry_run(
        repository='repo',
        lock_wait=None,
    )
예제 #5
0
def test_check_archives_with_log_debug_calls_borg_with_debug_parameter():
    checks = ('repository',)
    consistency_config = {'check_last': None}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').and_return(())
    insert_logging_mock(logging.DEBUG)
    insert_subprocess_mock(
        ('borg', 'check', 'repo', '--debug', '--show-rc'),
        stdout=None, stderr=STDOUT,
    )

    module.check_archives(
        repository='repo',
        storage_config={},
        consistency_config=consistency_config,
    )
예제 #6
0
def test_create_archive_with_log_debug_calls_borg_with_debug_parameter():
    flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')).and_return(())
    flexmock(module).should_receive('_write_pattern_file').and_return(None)
    flexmock(module).should_receive('_make_pattern_flags').and_return(())
    flexmock(module).should_receive('_make_exclude_flags').and_return(())
    insert_subprocess_mock(CREATE_COMMAND + ('--list', '--filter', 'AME','--stats', '--debug', '--show-rc'))
    insert_logging_mock(logging.DEBUG)

    module.create_archive(
        dry_run=False,
        repository='repo',
        location_config={
            'source_directories': ['foo', 'bar'],
            'repositories': ['repo'],
            'exclude_patterns': None,
        },
        storage_config={},
    )
예제 #7
0
def test_create_archive_with_dry_run_and_log_debug_calls_borg_without_stats_parameter():
    """ --dry-run and --stats are mutually exclusive, see:
    https://borgbackup.readthedocs.io/en/stable/usage/create.html#description """
    flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')).and_return(())
    flexmock(module).should_receive('_write_pattern_file').and_return(None)
    flexmock(module).should_receive('_make_pattern_flags').and_return(())
    flexmock(module).should_receive('_make_pattern_flags').and_return(())
    flexmock(module).should_receive('_make_exclude_flags').and_return(())
    insert_subprocess_mock(CREATE_COMMAND + ('--list', '--filter', 'AME', '--debug', '--show-rc', '--dry-run'))
    insert_logging_mock(logging.DEBUG)

    module.create_archive(
        dry_run=True,
        repository='repo',
        location_config={
            'source_directories': ['foo', 'bar'],
            'repositories': ['repo'],
            'exclude_patterns': None,
        },
        storage_config={},
    )