本文整理汇总了Python中clc_ansible_module.clc_loadbalancer.ClcLoadBalancer.process_request方法的典型用法代码示例。如果您正苦于以下问题:Python ClcLoadBalancer.process_request方法的具体用法?Python ClcLoadBalancer.process_request怎么用?Python ClcLoadBalancer.process_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clc_ansible_module.clc_loadbalancer.ClcLoadBalancer
的用法示例。
在下文中一共展示了ClcLoadBalancer.process_request方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_request_state_present
# 需要导入模块: from clc_ansible_module.clc_loadbalancer import ClcLoadBalancer [as 别名]
# 或者: from clc_ansible_module.clc_loadbalancer.ClcLoadBalancer import process_request [as 别名]
def test_process_request_state_present(self,
mock_set_clc_credentials,
mock_clc_sdk):
# Setup
self.module.params = {
'name': 'test',
'port': 80,
'nodes':[{ 'ipAddress': '10.82.152.15', 'privatePort': 80 }],
'state': 'present'
}
mock_loadbalancer_response = [{'name': 'TEST_LB'}]
mock_clc_sdk.v2.API.Call.side_effect = [
[{'name': 'test'}],
{'id': 'test', 'name': 'test'},
[],
{'id': 'test', 'name': 'test'},
[]
]
# TODO: Mock a response to API.Call('POST')
self.module.check_mode = False
# Under Test
under_test = ClcLoadBalancer(self.module)
under_test.process_request()
# Assert
self.module.exit_json.assert_called_once_with(changed=False, loadbalancer = {'id': 'test', 'name': 'test'})
self.assertFalse(self.module.fail_json.called)
示例2: test_process_request_state_absent
# 需要导入模块: from clc_ansible_module.clc_loadbalancer import ClcLoadBalancer [as 别名]
# 或者: from clc_ansible_module.clc_loadbalancer.ClcLoadBalancer import process_request [as 别名]
def test_process_request_state_absent(self,
mock_set_clc_credentials,
mock_clc_sdk):
#Setup
self.module.params = {
'name': 'test',
'state': 'absent'
}
mock_loadbalancer_response = [{'name': 'test', 'id': 'test'}]
mock_clc_sdk.v2.API.Call.return_value = mock_loadbalancer_response
self.module.check_mode = False
test = ClcLoadBalancer(self.module)
test.process_request()
#Assertions
self.module.exit_json.assert_called_once_with(changed=True, loadbalancer=[{'name': 'test', 'id': 'test'}])
self.assertFalse(self.module.fail_json.called)
示例3: test_process_request_state_port_absent
# 需要导入模块: from clc_ansible_module.clc_loadbalancer import ClcLoadBalancer [as 别名]
# 或者: from clc_ansible_module.clc_loadbalancer.ClcLoadBalancer import process_request [as 别名]
def test_process_request_state_port_absent(self,
mock_set_clc_credentials,
mock_clc_sdk):
#Setup
self.module.params = {
'name': 'test',
'port': 80,
'state': 'port_absent'
}
mock_clc_sdk.v2.API.Call.side_effect = [
[{'id': 'test', 'name': 'test'}],
[{'port': '80', 'id':'test'}],
{}
]
self.module.check_mode = False
test = ClcLoadBalancer(self.module)
test.process_request()
#Assertions
self.module.exit_json.assert_called_once_with(changed=True, loadbalancer={})
self.assertFalse(self.module.fail_json.called)
示例4: test_process_request_state_nodes_absent
# 需要导入模块: from clc_ansible_module.clc_loadbalancer import ClcLoadBalancer [as 别名]
# 或者: from clc_ansible_module.clc_loadbalancer.ClcLoadBalancer import process_request [as 别名]
def test_process_request_state_nodes_absent(self,
mock_set_clc_credentials,
mock_clc_sdk):
#Setup
self.module.params = {
'name': 'test',
'port': 80,
'nodes':[{ 'ipAddress': '10.82.152.15', 'privatePort': 82, 'status': 'enabled' }],
'state': 'nodes_absent'
}
mock_clc_sdk.v2.API.Call.side_effect = [
[{'id': 'test', 'name': 'test'}],
[{'port': '80', 'id':'test'}],
[{ 'ipAddress': '10.82.152.15', 'privatePort': 81, 'status': 'enabled' }]
]
test = ClcLoadBalancer(self.module)
test.process_request()
#Assertions
self.module.exit_json.assert_called_once_with(changed=False, loadbalancer={})
self.assertFalse(self.module.fail_json.called)