예제 #1
0
def test_parse_arguments_allows_repository_with_extract():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    module.parse_arguments('--config', 'myconfig', '--extract', '--repository',
                           'test.borg', '--archive', 'test')
예제 #2
0
def test_parse_arguments_allows_archive_with_list():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    module.parse_arguments('--config', 'myconfig', '--list', '--archive',
                           'test')
예제 #3
0
def test_parse_arguments_disallows_archive_without_extract_or_list():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--archive', 'test')
예제 #4
0
def test_parse_arguments_disallows_progress_without_create():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--progress', '--list')
예제 #5
0
def test_parse_arguments_allows_progress_and_extract():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    module.parse_arguments('--progress', '--extract', '--archive', 'test',
                           '--list')
예제 #6
0
def test_parse_arguments_requires_encryption_mode_with_init():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--init')
예제 #7
0
def test_parse_arguments_allows_json_with_list_or_info():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    module.parse_arguments('--list', '--json')
    module.parse_arguments('--info', '--json')
예제 #8
0
def test_parse_arguments_disallows_storage_quota_without_init():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--storage-quota', '5G')
예제 #9
0
def test_parse_arguments_disallows_append_only_without_init():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--append-only')
예제 #10
0
def test_parse_arguments_allows_init_and_create():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    module.parse_arguments('--config', 'myconfig', '--init', '--encryption',
                           'repokey', '--create')
예제 #11
0
def test_parse_arguments_with_invalid_arguments_exits():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(SystemExit):
        module.parse_arguments('--posix-me-harder')
예제 #12
0
def test_parse_arguments_disallows_init_and_dry_run():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments(
            '--config', 'myconfig', '--init', '--encryption', 'repokey', '--dry-run'
        )
예제 #13
0
def test_parse_arguments_disallows_init_and_dry_run():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--init', '--dry-run')
예제 #14
0
def test_parse_arguments_disallows_json_with_both_list_and_info():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--list', '--info', '--json')
예제 #15
0
def test_parse_arguments_disallows_deprecated_excludes_option():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--excludes',
                               'myexcludes')
예제 #16
0
def test_parse_arguments_with_stats_flag_but_no_create_or_prune_flag_raises_value_error(
):
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--stats', '--list')
예제 #17
0
def test_parse_arguments_with_path_arguments_overrides_defaults():
    parser = module.parse_arguments('--config', 'myconfig', '--excludes',
                                    'myexcludes')

    assert parser.config_paths == ['myconfig']
    assert parser.excludes_filename == 'myexcludes'
    assert parser.verbosity is None
예제 #18
0
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')

    assert parser.config_paths == ['myconfig', 'otherconfig']
    assert parser.verbosity is 0
예제 #19
0
def test_parse_arguments_with_no_actions_defaults_to_all_actions_enabled():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    parser = module.parse_arguments()

    assert parser.prune is True
    assert parser.create is True
    assert parser.check is True
예제 #20
0
def test_parse_arguments_with_multiple_actions_leaves_other_action_disabled():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    parser = module.parse_arguments('--create', '--check')

    assert parser.prune is False
    assert parser.create is True
    assert parser.check is True
예제 #21
0
def test_parse_arguments_with_verbosity_overrides_default():
    config_paths = ['default']
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)

    parser = module.parse_arguments('--verbosity', '1')

    assert parser.config_paths == config_paths
    assert parser.excludes_filename is None
    assert parser.verbosity == 1
예제 #22
0
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')

    assert parser.config_paths == ['myconfig', 'otherconfig']
    assert parser.verbosity is 0
예제 #23
0
def test_parse_arguments_with_multiple_actions_leaves_other_action_disabled():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    parser = module.parse_arguments('--create', '--check')

    assert parser.prune is False
    assert parser.create is True
    assert parser.check is True
예제 #24
0
def test_parse_arguments_with_no_arguments_uses_defaults():
    config_paths = ['default']
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)

    parser = module.parse_arguments()

    assert parser.config_paths == config_paths
    assert parser.excludes_filename is None
    assert parser.verbosity is 0
    assert parser.json is False
예제 #25
0
def test_parse_arguments_with_verbosity_overrides_default():
    config_paths = ['default']
    flexmock(module.collect).should_receive(
        'get_default_config_paths').and_return(config_paths)

    parser = module.parse_arguments('--verbosity', '1')

    assert parser.config_paths == config_paths
    assert parser.excludes_filename is None
    assert parser.verbosity == 1
예제 #26
0
def test_parse_arguments_with_no_actions_defaults_to_all_actions_enabled():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    parser = module.parse_arguments()

    assert parser.prune is True
    assert parser.create is True
    assert parser.check is True
예제 #27
0
def test_parse_arguments_with_no_arguments_uses_defaults():
    config_paths = ['default']
    flexmock(module.collect).should_receive(
        'get_default_config_paths').and_return(config_paths)

    parser = module.parse_arguments()

    assert parser.config_paths == config_paths
    assert parser.excludes_filename is None
    assert parser.verbosity is 0
    assert parser.json is False
예제 #28
0
def test_parse_arguments_with_path_arguments_overrides_defaults():
    flexmock(
        module.collect).should_receive('get_default_config_paths').and_return(
            ['default'])

    parser = module.parse_arguments('--config', 'myconfig', '--excludes',
                                    'myexcludes')

    assert parser.config_paths == ['myconfig']
    assert parser.excludes_filename == 'myexcludes'
    assert parser.verbosity is 0
