How to use the borgmatic.config.legacy.Config_option function in borgmatic

To help you get started, we’ve selected a few borgmatic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_validate_configuration_format_with_missing_optional_option_should_not_raise():
    parser = flexmock()
    parser.should_receive('sections').and_return(('section',))
    parser.should_receive('options').with_args('section').and_return(('option',))
    config_format = (
        module.Section_format(
            'section',
            options=(
                module.Config_option('option', str, required=True),
                module.Config_option('missing', str, required=False),
            ),
        ),
    )

    module.validate_configuration_format(parser, config_format)
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_validate_configuration_format_with_missing_required_option_should_raise():
    parser = flexmock()
    parser.should_receive('sections').and_return(('section',))
    parser.should_receive('options').with_args('section').and_return(('option',))
    config_format = (
        module.Section_format(
            'section',
            options=(
                module.Config_option('option', str, required=True),
                module.Config_option('missing', str, required=True),
            ),
        ),
    )

    with pytest.raises(ValueError):
        module.validate_configuration_format(parser, config_format)
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_option_should_create_config_option():
    option = module.option('name', bool, required=False)

    assert option == module.Config_option('name', bool, False)
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_validate_configuration_format_with_missing_required_section_should_raise():
    parser = flexmock()
    parser.should_receive('sections').and_return(('section',))
    config_format = (
        module.Section_format(
            'section', options=(module.Config_option('stuff', str, required=True),)
        ),
        # At least one option in this section is required, so the section is required.
        module.Section_format(
            'missing',
            options=(
                module.Config_option('such', str, required=False),
                module.Config_option('things', str, required=True),
            ),
        ),
    )

    with pytest.raises(ValueError):
        module.validate_configuration_format(parser, config_format)
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_validate_configuration_format_with_missing_optional_section_should_not_raise():
    parser = flexmock()
    parser.should_receive('sections').and_return(('section',))
    parser.should_receive('options').with_args('section').and_return(('stuff',))
    config_format = (
        module.Section_format(
            'section', options=(module.Config_option('stuff', str, required=True),)
        ),
        # No options in the section are required, so the section is optional.
        module.Section_format(
            'missing',
            options=(
                module.Config_option('such', str, required=False),
                module.Config_option('things', str, required=False),
            ),
        ),
    )

    module.validate_configuration_format(parser, config_format)
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_parse_section_options_for_missing_section_should_return_empty_dict():
    parser = flexmock()
    parser.should_receive('get').never()
    parser.should_receive('getint').never()
    parser.should_receive('getboolean').never()
    parser.should_receive('has_option').with_args('section', 'foo').and_return(False)
    parser.should_receive('has_option').with_args('section', 'bar').and_return(False)

    section_format = module.Section_format(
        'section',
        (
            module.Config_option('foo', str, required=False),
            module.Config_option('bar', int, required=False),
        ),
    )

    config = module.parse_section_options(parser, section_format)

    assert config == OrderedDict()
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_option_should_create_config_option_with_defaults():
    option = module.option('name')

    assert option == module.Config_option('name', str, True)
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_validate_configuration_format_with_missing_required_option_should_raise():
    parser = flexmock()
    parser.should_receive('sections').and_return(('section',))
    parser.should_receive('options').with_args('section').and_return(('option',))
    config_format = (
        module.Section_format(
            'section',
            options=(
                module.Config_option('option', str, required=True),
                module.Config_option('missing', str, required=True),
            ),
        ),
    )

    with pytest.raises(ValueError):
        module.validate_configuration_format(parser, config_format)
github witten / borgmatic / tests / integration / config / test_legacy.py View on Github external
def test_parse_section_options_with_punctuation_should_return_section_options():
    parser = module.RawConfigParser()
    parser.read_file(StringIO('[section]\nfoo: {}\n'.format(string.punctuation)))

    section_format = module.Section_format(
        'section', (module.Config_option('foo', str, required=True),)
    )

    config = module.parse_section_options(parser, section_format)

    assert config == OrderedDict((('foo', string.punctuation),))
github witten / borgmatic / tests / unit / config / test_legacy.py View on Github external
def test_validate_configuration_format_with_valid_config_should_not_raise():
    parser = flexmock()
    parser.should_receive('sections').and_return(('section', 'other'))
    parser.should_receive('options').with_args('section').and_return(('stuff',))
    parser.should_receive('options').with_args('other').and_return(('such',))
    config_format = (
        module.Section_format(
            'section', options=(module.Config_option('stuff', str, required=True),)
        ),
        module.Section_format('other', options=(module.Config_option('such', str, required=True),)),
    )

    module.validate_configuration_format(parser, config_format)