本文整理汇总了Python中ansible.compat.tests.mock.Mock.assert_called_with方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.assert_called_with方法的具体用法?Python Mock.assert_called_with怎么用?Python Mock.assert_called_with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.compat.tests.mock.Mock
的用法示例。
在下文中一共展示了Mock.assert_called_with方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ensure_feature_is_enabled_called
# 需要导入模块: from ansible.compat.tests.mock import Mock [as 别名]
# 或者: from ansible.compat.tests.mock.Mock import assert_called_with [as 别名]
def test_ensure_feature_is_enabled_called(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
save_config=False,
))
from ansible.modules.network.netscaler import netscaler_lb_vserver
client_mock = Mock()
lb_vserver_proxy_mock = Mock()
feature_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_lb_vserver',
get_nitro_client=Mock(return_value=client_mock),
lb_vserver_exists=Mock(side_effect=[True, True]),
lb_vserver_identical=Mock(side_effect=[True, True]),
servicegroup_bindings_identical=Mock(side_effect=[True, True]),
service_bindings_identical=Mock(side_effect=[True, True]),
ConfigProxy=Mock(return_value=lb_vserver_proxy_mock),
ensure_feature_is_enabled=feature_mock,
do_state_change=Mock(return_value=Mock(errorcode=0)),
):
self.module = netscaler_lb_vserver
self.exited()
feature_mock.assert_called_with(client_mock, 'LB')
示例2: test_ensure_feature_is_enabled_called
# 需要导入模块: from ansible.compat.tests.mock import Mock [as 别名]
# 或者: from ansible.compat.tests.mock.Mock import assert_called_with [as 别名]
def test_ensure_feature_is_enabled_called(self):
set_module_args(dict(
nitro_user='user',
nitro_pass='pass',
nsip='1.1.1.1',
state='present',
))
from ansible.modules.network.netscaler import netscaler_gslb_site
gslb_site_proxy_mock = Mock()
ensure_feature_is_enabled_mock = Mock()
client_mock = Mock()
with patch.multiple(
'ansible.modules.network.netscaler.netscaler_gslb_site',
get_nitro_client=Mock(return_value=client_mock),
gslb_site_exists=Mock(side_effect=[False, True]),
gslb_site_identical=Mock(side_effect=[True]),
nitro_exception=self.MockException,
ensure_feature_is_enabled=ensure_feature_is_enabled_mock,
ConfigProxy=Mock(return_value=gslb_site_proxy_mock),
):
self.module = netscaler_gslb_site
self.exited()
ensure_feature_is_enabled_mock.assert_called_with(client_mock, 'GSLB')
示例3: test_add_host_key
# 需要导入模块: from ansible.compat.tests.mock import Mock [as 别名]
# 或者: from ansible.compat.tests.mock.Mock import assert_called_with [as 别名]
def test_add_host_key(self):
# Copied
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
# unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually
with swap_stdin_and_argv(stdin_data=args):
ansible.module_utils.basic._ANSIBLE_ARGS = None
self.module = ansible.module_utils.basic.AnsibleModule(argument_spec=dict())
get_bin_path = Mock()
get_bin_path.return_value = keyscan_cmd = "/custom/path/ssh-keyscan"
self.module.get_bin_path = get_bin_path
run_command = Mock()
run_command.return_value = (0, "Needs output, otherwise thinks ssh-keyscan timed out'", "")
self.module.run_command = run_command
append_to_file = Mock()
append_to_file.return_value = (None,)
self.module.append_to_file = append_to_file
with patch('os.path.isdir', return_value=True):
with patch('os.path.exists', return_value=True):
for u in self.urls:
if self.urls[u]['is_ssh_url']:
known_hosts.add_host_key(self.module, self.urls[u]['get_fqdn'], port=self.urls[u]['port'])
run_command.assert_called_with(keyscan_cmd + self.urls[u]['add_host_key_cmd'])