diff --git a/services/director-v2/tests/unit/test_models_clusters.py b/services/director-v2/tests/unit/test_models_clusters.py index b08a988fc68..ae0b17dd43e 100644 --- a/services/director-v2/tests/unit/test_models_clusters.py +++ b/services/director-v2/tests/unit/test_models_clusters.py @@ -1,52 +1,16 @@ -from pprint import pformat -from typing import Any - -import pytest from faker import Faker from models_library.api_schemas_directorv2.clusters import ( AvailableResources, - ClusterCreate, - ClusterPatch, Scheduler, UsedResources, Worker, WorkerMetrics, ) from models_library.clusters import ClusterTypeInModel -from pydantic import BaseModel, ByteSize, TypeAdapter +from pydantic import ByteSize, TypeAdapter from simcore_postgres_database.models.clusters import ClusterType -@pytest.mark.parametrize( - "model_cls", - [ClusterCreate, ClusterPatch], -) -def test_clusters_model_examples( - model_cls: type[BaseModel], model_cls_examples: dict[str, dict[str, Any]] -): - for name, example in model_cls_examples.items(): - print(name, ":", pformat(example)) - model_instance = model_cls(**example) - assert model_instance, f"Failed with {name}" - - -@pytest.mark.parametrize( - "model_cls", - [ - ClusterCreate, - ], -) -def test_cluster_creation_brings_default_thumbail( - model_cls: type[BaseModel], model_cls_examples: dict[str, dict[str, Any]] -): - for example in model_cls_examples.values(): - if "thumbnail" in example: - example.pop("thumbnail") - instance = model_cls(**example) - assert instance - assert instance.thumbnail - - def test_scheduler_constructor_with_default_has_correct_dict(faker: Faker): scheduler = Scheduler(status=faker.text()) assert scheduler.workers is not None diff --git a/services/director-v2/tests/unit/test_modules_dask_clients_pool.py b/services/director-v2/tests/unit/test_modules_dask_clients_pool.py index 17c8513083a..e53b1bed582 100644 --- a/services/director-v2/tests/unit/test_modules_dask_clients_pool.py +++ b/services/director-v2/tests/unit/test_modules_dask_clients_pool.py @@ -3,8 +3,9 @@ # pylint:disable=redefined-outer-name +from collections.abc import AsyncIterator, Callable from random import choice -from typing import Any, AsyncIterator, Callable, get_args +from typing import Any, get_args from unittest import mock import pytest @@ -15,10 +16,8 @@ Cluster, ClusterAuthentication, ClusterTypeInModel, - JupyterHubTokenAuthentication, - KerberosAuthentication, NoAuthentication, - SimpleAuthentication, + TLSAuthentication, ) from pytest_mock.plugin import MockerFixture from pytest_simcore.helpers.typing_env import EnvVarsDict @@ -82,7 +81,7 @@ def test_dask_clients_pool_properly_setup_and_deleted( def fake_clusters(faker: Faker) -> Callable[[int], list[Cluster]]: def creator(num_clusters: int) -> list[Cluster]: fake_clusters = [] - for n in range(num_clusters): + for _n in range(num_clusters): fake_clusters.append( Cluster.model_validate( { @@ -94,12 +93,11 @@ def creator(num_clusters: int) -> list[Cluster]: "authentication": choice( [ NoAuthentication(), - SimpleAuthentication( - username=faker.user_name(), - password=faker.password(), + TLSAuthentication( + client_cert=faker.pystr(), + client_key=faker.pystr(), + ca_cert=faker.pystr(), ), - KerberosAuthentication(), - JupyterHubTokenAuthentication(api_token=faker.uuid4()), ] ), } @@ -155,6 +153,7 @@ async def test_dask_clients_pool_acquisition_creates_client_on_demand( clusters = fake_clusters(30) mocked_creation_calls = [] + assert client.app for cluster in clusters: mocked_creation_calls.append( mock.call(