本文整理汇总了Python中testing_helpers.build_config_from_dicts函数的典型用法代码示例。如果您正苦于以下问题:Python build_config_from_dicts函数的具体用法?Python build_config_from_dicts怎么用?Python build_config_from_dicts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_config_from_dicts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_bad_init
def test_bad_init(self):
"""
Check the server is buildable with an empty configuration
"""
server = Server(build_config_from_dicts(
main_conf={
'conninfo': '',
'ssh_command': '',
}
).get_server('main'))
assert server.config.disabled
# ARCHIVER_OFF_BACKCOMPATIBILITY - START OF CODE
# # Check that either archiver or streaming_archiver are set
# server = Server(build_config_from_dicts(
# main_conf={
# 'archiver': 'off',
# 'streaming_archiver': 'off'
# }
# ).get_server('main'))
# assert server.config.disabled
# assert "No archiver enabled for server 'main'. " \
# "Please turn on 'archiver', 'streaming_archiver' or " \
# "both" in server.config.msg_list
# ARCHIVER_OFF_BACKCOMPATIBILITY - START OF CODE
server = Server(build_config_from_dicts(
main_conf={
'archiver': 'off',
'streaming_archiver': 'on',
'slot_name': ''
}
).get_server('main'))
assert server.config.disabled
assert "Streaming-only archiver requires 'streaming_conninfo' and " \
"'slot_name' options to be properly configured" \
in server.config.msg_list
开发者ID:moench-tegeder,项目名称:barman,代码行数:35,代码来源:test_server.py
示例2: test_get_server_with_conflicts
def test_get_server_with_conflicts(self, monkeypatch, capsys):
"""
Test get_server method using a configuration containing errors
:param monkeypatch monkeypatch: pytest patcher
"""
# Mock the args from argparse
args = Mock()
# conflicting directories
monkeypatch.setattr(barman, '__config__', build_config_from_dicts(
main_conf={
'wals_directory': '/some/barman/home/main/wals',
'basebackups_directory': '/some/barman/home/main/wals',
}))
args.server_name = 'main'
with pytest.raises(SystemExit):
get_server(args, True)
out, err = capsys.readouterr()
assert err
assert "ERROR: Conflicting path:" in err
# conflicting directories with on_error_stop=False
monkeypatch.setattr(barman, '__config__', build_config_from_dicts(
main_conf={
'wals_directory': '/some/barman/home/main/wals',
'basebackups_directory': '/some/barman/home/main/wals',
}))
args.server_name = 'main'
get_server(args, on_error_stop=False)
# In this case the server is returned and a warning message is emitted
out, err = capsys.readouterr()
assert err
assert "ERROR: Conflicting path:" in err
开发者ID:zacchiro,项目名称:barman,代码行数:33,代码来源:test_cli.py
示例3: 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
示例4: test_populate_servers_following_symlink
def test_populate_servers_following_symlink(self, tmpdir):
"""
Test for the presence of conflicting paths in configuration between all
the servers
"""
incoming_dir = tmpdir.mkdir("incoming")
wals_dir = tmpdir.join("wal")
wals_dir.mksymlinkto(incoming_dir.strpath)
c = build_config_from_dicts(
global_conf=None,
main_conf={
'basebackups_directory': incoming_dir.strpath,
'incoming_wals_directory': incoming_dir.strpath,
'wals_directory': wals_dir.strpath,
'backup_directory': tmpdir.strpath,
})
c._populate_servers()
# If there is one or more path errors are present,
# the msg_list of the 'main' server is populated during
# the creation of the server configuration object
assert len(c._servers['main'].msg_list) == 2
symlink = 0
for msg in c._servers['main'].msg_list:
# Check for symlinks presence
if "(symlink to: " in msg:
symlink += 1
assert symlink == 1
开发者ID:stig,项目名称:barman,代码行数:30,代码来源:test_config.py
示例5: test_populate_servers
def test_populate_servers(self):
"""
Test for the presence of conflicting paths in configuration between all
the servers
"""
c = build_config_from_dicts(
global_conf=None,
main_conf={
'basebackups_directory': '/some/barman/home/main/base',
'incoming_wals_directory': '/some/barman/home/main/incoming',
'wals_directory': '/some/barman/home/main/wals',
'backup_directory': '/some/barman/home/main',
},
test_conf={
'basebackups_directory': '/some/barman/home/test/wals',
'incoming_wals_directory': '/some/barman/home/main/incoming',
'wals_directory': '/some/barman/home/main/wals',
'backup_directory': '/some/barman/home/main',
})
# attribute servers_msg_list is empty before _populate_server()
assert len(c.servers_msg_list) == 0
c._populate_servers()
# after _populate_servers() if there is a global paths error
# servers_msg_list is created in configuration
assert c.servers_msg_list
assert len(c.servers_msg_list) == 4
开发者ID:stig,项目名称:barman,代码行数:29,代码来源:test_config.py
示例6: test_get_server_list_global_error_continue
def test_get_server_list_global_error_continue(self, monkeypatch):
"""
Test the population of the list of global errors for diagnostic purposes
(diagnose invocation)
:param monkeypatch monkeypatch: pytest patcher
"""
monkeypatch.setattr(barman, '__config__', build_config_from_dicts(
global_conf=None,
main_conf={
'basebackups_directory': '/some/barman/home/main/base',
'incoming_wals_directory': '/some/barman/home/main/incoming',
'wals_directory': '/some/barman/home/main/wals',
'backup_directory': '/some/barman/home/main',
},
test_conf={
'basebackups_directory': '/some/barman/home/test/wals',
'incoming_wals_directory': '/some/barman/home/main/incoming',
'wals_directory': '/some/barman/home/main/wals',
'backup_directory': '/some/barman/home/main',
}))
server_dict = get_server_list(on_error_stop=False)
global_error_list = barman.__config__.servers_msg_list
# Check for the presence of servers
assert server_dict
# Check for the presence of global errors
assert global_error_list
assert len(global_error_list) == 4
开发者ID:zacchiro,项目名称:barman,代码行数:28,代码来源:test_cli.py
示例7: 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
示例8: 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
示例9: test_init
def test_init(self, tmpdir):
"""
Test the init method
"""
# Build a basic configuration
config = build_config_from_dicts({
'barman_lock_directory': tmpdir.strpath})
config.name = 'main'
# Acquire a lock and initialise the ProjectManager.
# Expect the ProjectManager to Retrieve the
# "Running process" identified by the lock
lock = ServerWalReceiveLock(tmpdir.strpath, 'main')
with lock:
pm = ProcessManager(config)
# Test for the length of the process list
assert len(pm.process_list) == 1
# Test for the server identifier of the process
assert pm.process_list[0].server_name == 'main'
# Test for the task type
assert pm.process_list[0].task == 'receive-wal'
# Read the pid from the lockfile and test id against the ProcessInfo
# contained in the process_list
with open(lock.filename, 'r') as lockfile:
pid = lockfile.read().strip()
assert int(pid) == pm.process_list[0].pid
# Test lock file parse error.
# Skip the lock and don't raise any exception.
with lock:
with open(lock.filename, 'w') as lockfile:
lockfile.write("invalid")
pm = ProcessManager(config)
assert len(pm.process_list) == 0
开发者ID:blueninj0r,项目名称:pgbarman,代码行数:34,代码来源:test_process.py
示例10: 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
示例11: 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
示例12: test_init
def test_init(self):
"""
Basic initialization test with minimal parameters
"""
server = Server(build_config_from_dicts(
global_conf={
'archiver': 'on'
}).get_server('main'))
assert not server.config.disabled
开发者ID:moench-tegeder,项目名称:barman,代码行数:9,代码来源:test_server.py
示例13: test_get_server_list
def test_get_server_list(self, monkeypatch, capsys):
"""
Test the get_server_list method
:param monkeypatch monkeypatch: pytest patcher
"""
monkeypatch.setattr(barman, '__config__', build_config_from_dicts())
server_dict = get_server_list()
assert server_dict
# Expect 2 test servers Main and Test
assert len(server_dict) == 2
# Test the method with global errors
monkeypatch.setattr(barman, '__config__', build_config_from_dicts(
global_conf=None,
main_conf={
'basebackups_directory': '/some/barman/home/main/base',
'incoming_wals_directory': '/some/barman/home/main/incoming',
'wals_directory': '/some/barman/home/main/wals',
'backup_directory': '/some/barman/home/main',
'archiver': 'on',
},
test_conf={
'basebackups_directory': '/some/barman/home/test/wals',
'incoming_wals_directory': '/some/barman/home/main/incoming',
'wals_directory': '/some/barman/home/main/wals',
'backup_directory': '/some/barman/home/main',
'archiver': 'on',
}))
# Expect the method to fail and exit
with pytest.raises(SystemExit):
get_server_list()
out, err = capsys.readouterr()
# Check for the presence of error messages
assert err
# Check paths in error messages
assert 'Conflicting path: ' \
'basebackups_directory=/some/barman/home/main/base' in err
assert 'Conflicting path: ' \
'incoming_wals_directory=/some/barman/home/main/incoming' in err
assert 'Conflicting path: ' \
'wals_directory=/some/barman/home/main/wals' in err
assert 'Conflicting path: ' \
'backup_directory=/some/barman/home/main' in err
开发者ID:moench-tegeder,项目名称:barman,代码行数:43,代码来源:test_cli.py
示例14: test_bad_init
def test_bad_init(self):
"""
Check the server is buildable with an empty configuration
"""
server = Server(build_config_from_dicts(
main_conf={
'conninfo': '',
'ssh_command': '',
}
).get_server('main'))
assert server.config.disabled
开发者ID:jamonation,项目名称:barman,代码行数:11,代码来源:test_server.py
示例15: 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
示例16: test_check_config_missing
def test_check_config_missing(self):
"""
Verify the check method can be called on an empty configuration
"""
server = Server(build_config_from_dicts(
main_conf={
'conninfo': '',
'ssh_command': '',
}
).get_server('main'))
check_strategy = CheckOutputStrategy()
server.check(check_strategy)
assert check_strategy.has_error
开发者ID:blueninj0r,项目名称:pgbarman,代码行数:13,代码来源:test_server.py
示例17: test_get_server
def test_get_server(self, monkeypatch):
"""
Test the get_server method, providing a basic configuration
:param monkeypatch monkeypatch: pytest patcher
"""
# Mock the args from argparse
args = Mock()
args.server_name = 'main'
monkeypatch.setattr(barman, '__config__', build_config_from_dicts())
server_main = get_server(args)
# Expect the server to exists
assert server_main
# Expect the name to be the right one
assert server_main.config.name == 'main'
开发者ID:zacchiro,项目名称:barman,代码行数:15,代码来源:test_cli.py
示例18: test_list
def test_list(self, tmpdir):
"""
Test the list method from the ProjectManager class
"""
config = build_config_from_dicts({
'barman_lock_directory': tmpdir.strpath})
config.name = 'main'
with ServerWalReceiveLock(tmpdir.strpath, 'main'):
pm = ProcessManager(config)
process = pm.list('receive-wal')[0]
assert process.server_name == 'main'
assert process.task == 'receive-wal'
with open(os.path.join(
tmpdir.strpath,
'.%s-receive-wal.lock' % config.name)) as lockfile:
pid = lockfile.read().strip()
assert int(pid) == process.pid
开发者ID:blueninj0r,项目名称:pgbarman,代码行数:18,代码来源:test_process.py
示例19: test_check_config_missing
def test_check_config_missing(self, tmpdir):
"""
Verify the check method can be called on an empty configuration
"""
server = Server(build_config_from_dicts(
global_conf={
# Required by server.check_archive method
"barman_lock_directory": tmpdir.mkdir('lock').strpath
},
main_conf={
'conninfo': '',
'ssh_command': '',
# Required by server.check_archive method
'wals_directory': tmpdir.mkdir('wals').strpath,
}
).get_server('main'))
check_strategy = CheckOutputStrategy()
server.check(check_strategy)
assert check_strategy.has_error
开发者ID:moench-tegeder,项目名称:barman,代码行数:19,代码来源:test_server.py
示例20: 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
注:本文中的testing_helpers.build_config_from_dicts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论