@@ -100,10 +100,7 @@ async def test_access_update_profile(
100100 await assert_status (resp , expected )
101101
102102
103- @pytest .mark .parametrize (
104- "user_role" ,
105- [UserRole .USER ],
106- )
103+ @pytest .mark .parametrize ("user_role" , [UserRole .USER ])
107104async def test_get_profile (
108105 logged_user : UserInfoDict ,
109106 client : TestClient ,
@@ -156,10 +153,7 @@ async def test_get_profile(
156153 )
157154
158155
159- @pytest .mark .parametrize (
160- "user_role" ,
161- [UserRole .USER ],
162- )
156+ @pytest .mark .parametrize ("user_role" , [UserRole .USER ])
163157async def test_update_profile (
164158 logged_user : UserInfoDict ,
165159 client : TestClient ,
@@ -197,10 +191,7 @@ def _copy(data: dict, exclude: set) -> dict:
197191 assert _copy (data , exclude ) == _copy (before , exclude )
198192
199193
200- @pytest .mark .parametrize (
201- "user_role" ,
202- [UserRole .USER ],
203- )
194+ @pytest .mark .parametrize ("user_role" , [UserRole .USER ])
204195async def test_profile_workflow (
205196 logged_user : UserInfoDict ,
206197 client : TestClient ,
@@ -217,7 +208,7 @@ async def test_profile_workflow(
217208 resp = await client .patch (
218209 f"{ url } " ,
219210 json = {
220- "firstName " : "Odei" ,
211+ "first_name " : "Odei" , # NOTE: still not camecase!
221212 "userName" : "odei123" ,
222213 "privacy" : {"hide_fullname" : False },
223214 },
@@ -241,34 +232,41 @@ async def test_profile_workflow(
241232 assert updated_profile .privacy .hide_fullname != my_profile .privacy .hide_fullname
242233
243234
244- @pytest .mark .parametrize (
245- "user_role" ,
246- [UserRole .USER ],
247- )
235+ @pytest .mark .parametrize ("user_role" , [UserRole .USER ])
236+ @pytest .mark .parametrize ("invalid_username" , ["" , "_foo" , "superadmin" , "foo..-123" ])
248237async def test_update_wrong_user_name (
249238 logged_user : UserInfoDict ,
250239 client : TestClient ,
251240 user_role : UserRole ,
241+ invalid_username : str ,
252242):
253243 assert client .app
254244
255- # update with INVALID username
256245 url = client .app .router ["update_my_profile" ].url_for ()
246+ resp = await client .patch (
247+ f"{ url } " ,
248+ json = {
249+ "userName" : invalid_username ,
250+ },
251+ )
252+ await assert_status (resp , status .HTTP_422_UNPROCESSABLE_ENTITY )
257253
258- for invalid_username in ( "_foo" , "superadmin" , "foo..-123" ):
259- resp = await client . patch (
260- f" { url } " ,
261- json = {
262- "userName" : invalid_username ,
263- } ,
264- )
265- await assert_status ( resp , status . HTTP_422_UNPROCESSABLE_ENTITY )
254+
255+ @ pytest . mark . parametrize ( "user_role" , [ UserRole . USER ])
256+ async def test_update_existing_user_name (
257+ logged_user : UserInfoDict ,
258+ client : TestClient ,
259+ user_role : UserRole ,
260+ ):
261+ assert client . app
266262
267263 # update with SAME username (i.e. existing)
268264 url = client .app .router ["get_my_profile" ].url_for ()
269265 resp = await client .get (f"{ url } " )
270266 data , _ = await assert_status (resp , status .HTTP_200_OK )
271267
268+ assert data ["userName" ] == logged_user ["name" ]
269+
272270 url = client .app .router ["update_my_profile" ].url_for ()
273271 resp = await client .patch (
274272 f"{ url } " ,
0 commit comments