本文整理汇总了Python中testing_helpers.build_config_dictionary函数的典型用法代码示例。如果您正苦于以下问题:Python build_config_dictionary函数的具体用法?Python build_config_dictionary怎么用?Python build_config_dictionary使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_config_dictionary函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_csv_values_recovery_options
def test_csv_values_recovery_options(self):
"""
Simple test for recovery_options values: '' and get-wal
test case
global value: recovery_options = ''
expected: recovery_options = None
test case
global value: recovery_options = 'get-wal'
expected: recovery_options = empty RecoveryOptions obj
"""
# Build configuration with empty recovery_options
c = build_config_from_dicts({'recovery_options': ''}, None)
main = c.get_server('main')
expected = build_config_dictionary({
'config': c,
'recovery_options': RecoveryOptions('', '', ''),
})
assert main.__dict__ == expected
# Build configuration with recovery_options set to get-wal
c = build_config_from_dicts({'recovery_options': 'get-wal'}, None)
main = c.get_server('main')
expected = build_config_dictionary({
'config': c,
'recovery_options': RecoveryOptions('get-wal', '', ''),
})
assert main.__dict__ == expected
开发者ID:gcalacoci,项目名称:barman,代码行数:31,代码来源:test_config.py
示例2: test_config
def test_config(self):
"""
Test for a basic configuration object construction
"""
fp = StringIO(TEST_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({
'config': main.config,
'compression': 'gzip',
'last_backup_maximum_age': timedelta(1),
'last_backup_minimum_size': 1048576,
'last_wal_maximum_age': timedelta(hours=1),
'retention_policy': 'redundancy 3',
'reuse_backup': 'link',
'description': 'Main PostgreSQL Database',
'ssh_command': 'ssh -c arcfour -p 22 [email protected]',
'wal_retention_policy': 'base',
'custom_compression_filter': 'bzip2 -c -9',
'wals_directory': 'wals',
'custom_decompression_filter': 'bzip2 -c -d'
})
assert main.__dict__ == expected
web = c.get_server('web')
# create the expected dictionary
expected = build_config_dictionary({
'config': web.config,
'backup_directory': '/some/barman/home/web',
'basebackups_directory': '/some/barman/home/web/base',
'compression': None,
'conninfo': 'host=web01 user=postgres port=5432',
'description': 'Web applications database',
'incoming_wals_directory': '/some/barman/home/web/incoming',
'name': 'web',
'reuse_backup': None,
'retention_policy': 'redundancy 2',
'wals_directory': '/some/barman/home/web/wals',
'wal_retention_policy': 'base',
'last_backup_maximum_age': timedelta(1),
'last_backup_minimum_size': 1048576,
'last_wal_maximum_age': timedelta(hours=1),
'ssh_command': 'ssh -I ~/.ssh/web01_rsa -c arcfour '
'-p 22 [email protected]',
'streaming_conninfo': 'host=web01 user=postgres port=5432',
'streaming_wals_directory': '/some/barman/home/web/streaming',
'errors_directory': '/some/barman/home/web/errors',
})
assert web.__dict__ == expected
开发者ID:infoxchange,项目名称:barman,代码行数:51,代码来源:test_config.py
示例3: test_csv_values_multikey_invalid_server_value
def test_csv_values_multikey_invalid_server_value(self, out_mock):
"""
test case
global: backup_options = concurrent_backup
server: backup_options = exclusive_backup, none_of_your_business
result = backup_options = concurrent_backup
the 'none_of_your_business' value on server section invalidates the
whole csv string, because is not an allowed value of the BackupOptions
class.
We expect to fallback to the global 'concurrent_backup' value.
"""
# build a string with a wrong value
wrong_parameters = "%s, %s" % (BackupOptions.EXCLUSIVE_BACKUP,
'none_of_your_business')
# add backup_options to minimal configuration string
c = build_config_from_dicts(
{'backup_options': BackupOptions.CONCURRENT_BACKUP},
{'backup_options': wrong_parameters})
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({
'config': main.config,
'backup_options': set(['concurrent_backup']),
})
assert main.__dict__ == expected
# use the mocked output class to verify the presence of the warning
# for a bad configuration parameter
out_mock.warning.assert_called_with("Invalid configuration value '%s' "
"for key %s in %s: %s", None,
'backup_options',
'[main] section', mock.ANY)
开发者ID:stig,项目名称:barman,代码行数:32,代码来源:test_config.py
示例4: test_csv_values_invalid_server_value
def test_csv_values_invalid_server_value(self, out_mock):
"""
test case
global: backup_options = exclusive_backup
server: backup_options = none_of_your_business
result = backup_options = exclusive_backup
The 'none_of_your_business' value on server section,
is not an allowed value for the BackupOptions class,
We expect to the config builder to fallback to the global
'exclusive_backup' value
"""
# add backup_options to minimal configuration string
c = build_config_from_dicts(
{'backup_options': BackupOptions.EXCLUSIVE_BACKUP},
{'backup_options': 'none_of_your_business'})
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({'config': main.config})
assert main.__dict__ == expected
# use the mocked output class to verify the presence of the warning
# for a bad configuration parameter
out_mock.warning.assert_called_with("Invalid configuration value '%s' "
"for key %s in %s: %s",
None, 'backup_options',
'[main] section', mock.ANY)
开发者ID:stig,项目名称:barman,代码行数:27,代码来源:test_config.py
示例5: test_csv_values_global_conflict
def test_csv_values_global_conflict(self, out_mock):
"""
test case
global value: backup_options = exclusive_backup, concurrent_backup
server value: backup_options =
expected: backup_options = exclusive_backup
Empty value is not allowed in BackupOptions class, so we expect the
configuration parser to fall back to the global value.
The global backup_options holds conflicting parameters, so we expect the
config builder to fall back to ignore de directive.
:param out_mock: Mock the output
"""
# build a string with conflicting values
conflict = "%s, %s" % (BackupOptions.EXCLUSIVE_BACKUP,
BackupOptions.CONCURRENT_BACKUP)
# add backup_options to minimal configuration string
c = build_config_from_dicts(
{'backup_options': conflict},
None)
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({'config': main.config})
assert main.__dict__ == expected
# use the mocked output class to verify the presence of the warning
# for a bad configuration parameter
out_mock.warning.assert_called_with("Invalid configuration value '%s' "
"for key %s in %s: %s", None,
'backup_options',
'[barman] section', mock.ANY)
开发者ID:stig,项目名称:barman,代码行数:31,代码来源:test_config.py
示例6: test_server_conflict_paths
def test_server_conflict_paths(self):
"""
Test for the presence of conflicting paths for a server
"""
# Build a configuration with conflicts:
# basebackups_directory = /some/barman/home/main/wals
# wals_directory = /some/barman/home/main/wals
c = build_config_from_dicts(main_conf={
'archiver': 'on',
'basebackups_directory': '/some/barman/home/main/wals',
'description': ' Text with quotes ',
})
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({
'config': main.config,
'disabled': True,
'basebackups_directory': '/some/barman/home/main/wals',
'msg_list': [
'Conflicting path: wals_directory=/some/barman/home/main/wals '
'conflicts with \'basebackups_directory\' '
'for server \'main\''],
'description': 'Text with quotes',
})
assert main.__dict__ == expected
开发者ID:moench-tegeder,项目名称:barman,代码行数:25,代码来源:test_config.py
示例7: test_interpolation
def test_interpolation(self):
"""
Basic interpolation test
"""
fp = StringIO(MINIMAL_CONFIG.format(**os.environ))
c = Config(fp)
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({'config': main.config})
assert main.__dict__ == expected
开发者ID:stig,项目名称:barman,代码行数:11,代码来源:test_config.py
示例8: test_csv_values_global_concurrent
def test_csv_values_global_concurrent(self):
"""
test case
global value: backup_options = concurrent_backup
expected: backup_options = concurrent_backup
Simple test for concurrent_backup option parsing
"""
# add backup_options to minimal configuration string
c = build_config_from_dicts(
{'backup_options': BackupOptions.CONCURRENT_BACKUP},
None)
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({
'config': main.config,
'backup_options': set(['concurrent_backup']),
})
assert main.__dict__ == expected
开发者ID:stig,项目名称:barman,代码行数:19,代码来源:test_config.py
示例9: test_csv_values_global_exclusive
def test_csv_values_global_exclusive(self):
"""
test case
global value: backup_options = exclusive_backup
server value: backup_options =
expected: backup_options = exclusive_backup
Empty value is not allowed in BackupOptions class, so we expect the
configuration parser to fall back to the global value.
"""
# add backup_options configuration to minimal configuration string
c = build_config_from_dicts(
{'backup_options': BackupOptions.EXCLUSIVE_BACKUP},
{'backup_options': ''})
main = c.get_server('main')
# create the expected dictionary
expected = build_config_dictionary({'config': main.config})
assert main.__dict__ == expected
开发者ID:stig,项目名称:barman,代码行数:20,代码来源:test_config.py
示例10: test_manage_server_command
def test_manage_server_command(self, monkeypatch, capsys):
"""
Test manage_server_command method checking
the various types of error output
:param monkeypatch monkeypatch: pytest patcher
"""
# Build a server with a config with path conflicts
monkeypatch.setattr(barman, '__config__', build_config_from_dicts(
main_conf=build_config_dictionary({
'wals_directory': '/some/barman/home/main/wals',
'basebackups_directory': '/some/barman/home/main/wals',
'archiver': 'on',
})))
server = Server(barman.__config__.get_server('main'))
# Test a not blocking WARNING message
manage_server_command(server)
out, err = capsys.readouterr()
# Expect an ERROR message because of conflicting paths
assert 'ERROR: Conflicting path' in err
# Build a server with a config without path conflicts
monkeypatch.setattr(barman, '__config__', build_config_from_dicts())
server = Server(barman.__config__.get_server('main'))
# Set the server as not active
server.config.active = False
# Request to treat inactive as errors
to_be_executed = manage_server_command(server, inactive_is_error=True)
out, err = capsys.readouterr()
# Expect a ERROR message because of a not active server
assert 'ERROR: Inactive server' in err
assert not to_be_executed
# Request to treat inactive as warning
to_be_executed = manage_server_command(server, inactive_is_error=False)
out, err = capsys.readouterr()
# Expect no error whatsoever
assert err == ''
assert not to_be_executed
开发者ID:moench-tegeder,项目名称:barman,代码行数:39,代码来源:test_cli.py
注:本文中的testing_helpers.build_config_dictionary函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论