@@ -445,17 +445,20 @@ def test_update(self):
445
445
446
446
# Test success flow
447
447
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" ],
458
459
)
460
+ user = resp ["user" ]
461
+ self .assertEqual (user ["id" ], "u1" )
459
462
mock_post .assert_called_with (
460
463
f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_update_path } " ,
461
464
headers = {
@@ -482,12 +485,15 @@ def test_update(self):
482
485
)
483
486
# Test success flow with verified flags
484
487
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
490
494
)
495
+ user = resp ["user" ]
496
+ self .assertEqual (user ["id" ], "u1" )
491
497
mock_post .assert_called_with (
492
498
f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_update_path } " ,
493
499
headers = {
@@ -528,21 +534,24 @@ def test_patch(self):
528
534
529
535
# Test success flow with some params set
530
536
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" ],
545
552
)
553
+ user = resp ["user" ]
554
+ self .assertEqual (user ["id" ], "u1" )
546
555
mock_patch .assert_called_with (
547
556
f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_patch_path } " ,
548
557
headers = {
@@ -564,25 +573,28 @@ def test_patch(self):
564
573
)
565
574
# Test success flow with other params
566
575
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
-
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
+
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 ,
585
595
)
596
+ user = resp ["user" ]
597
+ self .assertEqual (user ["id" ], "u1" )
586
598
mock_patch .assert_called_with (
587
599
f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_patch_path } " ,
588
600
headers = {
0 commit comments