1616import simcore_service_webserver .login ._auth_api
1717from aiohttp .test_utils import TestClient
1818from aiopg .sa .connection import SAConnection
19+ from common_library .users_enums import UserRole , UserStatus
1920from faker import Faker
2021from models_library .api_schemas_webserver .auth import AccountRequestInfo
2122from models_library .api_schemas_webserver .users import MyProfileGet , UserGet
22- from models_library .generics import Envelope
2323from psycopg2 import OperationalError
2424from pytest_simcore .helpers .assert_checks import assert_status
2525from pytest_simcore .helpers .faker_factories import (
3030from pytest_simcore .helpers .webserver_login import UserInfoDict
3131from servicelib .aiohttp import status
3232from servicelib .rest_constants import RESPONSE_MODEL_POLICY
33- from simcore_postgres_database .models .users import UserRole , UserStatus
3433from simcore_service_webserver .users ._common .schemas import (
3534 MAX_BYTES_SIZE_EXTRAS ,
3635 PreRegisteredUserGet ,
@@ -116,36 +115,31 @@ async def test_get_profile(
116115 resp = await client .get (f"{ url } " )
117116 data , error = await assert_status (resp , status .HTTP_200_OK )
118117
119- resp_model = Envelope [MyProfileGet ].model_validate (await resp .json ())
120-
121- assert resp_model .data .model_dump (** RESPONSE_MODEL_POLICY , mode = "json" ) == data
122- assert resp_model .error is None
123-
124- profile = resp_model .data
125-
126- product_group = {
127- "accessRights" : {"delete" : False , "read" : False , "write" : False },
128- "description" : "osparc product group" ,
129- "gid" : 2 ,
130- "inclusionRules" : {},
131- "label" : "osparc" ,
132- "thumbnail" : None ,
133- }
118+ assert not error
119+ profile = MyProfileGet .model_validate (data )
134120
135121 assert profile .login == logged_user ["email" ]
136122 assert profile .first_name == logged_user .get ("first_name" , None )
137123 assert profile .last_name == logged_user .get ("last_name" , None )
138124 assert profile .role == user_role .name
139125 assert profile .groups
126+ assert profile .expiration_date is None
140127
141128 got_profile_groups = profile .groups .model_dump (** RESPONSE_MODEL_POLICY , mode = "json" )
142129 assert got_profile_groups ["me" ] == primary_group
143130 assert got_profile_groups ["all" ] == all_group
131+ assert got_profile_groups ["product" ] == {
132+ "accessRights" : {"delete" : False , "read" : False , "write" : False },
133+ "description" : "osparc product group" ,
134+ "gid" : 2 ,
135+ "label" : "osparc" ,
136+ "thumbnail" : None ,
137+ }
144138
145139 sorted_by_group_id = functools .partial (sorted , key = lambda d : d ["gid" ])
146140 assert sorted_by_group_id (
147141 got_profile_groups ["organizations" ]
148- ) == sorted_by_group_id ([ * standard_groups , product_group ] )
142+ ) == sorted_by_group_id (standard_groups )
149143
150144 assert profile .preferences == await get_frontend_user_preferences_aggregation (
151145 client .app , user_id = logged_user ["id" ], product_name = "osparc"
@@ -160,25 +154,28 @@ async def test_update_profile(
160154):
161155 assert client .app
162156
163- resp = await client .get ("/v0/me" )
164- data , _ = await assert_status (resp , status .HTTP_200_OK )
157+ # GET
158+ url = client .app .router ["get_my_profile" ].url_for ()
159+ resp = await client .get (f"{ url } " )
165160
161+ data , _ = await assert_status (resp , status .HTTP_200_OK )
166162 assert data ["role" ] == user_role .name
167163 before = deepcopy (data )
168164
165+ # UPDATE
169166 url = client .app .router ["update_my_profile" ].url_for ()
170- assert url .path == "/v0/me"
171167 resp = await client .patch (
172168 f"{ url } " ,
173169 json = {
174170 "last_name" : "Foo" ,
175171 },
176172 )
177173 _ , error = await assert_status (resp , status .HTTP_204_NO_CONTENT )
178-
179174 assert not error
180175
181- resp = await client .get ("/v0/me" )
176+ # GET
177+ url = client .app .router ["get_my_profile" ].url_for ()
178+ resp = await client .get (f"{ url } " )
182179 data , _ = await assert_status (resp , status .HTTP_200_OK )
183180
184181 assert data ["last_name" ] == "Foo"
0 commit comments