File tree Expand file tree Collapse file tree 3 files changed +23
-24
lines changed
pytest-simcore/src/pytest_simcore
simcore-sdk/tests/integration
services/dynamic-sidecar/tests/integration Expand file tree Collapse file tree 3 files changed +23
-24
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change 1919from models_library .users import UserID
2020from pydantic import TypeAdapter
2121from pytest_simcore .helpers .faker_factories import random_project , random_user
22+ from pytest_simcore .helpers .postgres_tools import sync_insert_and_get_row_lifespan
2223from settings_library .aws_s3_cli import AwsS3CliSettings
2324from settings_library .r_clone import RCloneSettings , S3Provider
2425from 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
Original file line number Diff line number Diff line change 44import sqlalchemy as sa
55from models_library .users import UserID
66from pytest_simcore .helpers .faker_factories import random_user
7+ from pytest_simcore .helpers .postgres_tools import sync_insert_and_get_row_lifespan
78from simcore_postgres_database .models .users import users
89
910pytest_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" ]
You can’t perform that action at this time.
0 commit comments