本文整理汇总了Python中clc_ansible_module.clc_publicip.ClcPublicIp.ensure_public_ip_absent方法的典型用法代码示例。如果您正苦于以下问题:Python ClcPublicIp.ensure_public_ip_absent方法的具体用法?Python ClcPublicIp.ensure_public_ip_absent怎么用?Python ClcPublicIp.ensure_public_ip_absent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clc_ansible_module.clc_publicip.ClcPublicIp
的用法示例。
在下文中一共展示了ClcPublicIp.ensure_public_ip_absent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ensure_server_absent_absent_w_mock_server
# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_absent [as 别名]
def test_ensure_server_absent_absent_w_mock_server(self,mock_get_servers):
server_ids = ['TESTSVR1']
mock_server1 = mock.MagicMock()
mock_server1.id = 'TESTSVR1'
public_ips_obj = mock.MagicMock()
ip = mock.MagicMock()
ip.Delete.return_value = 'success'
public_ips_obj.public_ips = [ip]
mock_server1.PublicIPs.return_value = public_ips_obj
mock_get_servers.return_value=[mock_server1]
self.module.check_mode = False
under_test = ClcPublicIp(self.module)
changed, servers_modified, requests = under_test.ensure_public_ip_absent(server_ids)
self.assertFalse(self.module.fail_json.called)
self.assertEqual(changed, True)
self.assertEqual(servers_modified, ['TESTSVR1'])
示例2: test_ensure_server_publicip_absent_returns_expected_data
# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_absent [as 别名]
def test_ensure_server_publicip_absent_returns_expected_data(self,mock_get_server):
server_id = 'TESTSVR1'
mock_server = mock.MagicMock()
mock_server.id = server_id
ip1 = mock.MagicMock()
ip2 = mock.MagicMock()
ip1.Delete = mock.MagicMock(return_value="Hell0")
ip2.Delete = mock.MagicMock(return_value="More Awesome Result")
mock_server.PublicIPs().public_ips = [ip1, ip2]
mock_get_server.return_value=mock_server
self.module.check_mode = False
under_test = ClcPublicIp(self.module)
changed, changed_server_id, result = under_test.ensure_public_ip_absent(server_id)
self.assertEqual(True, changed)
self.assertEqual(server_id, changed_server_id)
self.assertEqual('More Awesome Result', result)