Exemplo n.º 1
0
def test_restart_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.restart()
Exemplo n.º 2
0
def test_restart_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.restart()

    mock_req.assert_called_once_with('PATCH', '/kernel/{}'.format(kernel_id))
    mock_req_obj.send.assert_called_once_with()