@@ -445,17 +445,20 @@ def test_update(self):
445445
446446 # Test success flow
447447 with patch ("requests.post" ) as mock_post :
448- mock_post .return_value .ok = True
449- self .assertIsNone (
450- self .client .mgmt .user .update (
451- "id" ,
452- display_name = "new-name" ,
453- role_names = ["domain.com" ],
454- picture = "https://test.com" ,
455- custom_attributes = {"ak" : "av" },
456- sso_app_ids = ["app1" , "app2" ],
457- )
448+ network_resp = mock .Mock ()
449+ network_resp .ok = True
450+ network_resp .json .return_value = json .loads ("""{"user": {"id": "u1"}}""" )
451+ mock_post .return_value = network_resp
452+ resp = self .client .mgmt .user .update (
453+ "id" ,
454+ display_name = "new-name" ,
455+ role_names = ["domain.com" ],
456+ picture = "https://test.com" ,
457+ custom_attributes = {"ak" : "av" },
458+ sso_app_ids = ["app1" , "app2" ],
458459 )
460+ user = resp ["user" ]
461+ self .assertEqual (user ["id" ], "u1" )
459462 mock_post .assert_called_with (
460463 f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_update_path } " ,
461464 headers = {
@@ -482,12 +485,15 @@ def test_update(self):
482485 )
483486 # Test success flow with verified flags
484487 with patch ("requests.post" ) as mock_post :
485- mock_post .return_value .ok = True
486- self .assertIsNone (
487- self .client .mgmt .user .update (
488- "id" , verified_email = True , verified_phone = False
489- )
488+ network_resp = mock .Mock ()
489+ network_resp .ok = True
490+ network_resp .json .return_value = json .loads ("""{"user": {"id": "u1"}}""" )
491+ mock_post .return_value = network_resp
492+ resp = self .client .mgmt .user .update (
493+ "id" , verified_email = True , verified_phone = False
490494 )
495+ user = resp ["user" ]
496+ self .assertEqual (user ["id" ], "u1" )
491497 mock_post .assert_called_with (
492498 f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_update_path } " ,
493499 headers = {
@@ -528,21 +534,24 @@ def test_patch(self):
528534
529535 # Test success flow with some params set
530536 with patch ("requests.patch" ) as mock_patch :
531- mock_patch .return_value .ok = True
532- self .assertIsNone (
533- self .client .mgmt .user .patch (
534- "id" ,
535- display_name = "new-name" ,
536- email = None ,
537- phone = None ,
538- given_name = None ,
539- role_names = ["domain.com" ],
540- user_tenants = None ,
541- picture = "https://test.com" ,
542- custom_attributes = {"ak" : "av" },
543- sso_app_ids = ["app1" , "app2" ],
544- )
537+ network_resp = mock .Mock ()
538+ network_resp .ok = True
539+ network_resp .json .return_value = json .loads ("""{"user": {"id": "u1"}}""" )
540+ mock_patch .return_value = network_resp
541+ resp = self .client .mgmt .user .patch (
542+ "id" ,
543+ display_name = "new-name" ,
544+ email = None ,
545+ phone = None ,
546+ given_name = None ,
547+ role_names = ["domain.com" ],
548+ user_tenants = None ,
549+ picture = "https://test.com" ,
550+ custom_attributes = {"ak" : "av" },
551+ sso_app_ids = ["app1" , "app2" ],
545552 )
553+ user = resp ["user" ]
554+ self .assertEqual (user ["id" ], "u1" )
546555 mock_patch .assert_called_with (
547556 f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_patch_path } " ,
548557 headers = {
@@ -564,25 +573,28 @@ def test_patch(self):
564573 )
565574 # Test success flow with other params
566575 with patch ("requests.patch" ) as mock_patch :
567- mock_patch .return_value .ok = True
568- self .assertIsNone (
569- self .client .mgmt .user .patch (
570- "id" ,
571- email = "a@test.com" ,
572- phone = "+123456789" ,
573- given_name = "given" ,
574- middle_name = "middle" ,
575- family_name = "family" ,
576- role_names = None ,
577- user_tenants = [
578- AssociatedTenant ("tenant1" ),
579- AssociatedTenant ("tenant2" , ["role1" , "role2" ]),
580- ],
581- custom_attributes = None ,
582- verified_email = True ,
583- verified_phone = False ,
584- )
576+ network_resp = mock .Mock ()
577+ network_resp .ok = True
578+ network_resp .json .return_value = json .loads ("""{"user": {"id": "u1"}}""" )
579+ mock_patch .return_value = network_resp
580+ resp = self .client .mgmt .user .patch (
581+ "id" ,
582+ email = "a@test.com" ,
583+ phone = "+123456789" ,
584+ given_name = "given" ,
585+ middle_name = "middle" ,
586+ family_name = "family" ,
587+ role_names = None ,
588+ user_tenants = [
589+ AssociatedTenant ("tenant1" ),
590+ AssociatedTenant ("tenant2" , ["role1" , "role2" ]),
591+ ],
592+ custom_attributes = None ,
593+ verified_email = True ,
594+ verified_phone = False ,
585595 )
596+ user = resp ["user" ]
597+ self .assertEqual (user ["id" ], "u1" )
586598 mock_patch .assert_called_with (
587599 f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_patch_path } " ,
588600 headers = {
0 commit comments