當前位置: 首頁>>代碼示例>>Python>>正文


Python ClcPublicIp.ensure_public_ip_absent方法代碼示例

本文整理匯總了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'])
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:19,代碼來源:test_clc_publicip.py

示例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)
開發者ID:bjfelton,項目名稱:clc-ansible-module,代碼行數:21,代碼來源:test_clc_publicip.py


注:本文中的clc_ansible_module.clc_publicip.ClcPublicIp.ensure_public_ip_absent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。