Skip to content

Commit

Permalink
remove usage of deleted code
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Dec 2, 2024
1 parent 4329439 commit c6ae907
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 47 deletions.
38 changes: 1 addition & 37 deletions services/director-v2/tests/unit/test_models_clusters.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 9 additions & 10 deletions services/director-v2/tests/unit/test_modules_dask_clients_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(
{
Expand All @@ -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()),
]
),
}
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c6ae907

Please sign in to comment.