本文整理汇总了Python中clc_ansible_module.clc_modify_server.ClcModifyServer.process_request方法的典型用法代码示例。如果您正苦于以下问题:Python ClcModifyServer.process_request方法的具体用法?Python ClcModifyServer.process_request怎么用?Python ClcModifyServer.process_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clc_ansible_module.clc_modify_server.ClcModifyServer
的用法示例。
在下文中一共展示了ClcModifyServer.process_request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_request_state_present_empty_server_list
# 需要导入模块: from clc_ansible_module.clc_modify_server import ClcModifyServer [as 别名]
# 或者: from clc_ansible_module.clc_modify_server.ClcModifyServer import process_request [as 别名]
def test_process_request_state_present_empty_server_list(self,
mock_clc_sdk,
mock_set_clc_creds):
# Setup Test
self.module.params = {
'state': 'present',
'server_ids': None,
'cpu': 2,
'memory': 4,
'wait': True
}
mock_server = mock.MagicMock()
mock_server.id = 'TEST_SERVER'
mock_server.cpu = 2
mock_server.memory= 2
#mock_clc_sdk.v2.Servers().Servers.return_value = [mock_server]
# Test
under_test = ClcModifyServer(self.module)
under_test.process_request()
# Assert
self.assertFalse(self.module.exit_json.called)
self.assertTrue(self.module.fail_json.called)
self.module.fail_json.assert_called_once_with(
msg='server_ids needs to be a list of instances to modify: None'
)
示例2: test_process_request_state_present_cpu_memory
# 需要导入模块: from clc_ansible_module.clc_modify_server import ClcModifyServer [as 别名]
# 或者: from clc_ansible_module.clc_modify_server.ClcModifyServer import process_request [as 别名]
def test_process_request_state_present_cpu_memory(self,
mock_clc_sdk,
mock_set_clc_creds):
# Setup Test
self.module.params = {
'state': 'present',
'server_ids': ['TEST_SERVER'],
'cpu': 2,
'memory': 4,
'wait': True
}
mock_server = mock.MagicMock()
mock_server.id = 'TEST_SERVER'
mock_server.cpu = 2
mock_server.memory= 2
mock_clc_sdk.v2.Servers().Servers.return_value = [mock_server]
# Test
under_test = ClcModifyServer(self.module)
under_test.process_request()
# Assert
self.assertTrue(self.module.exit_json.called)
self.assertFalse(self.module.fail_json.called)
示例3: test_process_request_state_absent_alertpolicy_error
# 需要导入模块: from clc_ansible_module.clc_modify_server import ClcModifyServer [as 别名]
# 或者: from clc_ansible_module.clc_modify_server.ClcModifyServer import process_request [as 别名]
def test_process_request_state_absent_alertpolicy_error(self,
mock_clc_sdk,
mock_set_clc_creds):
# Setup Test
self.module.params = {
'state': 'absent',
'server_ids': ['TEST_SERVER'],
'alert_policy_name': 'test',
'cpu': 2,
'wait': True
}
mock_server = mock.MagicMock()
mock_server.id = 'TEST_SERVER'
mock_server.cpu = 2
mock_server.memory= 2
mock_clc_sdk.v2.Servers().Servers.return_value = [mock_server]
# Test
under_test = ClcModifyServer(self.module)
under_test.process_request()
# Assert
self.assertFalse(self.module.exit_json.called)
self.assertTrue(self.module.fail_json.called)
self.module.fail_json.assert_called_with(
msg='\'absent\' state is not supported for \'cpu\' and \'memory\' arguments')