本文整理匯總了Python中clc_ansible_module.clc_publicip.ClcPublicIp._validate_ports方法的典型用法代碼示例。如果您正苦於以下問題:Python ClcPublicIp._validate_ports方法的具體用法?Python ClcPublicIp._validate_ports怎麽用?Python ClcPublicIp._validate_ports使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類clc_ansible_module.clc_publicip.ClcPublicIp
的用法示例。
在下文中一共展示了ClcPublicIp._validate_ports方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_valid_ports_returns_expected_error_for_invalid_protocol
# 需要導入模塊: from clc_ansible_module.clc_publicip import ClcPublicIp [as 別名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import _validate_ports [as 別名]
def test_valid_ports_returns_expected_error_for_invalid_protocol(self):
under_test = ClcPublicIp(self.module)
under_test._validate_ports([{'protocol': 'ICP', 'port': 'Faygo'}])
self.module.fail_json.assert_called_once_with(
msg="Valid protocols for this module are: [TCP, UDP]: You specified 'ICP'"
)
示例2: test_valid_ports_skips_and_removes_blank_entry
# 需要導入模塊: from clc_ansible_module.clc_publicip import ClcPublicIp [as 別名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import _validate_ports [as 別名]
def test_valid_ports_skips_and_removes_blank_entry(self):
expected = [{'protocol': 'TCP', 'port': 456}]
under_test = ClcPublicIp(self.module)
actual = under_test._validate_ports([{'protocol': 'TCP', 'port': 456}, {}])
self.assertEqual(expected, actual)
self.assertFalse(self.module.fail_json.called)
示例3: test_valid_ports_returns_expected_output
# 需要導入模塊: from clc_ansible_module.clc_publicip import ClcPublicIp [as 別名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import _validate_ports [as 別名]
def test_valid_ports_returns_expected_output(self):
expected = [
{'port': 80, 'protocol': 'TCP'},
{'port': 34590, 'protocol': 'UDP'},
{'port': 1234, 'port_to': 4567, 'protocol': 'TCP'}
]
input_data = [
{'port': 80},
{'port': 34590, 'protocol': 'UDP'},
{'port': 1234, 'port_to': 4567}
]
under_test = ClcPublicIp(self.module)
actual = under_test._validate_ports(input_data)
self.assertEqual(expected, actual)
self.assertFalse(self.module.fail_json.called)
示例4: test_valid_ports_returns_expected_error_for_missing_port
# 需要導入模塊: from clc_ansible_module.clc_publicip import ClcPublicIp [as 別名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import _validate_ports [as 別名]
def test_valid_ports_returns_expected_error_for_missing_port(self):
under_test = ClcPublicIp(self.module)
under_test._validate_ports([{'protocol': 'UDP'}])
self.module.fail_json.assert_called_once_with(msg="You must provide a port")