Skip to content

Commit d0620b8

Browse files
committed
common
1 parent 6bc16c4 commit d0620b8

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

packages/pytest-simcore/src/pytest_simcore/faker_users_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def user(
129129
user_name: IDStr,
130130
user_password: str,
131131
) -> dict[str, Any]:
132+
"""NOTE: it returns user data including poassword and password_hash"""
132133
secrets = random_user_secrets(fake=faker, user_id=user_id, password=user_password)
133134
assert secrets["user_id"] == user_id
134135
return {

packages/simcore-sdk/tests/integration/conftest.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from models_library.users import UserID
2020
from pydantic import TypeAdapter
2121
from pytest_simcore.helpers.faker_factories import random_project, random_user
22+
from pytest_simcore.helpers.postgres_tools import sync_insert_and_get_row_lifespan
2223
from settings_library.aws_s3_cli import AwsS3CliSettings
2324
from settings_library.r_clone import RCloneSettings, S3Provider
2425
from settings_library.s3 import S3Settings
@@ -40,18 +41,16 @@ def user_id(postgres_db: sa.engine.Engine) -> Iterable[UserID]:
4041
# which would turn this test too complex.
4142

4243
# pylint: disable=no-value-for-parameter
43-
with postgres_db.connect() as conn:
44-
result = conn.execute(
45-
users.insert().values(**random_user(name="test")).returning(users.c.id)
46-
)
47-
row = result.first()
48-
assert row
49-
usr_id = row[users.c.id]
50-
51-
yield usr_id
52-
53-
with postgres_db.connect() as conn:
54-
conn.execute(users.delete().where(users.c.id == usr_id))
44+
with sync_insert_and_get_row_lifespan( # pylint:disable=contextmanager-generator-missing-cleanup
45+
postgres_db,
46+
table=users,
47+
values=random_user(
48+
name="test",
49+
),
50+
pk_col=users.c.id,
51+
) as user_row:
52+
53+
yield user_row["id"]
5554

5655

5756
@pytest.fixture

services/dynamic-sidecar/tests/integration/conftest.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sqlalchemy as sa
55
from models_library.users import UserID
66
from pytest_simcore.helpers.faker_factories import random_user
7+
from pytest_simcore.helpers.postgres_tools import sync_insert_and_get_row_lifespan
78
from simcore_postgres_database.models.users import users
89

910
pytest_plugins = [
@@ -24,15 +25,13 @@ def user_id(postgres_db: sa.engine.Engine) -> Iterable[UserID]:
2425
# which would turn this test too complex.
2526

2627
# pylint: disable=no-value-for-parameter
27-
stmt = users.insert().values(**random_user(name="test")).returning(users.c.id)
28-
print(f"{stmt}")
29-
with postgres_db.connect() as conn:
30-
result = conn.execute(stmt)
31-
row = result.first()
32-
assert row
33-
usr_id = row[users.c.id]
34-
35-
yield usr_id
36-
37-
with postgres_db.connect() as conn:
38-
conn.execute(users.delete().where(users.c.id == usr_id))
28+
with sync_insert_and_get_row_lifespan( # pylint:disable=contextmanager-generator-missing-cleanup
29+
postgres_db,
30+
table=users,
31+
values=random_user(
32+
name="test",
33+
),
34+
pk_col=users.c.id,
35+
) as user_row:
36+
37+
yield user_row["id"]

0 commit comments

Comments
 (0)