diff --git a/services/web/server/src/simcore_service_webserver/projects/_create_utils.py b/services/web/server/src/simcore_service_webserver/projects/_create_utils.py index b775972a916..18488414a91 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_create_utils.py +++ b/services/web/server/src/simcore_service_webserver/projects/_create_utils.py @@ -8,6 +8,7 @@ from models_library.projects import ProjectID from models_library.projects_state import ProjectStatus from models_library.users import UserID +from models_library.utils.fastapi_encoders import jsonable_encoder from pydantic import parse_obj_as from servicelib.aiohttp.long_running_tasks.server import TaskProgress from servicelib.json_serialization import json_dumps @@ -204,8 +205,8 @@ async def create_project( # 3. save new project in DB new_project = await db.insert_project( - new_project, - user_id, + project=jsonable_encoder(new_project), + user_id=user_id, product_name=product_name, force_as_template=as_template, hidden=copy_data, diff --git a/services/web/server/src/simcore_service_webserver/projects/projects_db.py b/services/web/server/src/simcore_service_webserver/projects/projects_db.py index 595a2ecb1b0..bf215916657 100644 --- a/services/web/server/src/simcore_service_webserver/projects/projects_db.py +++ b/services/web/server/src/simcore_service_webserver/projects/projects_db.py @@ -116,6 +116,7 @@ async def insert_project( :raises ValidationError :return: inserted project """ + # pylint: disable=no-value-for-parameter async with self.engine.acquire() as conn: # TODO: check security of this query with args. Hard-code values? @@ -133,9 +134,9 @@ async def insert_project( insert_values = convert_to_db_names(project) insert_values.update( { - "type": ProjectType.TEMPLATE + "type": ProjectType.TEMPLATE.value if (force_as_template or user_id is None) - else ProjectType.STANDARD, + else ProjectType.STANDARD.value, "prj_owner": user_id if user_id else None, } ) diff --git a/services/web/server/tests/integration/01/test_project_workflow.py b/services/web/server/tests/integration/01/test_project_workflow.py index 86cb501b4e4..837dc7f8eb7 100644 --- a/services/web/server/tests/integration/01/test_project_workflow.py +++ b/services/web/server/tests/integration/01/test_project_workflow.py @@ -190,7 +190,7 @@ async def _request_get(client, pid) -> dict: return project -async def _request_update(client, project, pid): +async def _request_replace(client, project, pid): # PUT /v0/projects/{project_id} url = client.app.router["replace_project"].url_for(project_id=pid) resp = await client.put(url, json=project) @@ -207,6 +207,7 @@ async def _request_delete(client, pid): await assert_status(resp, web.HTTPNoContent) +@pytest.mark.testit @pytest.mark.parametrize("user_role", [UserRole.USER]) async def test_workflow( postgres_db: sa.engine.Engine, @@ -272,7 +273,7 @@ async def test_workflow( ) # modify pid = modified_project["uuid"] - await _request_update(client, modified_project, pid) + await _request_replace(client, modified_project, pid) # list not empty projects = await _request_list(client)