Skip to content

Commit f7cf17b

Browse files
committed
fixing fakes
1 parent 9c0640e commit f7cf17b

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

packages/models-library/tests/test_services_types.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ def test_get_resource_tracking_run_id_for_dynamic():
4444
)
4545

4646

47-
def test_faker_factories_random_service_key_and_version_are_in_sync():
47+
@pytest.mark.parametrize(
48+
"service_key, service_version",
49+
[(random_service_key(), random_service_version()) for _ in range(10)],
50+
)
51+
def test_service_key_and_version_are_in_sync(
52+
service_key: ServiceKey, service_version: ServiceVersion
53+
):
54+
TypeAdapter(ServiceKey).validate_python(service_key)
55+
TypeAdapter(ServiceVersion).validate_python(service_version)
4856

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)
57+
assert service_key.startswith("simcore/services/")

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727

2828
def random_service_key(fake: Faker = DEFAULT_FAKER, *, name: str | None = None) -> str:
29-
return f"simcore/services/{fake.random_element(['dynamic', 'comp', 'frontend'])}/{name or fake.name().lower().replace(' ', '')}"
29+
suffix = fake.unique.word() if name is None else name
30+
return f"simcore/services/{fake.random_element(['dynamic', 'comp', 'frontend'])}/{suffix}"
3031

3132

3233
def random_service_version(fake: Faker = DEFAULT_FAKER) -> str:
33-
return ".".join([str(fake.pyint()) for _ in range(3)])
34+
return ".".join([str(fake.pyint(0, 100)) for _ in range(3)])
3435

3536

3637
def random_icon_url(fake: Faker):

0 commit comments

Comments
 (0)