本文整理汇总了Python中clc_ansible_module.clc_publicip.ClcPublicIp.process_request方法的典型用法代码示例。如果您正苦于以下问题:Python ClcPublicIp.process_request方法的具体用法?Python ClcPublicIp.process_request怎么用?Python ClcPublicIp.process_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clc_ansible_module.clc_publicip.ClcPublicIp
的用法示例。
在下文中一共展示了ClcPublicIp.process_request方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_request_calls_ensure_public_ip_present_with_expected_args
# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import process_request [as 别名]
def test_process_request_calls_ensure_public_ip_present_with_expected_args(self, mock_set_clc_creds, mock_public_ip):
test_params = {
'server_id': 'TESTSVR1'
,'private_ip': '10.11.12.13'
,'source_restrictions': ['no']
,'ports': [
{'port': 80},
{'port': 90, 'protocol': 'TCP'}
]
,'wait': True
,'state': 'present'
}
mock_public_ip.return_value = True, 'TESTSVR1', mock.MagicMock()
self.module.params = test_params
self.module.check_mode = False
under_test = ClcPublicIp(self.module)
under_test.process_request()
mock_public_ip.assert_called_once_with(
server_id='TESTSVR1'
, private_ip="10.11.12.13"
, ports=[
{'port': 80, 'protocol': 'TCP'},
{'port': 90, 'protocol': 'TCP'}
]
, source_restrictions=['no']
)
self.assertFalse(self.module.fail_json.called)
示例2: test_process_request_state_invalid
# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import process_request [as 别名]
def test_process_request_state_invalid(self, mock_set_clc_creds, mock_public_ip):
test_params = {
'server_ids': ['TESTSVR1', 'TESTSVR2']
,'protocol': 'TCP'
,'ports': [80, 90]
,'wait': True
, 'state': 'INVALID'
}
self.module.params = test_params
under_test = ClcPublicIp(self.module)
under_test.process_request()
self.assertFalse(mock_public_ip.called)
self.module.fail_json.assert_called_once_with(msg='Unknown State: INVALID')
self.assertFalse(self.module.exit_json.called)
示例3: test_process_request_state_absent
# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import process_request [as 别名]
def test_process_request_state_absent(self, mock_set_clc_creds, mock_public_ip):
test_params = {
'server_ids': ['TESTSVR1', 'TESTSVR2']
,'protocol': 'TCP'
,'ports': [80, 90]
,'wait': True
, 'state': 'absent'
}
mock_public_ip.return_value = True, ['TESTSVR1','TESTSVR2'], mock.MagicMock()
self.module.params = test_params
self.module.check_mode = False
under_test = ClcPublicIp(self.module)
under_test.process_request()
self.module.exit_json.assert_called_once_with(changed=True, server_ids=['TESTSVR1', 'TESTSVR2'])
self.assertFalse(self.module.fail_json.called)
示例4: test_process_request_validates_valid_ports_argument
# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import process_request [as 别名]
def test_process_request_validates_valid_ports_argument(self, mock_set_clc_creds, mock_public_ip, mock_validate_ports):
test_params = {
'server_id': 'TESTSVR1'
,'ports': [
{'port': 80},
{'port': 34590, 'protocol': 'UDP'}
]
,'wait': True
,'state': 'present'
}
mock_public_ip.return_value = True, 'TESTSVR1', mock.MagicMock()
self.module.params = test_params
self.module.check_mode = False
under_test = ClcPublicIp(self.module)
under_test.process_request()
mock_validate_ports.assert_called_once_with(test_params['ports'])
self.module.exit_json.assert_called_once_with(changed=True, server_id='TESTSVR1')
self.assertFalse(self.module.fail_json.called)