async def test_blank_put(jp_fetch, labserverapp):
    orig = "foo"
    r = await jp_fetch("lab", "api", "workspaces", orig)
    assert r.code == 200
    res = r.body.decode()
    data = json.loads(res)
    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        await jp_fetch("lab", "api", "workspaces", method="PUT", body=json.dumps(data))
    assert expected_http_error(e, 400)
async def test_patch_invalid_json(jp_fetch, labserverapp):
    id = "@jupyterlab/apputils-extension:themes"

    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        payload_str = "eh"
        await jp_fetch("lab",
                       "api",
                       "settings",
                       id,
                       method="PUT",
                       body=json.dumps(payload_str))
    assert expected_http_error(e, 400)
async def test_patch_invalid_payload_format(jp_fetch, labserverapp):
    id = "@jupyterlab/apputils-extension:themes"

    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        settings = dict(keyMap=10)
        payload = dict(foo=json5.dumps(settings))
        await jp_fetch("lab",
                       "api",
                       "settings",
                       id,
                       method="PUT",
                       body=json.dumps(payload))
    assert expected_http_error(e, 400)
async def test_get_bad(jp_fetch, labserverapp):
    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        await jp_fetch("foo")
    assert expected_http_error(e, 404)
async def test_patch_bad_data(jp_fetch, labserverapp):
    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        settings = dict(keyMap=10)
        payload = dict(raw=json5.dumps(settings))
        await jp_fetch("foo", method="PUT", body=json.dumps(payload))
    assert expected_http_error(e, 404)
async def test_patch_wrong_id(jp_fetch, labserverapp):
    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        await jp_fetch("foo",
                       method="PUT",
                       body=json.dumps(dict(raw=json5.dumps(dict()))))
    assert expected_http_error(e, 404)
Ejemplo n.º 7
0
async def test_404(notebooks, jp_fetch):
    with pytest.raises(tornado.httpclient.HTTPClientError) as e:
        await jp_fetch("foo")
    assert expected_http_error(e, 404)