예제 #29
0
def test_parse_arguments_with_stats_flag_but_no_create_or_prune_flag_raises_value_error():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--stats', '--list')
예제 #30
0
def test_parse_arguments_with_json_overrides_default():
    parser = module.parse_arguments('--list', '--json')
    assert parser.json is True
예제 #31
0
def test_parse_arguments_disallows_deprecated_excludes_option():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--excludes', 'myexcludes')
예제 #32
0
def test_parse_arguments_disallows_json_without_list_or_info():
    with pytest.raises(ValueError):
        module.parse_arguments('--json')
예제 #33
0
def test_parse_arguments_with_stats_flag_but_no_create_or_prune_flag_raises_value_error(
):
    with pytest.raises(ValueError):
        module.parse_arguments('--stats', '--list')
예제 #34
0
def test_parse_arguments_disallows_progress_without_create():
    with pytest.raises(ValueError):
        module.parse_arguments('--progress', '--list')
예제 #35
0
def test_parse_arguments_disallows_restore_paths_without_extract():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--restore-path', 'test')
예제 #36
0
def test_parse_arguments_with_verbosity_flag_overrides_default():
    parser = module.parse_arguments('--verbosity', '1')

    assert parser.config_paths == module.collect.DEFAULT_CONFIG_PATHS
    assert parser.excludes_filename == None
    assert parser.verbosity == 1
예제 #37
0
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
    parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')

    assert parser.config_paths == ['myconfig', 'otherconfig']
    assert parser.verbosity is None
예제 #38
0
def test_parse_arguments_with_path_arguments_overrides_defaults():
    parser = module.parse_arguments('--config', 'myconfig', '--excludes', 'myexcludes')

    assert parser.config_paths == ['myconfig']
    assert parser.excludes_filename == 'myexcludes'
    assert parser.verbosity is None
예제 #39
0
def test_parse_arguments_with_just_stats_flag_does_not_raise():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    module.parse_arguments('--stats')
예제 #40
0
def test_parse_arguments_disallows_storage_quota_without_init():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--storage-quota', '5G')
예제 #41
0
def test_parse_arguments_allows_progress_and_extract():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    module.parse_arguments('--progress', '--extract', '--archive', 'test', '--list')
예제 #42
0
def test_parse_arguments_requires_archive_with_extract():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--extract')
예제 #43
0
def test_parse_arguments_allows_archive_with_list():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    module.parse_arguments('--config', 'myconfig', '--list', '--archive', 'test')
예제 #44
0
def test_parse_arguments_allows_json_with_list_or_info():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    module.parse_arguments('--list', '--json')
    module.parse_arguments('--info', '--json')
예제 #45
0
def test_parse_arguments_allows_progress_and_create():
    module.parse_arguments('--progress', '--create', '--list')
예제 #46
0
def test_parse_arguments_allows_repository_with_extract():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    module.parse_arguments(
        '--config', 'myconfig', '--extract', '--repository', 'test.borg', '--archive', 'test'
    )
예제 #47
0
def test_parse_arguments_with_stats_and_prune_flags_does_not_raise():
    module.parse_arguments('--stats', '--prune', '--list')
예제 #48
0
def test_parse_arguments_disallows_json_with_both_list_and_info():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--list', '--info', '--json')
예제 #49
0
def test_parse_arguments_allows_json_with_list_or_info():
    module.parse_arguments('--list', '--json')
    module.parse_arguments('--info', '--json')
예제 #50
0
def test_parse_arguments_with_invalid_arguments_exits():
    with pytest.raises(SystemExit):
        module.parse_arguments('--posix-me-harder')
예제 #51
0
def test_parse_arguments_disallows_json_with_both_list_and_info():
    with pytest.raises(ValueError):
        module.parse_arguments('--list', '--info', '--json')
예제 #52
0
def test_parse_arguments_with_no_arguments_uses_defaults():
    parser = module.parse_arguments()

    assert parser.config_paths == module.collect.DEFAULT_CONFIG_PATHS
    assert parser.excludes_filename == None
    assert parser.verbosity is None
예제 #53
0
def test_parse_arguments_with_invalid_arguments_exits():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(SystemExit):
        module.parse_arguments('--posix-me-harder')
예제 #54
0
def test_parse_arguments_allows_encryption_mode_with_init():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    module.parse_arguments('--config', 'myconfig', '--init', '--encryption', 'repokey')
예제 #55
0
def test_parse_arguments_with_no_actions_defaults_to_all_actions_enabled():
    parser = module.parse_arguments()

    assert parser.prune is True
    assert parser.create is True
    assert parser.check is True
예제 #56
0
def test_parse_arguments_disallows_progress_without_create():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--progress', '--list')
예제 #57
0
def test_parse_arguments_with_prune_action_leaves_other_actions_disabled():
    parser = module.parse_arguments('--prune')

    assert parser.prune is True
    assert parser.create is False
    assert parser.check is False
예제 #58
0
def test_parse_arguments_with_multiple_actions_leaves_other_action_disabled():
    parser = module.parse_arguments('--create', '--check')

    assert parser.prune is False
    assert parser.create is True
    assert parser.check is True
예제 #59
0
def test_parse_arguments_disallows_append_only_without_init():
    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])

    with pytest.raises(ValueError):
        module.parse_arguments('--config', 'myconfig', '--append-only')
예제 #60
0
def test_parse_arguments_with_json_overrides_default():
    parser = module.parse_arguments('--list', '--json')
    assert parser.json is True