Skip to content

Commit 5b7935a

Browse files
committed
faker
1 parent c209c6b commit 5b7935a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/models-library/tests/test_services_types.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import pytest
22
from models_library.projects import ProjectID
33
from models_library.projects_nodes import NodeID
4-
from models_library.services_types import ServiceRunID
4+
from models_library.services_types import ServiceKey, ServiceRunID, ServiceVersion
55
from models_library.users import UserID
6-
from pydantic import PositiveInt
6+
from pydantic import PositiveInt, TypeAdapter
7+
from pytest_simcore.helpers.faker_factories import (
8+
random_service_key,
9+
random_service_version,
10+
)
711

812

913
@pytest.mark.parametrize(
@@ -38,3 +42,12 @@ def test_get_resource_tracking_run_id_for_dynamic():
3842
assert isinstance(
3943
ServiceRunID.get_resource_tracking_run_id_for_dynamic(), ServiceRunID
4044
)
45+
46+
47+
def test_faker_factories_random_service_key_and_version_are_in_sync():
48+
49+
for _ in range(10):
50+
key = random_service_key()
51+
version = random_service_version()
52+
TypeAdapter(ServiceKey).validate_python(key)
53+
TypeAdapter(ServiceVersion).validate_python(version)

packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727

2828
def random_service_key(fake: Faker = DEFAULT_FAKER, *, name: str | None = None) -> str:
29-
"""Generates a random service key"""
30-
return f"simcore/services/{fake.random_element(['dynamic', 'computational'])}/{name or fake.name()}"
29+
return f"simcore/services/{fake.random_element(['dynamic', 'comp', 'frontend'])}/{name or fake.name().lower().replace(' ', '')}"
3130

3231

3332
def random_service_version(fake: Faker = DEFAULT_FAKER) -> str:

0 commit comments

Comments
 (0)