From 93d159ba4410832c043572d2ade3ca44d13251d5 Mon Sep 17 00:00:00 2001 From: Tasko Olevski Date: Tue, 10 Dec 2024 18:48:31 +0100 Subject: [PATCH] fix: notebook tests --- .../data_api/test_notebooks.py | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/test/bases/renku_data_services/data_api/test_notebooks.py b/test/bases/renku_data_services/data_api/test_notebooks.py index 22e0c9d76..1e7ff8c53 100644 --- a/test/bases/renku_data_services/data_api/test_notebooks.py +++ b/test/bases/renku_data_services/data_api/test_notebooks.py @@ -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, + }, + }, + }, + }, } ) @@ -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)] @@ -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 @@ -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", }