Skip to content

Commit 8acb720

Browse files
committed
chore: fix tests
1 parent a920d1d commit 8acb720

7 files changed

Lines changed: 14 additions & 13 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"ghcr.io/devcontainers-contrib/features/poetry",
3535
"ghcr.io/devcontainers-contrib/features/bash-command"
3636
],
37-
"postCreateCommand": "poetry install --with dev",
37+
"postCreateCommand": "poetry install --with dev && mkdir -p /home/vscode/.config/k9s",
3838
"customizations": {
3939
"vscode": {
4040
"extensions": [

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ services:
2525
POETRY_CACHE_DIR: "/poetry_cache"
2626
NB_SERVER_OPTIONS__DEFAULTS_PATH: /workspace/server_defaults.json
2727
NB_SERVER_OPTIONS__UI_CHOICES_PATH: /workspace/server_options.json
28+
KUBECONFIG: "/workspace/.k3d-config.yaml"
2829
network_mode: service:db
2930
depends_on:
3031
- db

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ docker-compose.override.yml
7979
# nix
8080
result
8181
*.qcow2
82+
83+
.k3d-config.yaml

components/renku_data_services/notebooks/api/classes/image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class ImageRepoDockerAPI:
3030
hostname: str
3131
oauth2_token: Optional[str] = field(default=None, repr=False)
3232
# NOTE: We need to follow redirects so that we can authenticate with the image repositories properly.
33-
client: httpx.AsyncClient = httpx.AsyncClient(timeout=10, follow_redirects=True)
33+
# NOTE: If we do not use default_factory to create the client here requests will fail beause it can happen
34+
# that the client gets created in the wrong asyncio loop.
35+
client: httpx.AsyncClient = field(default_factory=lambda: httpx.AsyncClient(timeout=10, follow_redirects=True))
3436

3537
async def _get_docker_token(self, image: "Image") -> Optional[str]:
3638
"""Get an authorization token from the docker v2 API.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ ignore = [
150150
"components/renku_data_services/notebooks/crs.py" = ["F401"]
151151

152152
[tool.ruff.lint.isort]
153-
known-first-party = ["renku_data_services"]
153+
known-first-party = ["renku_data_services", "test"]
154154

155155
[tool.ruff.lint.pydocstyle]
156156
convention = "google"

test/bases/renku_data_services/data_api/test_notebooks.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import asyncio
44
import os
55
import shutil
6-
from collections.abc import AsyncIterator
6+
from collections.abc import AsyncIterator, Iterator
77
from unittest.mock import MagicMock
88
from uuid import uuid4
99

@@ -13,14 +13,12 @@
1313
from sanic_testing.testing import SanicASGITestClient
1414

1515
from renku_data_services.notebooks.api.classes.k8s_client import JupyterServerV1Alpha1Kr8s
16-
17-
from .utils import K3DCluster, setup_amalthea
18-
19-
os.environ["KUBECONFIG"] = ".k3d-config.yaml"
16+
from test.bases.renku_data_services.data_api.utils import K3DCluster, setup_amalthea
2017

2118

2219
@pytest.fixture(scope="module", autouse=True)
23-
def cluster() -> K3DCluster:
20+
def cluster() -> Iterator[K3DCluster]:
21+
os.environ["KUBECONFIG"] = ".k3d-config.yaml"
2422
if shutil.which("k3d") is None:
2523
pytest.skip("Requires k3d for cluster creation")
2624

test/bases/renku_data_services/data_api/test_sessions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
from renku_data_services.app_config.config import Config
1414
from renku_data_services.crc.apispec import ResourcePool
1515
from renku_data_services.users.models import UserInfo
16-
17-
from .utils import K3DCluster, setup_amalthea
18-
19-
os.environ["KUBECONFIG"] = ".k3d-config.yaml"
16+
from test.bases.renku_data_services.data_api.utils import K3DCluster, setup_amalthea
2017

2118

2219
@pytest.fixture(scope="module")
2320
def cluster() -> Iterator[K3DCluster]:
21+
os.environ["KUBECONFIG"] = ".k3d-config.yaml"
2422
if shutil.which("k3d") is None:
2523
pytest.skip("Requires k3d for cluster creation")
2624

0 commit comments

Comments
 (0)