本文整理汇总了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")