@@ -231,6 +231,14 @@ async def test_search_and_pre_registration(
231231):
232232 assert client .app
233233
234+ # NOTE: listing of user accounts drops nullable fields to avoid lengthy responses (even if they have no defaults)
235+ # therefore they are reconstructed here from http response payloads
236+ nullable_fields = {
237+ name : None
238+ for name , field in UserAccountGet .model_fields .items ()
239+ if is_nullable (field )
240+ }
241+
234242 # ONLY in `users` and NOT `users_pre_registration_details`
235243 resp = await client .get (
236244 "/v0/admin/user-accounts:search" , params = {"email" : logged_user ["email" ]}
@@ -240,12 +248,6 @@ async def test_search_and_pre_registration(
240248 found , _ = await assert_status (resp , status .HTTP_200_OK )
241249 assert len (found ) == 1
242250
243- nullable_fields = {
244- name : None
245- for name , field in UserAccountGet .model_fields .items ()
246- if is_nullable (field )
247- }
248-
249251 got = UserAccountGet .model_validate ({** nullable_fields , ** found [0 ]})
250252 expected = {
251253 "first_name" : logged_user .get ("first_name" ),
@@ -263,7 +265,7 @@ async def test_search_and_pre_registration(
263265 "status" : UserStatus .ACTIVE ,
264266 "user_id" : logged_user ["id" ],
265267 "user_name" : logged_user ["name" ],
266- "user_primary_group_id" : logged_user .get ("primary_group_id " ),
268+ "user_primary_group_id" : logged_user .get ("primary_gid " ),
267269 }
268270 assert got .model_dump (include = set (expected )) == expected
269271
@@ -281,8 +283,8 @@ async def test_search_and_pre_registration(
281283 )
282284 found , _ = await assert_status (resp , status .HTTP_200_OK )
283285 assert len (found ) == 1
284- got = UserAccountGet (** found [0 ], state = None , status = None )
285286
287+ got = UserAccountGet .model_validate ({** nullable_fields , ** found [0 ]})
286288 assert got .model_dump (include = {"registered" , "status" }) == {
287289 "registered" : False ,
288290 "status" : None ,
@@ -305,7 +307,8 @@ async def test_search_and_pre_registration(
305307 )
306308 found , _ = await assert_status (resp , status .HTTP_200_OK )
307309 assert len (found ) == 1
308- got = UserAccountGet (** found [0 ], state = None )
310+
311+ got = UserAccountGet .model_validate ({** nullable_fields , ** found [0 ]})
309312 assert got .model_dump (include = {"registered" , "status" }) == {
310313 "registered" : True ,
311314 "status" : new_user ["status" ],
0 commit comments