|
15 | 15 | from models_library.projects_nodes_io import NodeID |
16 | 16 | from simcore_postgres_database.models.comp_pipeline import StateType, comp_pipeline |
17 | 17 | from simcore_postgres_database.models.comp_tasks import comp_tasks |
| 18 | +from simcore_postgres_database.models.products import products |
18 | 19 | from simcore_postgres_database.models.projects import ProjectType, projects |
19 | 20 | from simcore_postgres_database.models.projects_to_products import projects_to_products |
20 | 21 | from simcore_postgres_database.models.services import services_access_rights |
@@ -65,9 +66,28 @@ def creator(**user_kwargs) -> dict[str, Any]: |
65 | 66 | print(f"<-- deleted users {created_user_ids=}") |
66 | 67 |
|
67 | 68 |
|
| 69 | +@pytest.fixture |
| 70 | +async def product_db( |
| 71 | + sqlalchemy_async_engine: AsyncEngine, product: dict[str, Any] |
| 72 | +) -> AsyncIterator[ProductName]: |
| 73 | + async with sqlalchemy_async_engine.begin() as con: |
| 74 | + result = await con.execute( |
| 75 | + products.insert().values(**product).returning(sa.literal_column("*")) |
| 76 | + ) |
| 77 | + created_product = result.one() |
| 78 | + print(f"--> created product {created_product.name=}") |
| 79 | + yield created_product.name |
| 80 | + |
| 81 | + async with sqlalchemy_async_engine.begin() as con: |
| 82 | + await con.execute( |
| 83 | + products.delete().where(products.c.name == created_product.name) |
| 84 | + ) |
| 85 | + print(f"<-- deleted product {created_product.name=}") |
| 86 | + |
| 87 | + |
68 | 88 | @pytest.fixture |
69 | 89 | async def project( |
70 | | - sqlalchemy_async_engine: AsyncEngine, faker: Faker, product_name: ProductName |
| 90 | + sqlalchemy_async_engine: AsyncEngine, faker: Faker, product_db: ProductName |
71 | 91 | ) -> AsyncIterator[Callable[..., Awaitable[ProjectAtDB]]]: |
72 | 92 | created_project_ids: list[str] = [] |
73 | 93 |
|
@@ -118,7 +138,7 @@ async def creator( |
118 | 138 | await con.execute( |
119 | 139 | projects_to_products.insert().values( |
120 | 140 | project_uuid=f"{inserted_project.uuid}", |
121 | | - product_name=product_name, |
| 141 | + product_name=product_db, |
122 | 142 | ) |
123 | 143 | ) |
124 | 144 | print(f"--> created {inserted_project=}") |
|
0 commit comments