def test_destroy_kernel_raises_err_with_abnormal_status(mocker): mock_req_obj = mock.Mock() mock_req_obj.send.return_value = mock.MagicMock(status=400) mocker.patch('ai.backend.client.kernel.Request', return_value=mock_req_obj) kernel_id = token_hex(12) with pytest.raises(BackendAPIError): k = Kernel(kernel_id) k.destroy()
def test_destroy_kernel_url(mocker): mock_req_obj = mock.Mock() mock_req_obj.send.return_value = mock.MagicMock(status=204) mock_req = mocker.patch('ai.backend.client.kernel.Request', return_value=mock_req_obj) kernel_id = token_hex(12) k = Kernel(kernel_id) k.destroy() mock_req.assert_called_once_with('DELETE', '/kernel/{}'.format(kernel_id)) mock_req_obj.send.assert_called_once_with()