本文整理汇总了Python中pydnstest.config.DnstestConfig.conf_file方法的典型用法代码示例。如果您正苦于以下问题:Python DnstestConfig.conf_file方法的具体用法?Python DnstestConfig.conf_file怎么用?Python DnstestConfig.conf_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydnstest.config.DnstestConfig
的用法示例。
在下文中一共展示了DnstestConfig.conf_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_promptconfig_no_confirm
# 需要导入模块: from pydnstest.config import DnstestConfig [as 别名]
# 或者: from pydnstest.config.DnstestConfig import conf_file [as 别名]
def test_promptconfig_no_confirm(self, capfd):
dc = DnstestConfig()
dc.conf_file = '/foo/bar/baz'
def prompt_input_se(prompt, default=None, validate_cb=None):
ret = {
"Production DNS Server IP": '1.2.3.4',
"Test/Staging DNS Server IP": '5.6.7.8',
"Check for reverse DNS by default? [Y|n]": True,
"Default domain for to append to any input that appears to be less than a FQDN (blank for none)": 'example.com',
"Ignore difference in TTL when comparing responses? [y|N]": False,
"Sleep between DNS record tests (seconds)": 0.0,
}
return ret[prompt]
prompt_input_mock = mock.MagicMock(side_effect=prompt_input_se)
confirm_response_mock = mock.MagicMock()
confirm_response_mock.return_value = False
to_string_mock = mock.MagicMock()
to_string_mock.return_value = 'foo bar baz'
write_mock = mock.MagicMock()
write_mock.return_value = True
with mock.patch('pydnstest.config.DnstestConfig.prompt_input', prompt_input_mock):
with mock.patch('pydnstest.config.DnstestConfig.to_string', to_string_mock):
with mock.patch('pydnstest.config.DnstestConfig.confirm_response', confirm_response_mock):
with mock.patch('pydnstest.config.DnstestConfig.write', write_mock):
with pytest.raises(SystemExit) as excinfo:
dc.prompt_config()
assert excinfo.value.code == "Exiting on user request. No configuration written."
assert prompt_input_mock.call_count == 6
assert prompt_input_mock.call_args_list == [
mock.call("Production DNS Server IP", validate_cb=dc.validate_ipaddr),
mock.call("Test/Staging DNS Server IP", validate_cb=dc.validate_ipaddr),
mock.call("Check for reverse DNS by default? [Y|n]", default=True, validate_cb=dc.validate_bool),
mock.call("Default domain for to append to any input that appears to be less than a FQDN (blank for none)", default=''),
mock.call("Ignore difference in TTL when comparing responses? [y|N]", default=False, validate_cb=dc.validate_bool),
mock.call("Sleep between DNS record tests (seconds)", default=0.0, validate_cb=dc.validate_float),
]
assert to_string_mock.call_count == 1
assert confirm_response_mock.call_count == 1
assert write_mock.call_count == 0
out, err = capfd.readouterr()
assert out == "Configuration:\n#####################\nfoo bar baz\n#####################\n\n"
assert err == ""
assert dc.server_prod == '1.2.3.4'
assert dc.server_test == '5.6.7.8'
assert dc.have_reverse_dns == True
assert dc.default_domain == 'example.com'
assert dc.ignore_ttl == False
assert dc.sleep == 0.0