|
10 | 10 | import sqlalchemy as sa |
11 | 11 | import sqlalchemy.engine |
12 | 12 | import sqlalchemy.exc |
| 13 | +from common_library.users_enums import UserRole |
13 | 14 | from faker import Faker |
14 | 15 | from pytest_simcore.helpers import postgres_tools |
15 | 16 | from pytest_simcore.helpers.faker_factories import random_project, random_user |
16 | 17 | from simcore_postgres_database.models.projects import projects |
17 | 18 | from simcore_postgres_database.models.projects_to_jobs import projects_to_jobs |
18 | | -from simcore_postgres_database.models.users import users |
19 | 19 |
|
20 | 20 |
|
21 | 21 | @pytest.fixture |
@@ -66,9 +66,24 @@ def test_populate_projects_to_jobs_during_migration( |
66 | 66 |
|
67 | 67 | # INSERT data (emulates data in-place) |
68 | 68 | user_data = random_user( |
69 | | - faker, name="test_populate_projects_to_jobs_during_migration" |
| 69 | + faker, |
| 70 | + name="test_populate_projects_to_jobs_during_migration", |
| 71 | + role=UserRole.USER.value, |
70 | 72 | ) |
71 | | - stmt = users.insert().values(**user_data).returning(users.c.id) |
| 73 | + user_data["password_hash"] = ( |
| 74 | + "password_hash_was_still_here_at_this_migration_commit" # noqa: S105 |
| 75 | + ) |
| 76 | + |
| 77 | + columns = list(user_data.keys()) |
| 78 | + values_clause = ", ".join(f":{col}" for col in columns) |
| 79 | + columns_clause = ", ".join(columns) |
| 80 | + stmt = sa.text( |
| 81 | + f""" |
| 82 | + INSERT INTO users ({columns_clause}) |
| 83 | + VALUES ({values_clause}) |
| 84 | + RETURNING id |
| 85 | + """ # noqa: S608 |
| 86 | + ).bindparams(**user_data) |
72 | 87 | result = conn.execute(stmt) |
73 | 88 | user_id = result.scalar() |
74 | 89 |
|
|
0 commit comments