Skip to content

Commit

Permalink
fix: notebook tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Dec 11, 2024
1 parent 85aeb5d commit 93d159b
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions test/bases/renku_data_services/data_api/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ async def practice_jupyter_server(renku_image: str, server_name: str) -> AsyncIt
"renku.io/repository": "dummy",
},
},
"spec": {"jupyterServer": {"image": renku_image}},
"spec": {
"jupyterServer": {
"image": renku_image,
"resources": {
"requests": {
"cpu": 0.1,
"memory": 100_000_000,
},
},
},
},
}
)

Expand Down Expand Up @@ -263,17 +273,31 @@ async def test_user_server_list(
sanic_client: SanicASGITestClient,
request,
server_name,
jupyter_server,
authenticated_user_headers,
fake_gitlab,
):
"""Validate that the user server list endpoint answers correctly"""
data = {
"branch": "main",
"commit_sha": "ee4b1c9fedc99abe5892ee95320bbd8471c5985b",
"namespace": "test-namespace",
"project": "my-test",
"image": "alpine:3",
}
_, res = await sanic_client.post("/api/data/notebooks/servers/", json=data, headers=authenticated_user_headers)
assert res.status_code == 201, res.text
server_name = res.json["name"]

_, res = await sanic_client.get("/api/data/notebooks/servers", headers=authenticated_user_headers)

assert res.status_code == 200, res.text
assert "servers" in res.json
assert len(res.json["servers"]) == 1

_, res = await sanic_client.delete(
f"/api/data/notebooks/servers/{server_name}", headers=authenticated_user_headers
)
assert res.status_code == 204, res.text

@pytest.mark.asyncio
@pytest.mark.parametrize(
"server_name_fixture,expected_status_code", [("unknown_server_name", 404), ("server_name", 200)]
Expand Down Expand Up @@ -349,9 +373,7 @@ async def test_old_start_server(self, sanic_client: SanicASGITestClient, authent
"image": "alpine:3",
}

_, res = await sanic_client.post(
"/api/data/notebooks/old/servers/", json=data, headers=authenticated_user_headers
)
_, res = await sanic_client.post("/api/data/notebooks/servers/", json=data, headers=authenticated_user_headers)

assert res.status_code == 201, res.text

Expand All @@ -367,8 +389,8 @@ async def test_start_server(self, sanic_client: SanicASGITestClient, authenticat
data = {
"branch": "main",
"commit_sha": "ee4b1c9fedc99abe5892ee95320bbd8471c5985b",
"project_id": "test-namespace/my-test",
"launcher_id": "test_launcher",
"namespace": "test-namespace",
"project": "my-test",
"image": "alpine:3",
}

Expand Down

0 comments on commit 93d159b

Please sign in to comment.