def test_image_create(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/images' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.image.ImageAction.create' with mock.patch(function) as create: h(self.env, dummy) self.assertTrue(create.called)
def test_image_delete(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/images/image1' self.env['REQUEST_METHOD'] = 'DELETE' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.image.ImageAction.delete' with mock.patch(function) as delete: h(self.env, dummy) delete.assert_called_once_with('image1')
def test_guest_create_nic(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/guests/1/nic' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.create_nic' with mock.patch(function) as create_nic: h(self.env, dummy) self.assertTrue(create_nic.called)
def test_guest_update_nic(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/guests/1/nic/1000' self.env['REQUEST_METHOD'] = 'PUT' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.couple_uncouple_nic' with mock.patch(func) as update_nic: h(self.env, dummy) self.assertTrue(update_nic.called)
def test_guest_get_nic_info(self, mock_validate): self.env['PATH_INFO'] = '/guests/1/nic' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.get_nic' with mock.patch(func) as get_nic_info: get_nic_info.return_value = '' h(self.env, dummy) get_nic_info.assert_called_once_with('1')
def test_guest_delete_nic(self, mock_validate, mock_json): mock_json.return_value = '' self.env['PATH_INFO'] = '/guests/1/nic/1000' self.env['REQUEST_METHOD'] = 'DELETE' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.delete_nic' with mock.patch(func) as delete_nic: h(self.env, dummy) delete_nic.assert_called_once_with('1', '1000', '')
def test_vswitch_query(self, mock_validate): self.env['PATH_INFO'] = '/vswitches/vsw1' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.vswitch.VswitchAction.query' with mock.patch(function) as query: query.return_value = {'overallRC': 0} h(self.env, dummy) query.assert_called_once_with('vsw1')
def test_vswitch_list(self, mock_validate): self.env['PATH_INFO'] = '/vswitchs' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.vswitch.VswitchAction.list' with mock.patch(function) as list: list.return_value = '' h(self.env, dummy) self.assertTrue(list.called)
def test_host_get_info(self, mock_validate): self.env['PATH_INFO'] = '/host' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.host.HostAction.get_info' with mock.patch(function) as get_info: get_info.return_value = {'overallRC': 0} h(self.env, dummy) self.assertTrue(get_info.called)
def test_vswitch_delete(self, mock_validate): self.env['PATH_INFO'] = '/vswitches/vsw1' self.env['REQUEST_METHOD'] = 'DELETE' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.vswitch.VswitchAction.delete' with mock.patch(function) as delete: delete.return_value = {'overallRC': 0} h(self.env, dummy) delete.assert_called_once_with('vsw1')
def test_image_query(self, mock_validate): self.env['PATH_INFO'] = '/images' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() func = 'zvmconnector.connector.ZVMConnector.send_request' with mock.patch(func) as query: query.return_value = {'overallRC': 0} h(self.env, dummy) query.assert_called_once_with('image_query', None)
def test_guest_delete(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/guests/1' self.env['REQUEST_METHOD'] = 'DELETE' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.delete' with mock.patch(func) as delete: delete.return_value = {'overallRC': 0} h(self.env, dummy) delete.assert_called_once_with('1')
def test_guest_get(self, mock_validate): self.env['PATH_INFO'] = '/guests/1' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.get_definition_info' with mock.patch(func) as get: get.return_value = {'overallRC': 0} h(self.env, dummy) get.assert_called_once_with(mock.ANY, '1')
def test_guest_get_info(self, mock_validate): self.env['PATH_INFO'] = '/guests/1/info' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() with mock.patch('zvmsdk.sdkwsgi.handlers.guest.VMHandler.get_info') \ as get_info: get_info.return_value = {'overallRC': 0} h(self.env, dummy) get_info.assert_called_once_with(mock.ANY, '1')
def test_guest_list(self, mock_validate): self.env['PATH_INFO'] = '/guests' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() with mock.patch('zvmsdk.sdkwsgi.handlers.guest.VMHandler.list') \ as list: list.return_value = '' h(self.env, dummy) self.assertTrue(list.called)
def test_host_get_disk_info(self, mock_validate): self.env['PATH_INFO'] = '/host/disk_info/disk1' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.host.HostAction.get_disk_info' with mock.patch(function) as get_disk_info: get_disk_info.return_value = '' h(self.env, dummy) get_disk_info.assert_called_once_with('disk1')
def test_image_query(self, mock_validate): self.env['PATH_INFO'] = '/images' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.image.ImageAction.query' with mock.patch(function) as query: query.return_value = '[]' h(self.env, dummy) query.assert_called_once_with(None)
def test_host_get_guest_list(self, mock_validate): self.env['PATH_INFO'] = '/host/guests' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() with mock.patch('zvmsdk.sdkwsgi.handlers.host.HostAction' '.get_guest_list') as get_guest_list: get_guest_list.return_value = {'overallRC': 0} h(self.env, dummy) self.assertTrue(get_guest_list.called)
def test_guest_stop(self, mock_json): mock_json.return_value = {"action": "stop"} self.env['PATH_INFO'] = '/guests/1/action' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() with mock.patch('zvmsdk.sdkwsgi.handlers.guest.VMAction.stop') \ as stop: stop.return_value = {'overallRC': 0} h(self.env, dummy) stop.assert_called_once_with('1', body={})
def test_vswitch_create(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/vswitches' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.vswitch.VswitchAction.create' with mock.patch(function) as create: create.return_value = {'overallRC': 0} h(self.env, dummy) self.assertTrue(create.called)
def test_vswitch_update(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/vswitches/vsw1' self.env['REQUEST_METHOD'] = 'PUT' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.vswitch.VswitchAction.update' with mock.patch(function) as update: update.return_value = {'overallRC': 0} h(self.env, dummy) update.assert_called_once_with('vsw1', body={})
def test_image_delete(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/images/image1' self.env['REQUEST_METHOD'] = 'DELETE' h = handler.SdkHandler() func = 'zvmconnector.connector.ZVMConnector.send_request' with mock.patch(func) as delete: delete.return_value = {'overallRC': 0} h(self.env, dummy) delete.assert_called_once_with('image_delete', 'image1')
def test_host_get_volume_info(self, mock_validate): self.env['PATH_INFO'] = '/host/volume' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() function = 'zvmsdk.sdkwsgi.handlers.host.HostAction.'\ 'get_volume_info' with mock.patch(function) as get_volume_info: get_volume_info.return_value = {'overallRC': 0} h(self.env, dummy) get_volume_info.assert_called_once_with(mock.ANY, None)
def test_image_root_disk_size(self, mock_validate): self.env['PATH_INFO'] = '/images/image1/root_disk_size' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() func = 'zvmconnector.connector.ZVMConnector.send_request' with mock.patch(func) as get_size: get_size.return_value = {'overallRC': 0} h(self.env, dummy) get_size.assert_called_once_with('image_get_root_disk_size', 'image1')
def test_image_create(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/images' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.image.ImageAction.create' with mock.patch(func) as create: create.return_value = {'overallRC': 0} h(self.env, dummy) create.assert_called_once_with(body={})
def test_guest_update_nic(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/guests/1/nic/1000' self.env['REQUEST_METHOD'] = 'PUT' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.nic_couple_uncouple' with mock.patch(func) as update_nic: update_nic.return_value = {'overallRC': 0} h(self.env, dummy) update_nic.assert_called_once_with('1', '1000', body={})
def test_guest_create_nic(self, mock_validate, mock_json): mock_json.return_value = {} self.env['PATH_INFO'] = '/guests/1/nic' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler.create_nic' with mock.patch(func) as create_nic: create_nic.return_value = {'overallRC': 0} h(self.env, dummy) create_nic.assert_called_once_with('1', body={})
def test_guest_get_power_state_real(self, mock_validate): self.env['PATH_INFO'] = '/guests/1/power_state_real' self.env['REQUEST_METHOD'] = 'GET' h = handler.SdkHandler() func = 'zvmsdk.sdkwsgi.handlers.guest.VMHandler'\ '.get_power_state_real' with mock.patch(func) as get_power: get_power.return_value = {'overallRC': 0} h(self.env, dummy) get_power.assert_called_once_with(mock.ANY, '1')
def test_guest_get_console_output(self, mock_json): mock_json.return_value = {"action": "get_console_output"} self.env['PATH_INFO'] = '/guests/1/action' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() url = 'zvmsdk.sdkwsgi.handlers.guest.VMAction.get_console_output' with mock.patch(url) as get_console_output: get_console_output.return_value = {'overallRC': 0} h(self.env, dummy) get_console_output.assert_called_once_with('1', body={})
def test_guest_deploy(self, mock_json): mock_json.return_value = {"action": "deploy"} self.env['PATH_INFO'] = '/guests/1/action' self.env['REQUEST_METHOD'] = 'POST' h = handler.SdkHandler() with mock.patch('zvmsdk.sdkwsgi.handlers.guest.VMAction.deploy') \ as deploy: deploy.return_value = '' h(self.env, dummy) deploy.assert_called_once_with('1', body={})