@@ -1260,6 +1260,44 @@ def test_resend_invitation_accepted(self, capture_and_mock_http_client_request):
12601260 with pytest .raises (Exception ):
12611261 syncify (self .user_management .resend_invitation ("invitation_accepted" ))
12621262
1263+ def test_accept_invitation (
1264+ self , capture_and_mock_http_client_request , mock_invitation
1265+ ):
1266+ request_kwargs = capture_and_mock_http_client_request (
1267+ self .http_client , mock_invitation , 200
1268+ )
1269+
1270+ invitation = syncify (self .user_management .accept_invitation ("invitation_ABCDE" ))
1271+
1272+ assert request_kwargs ["url" ].endswith (
1273+ "user_management/invitations/invitation_ABCDE/accept"
1274+ )
1275+ assert request_kwargs ["method" ] == "post"
1276+ assert isinstance (invitation , Invitation )
1277+ assert invitation .id == "invitation_ABCDE"
1278+
1279+ def test_accept_invitation_not_found (self , capture_and_mock_http_client_request ):
1280+ error_response = {
1281+ "message" : "Invitation not found" ,
1282+ "code" : "not_found" ,
1283+ }
1284+ capture_and_mock_http_client_request (self .http_client , error_response , 404 )
1285+
1286+ with pytest .raises (Exception ):
1287+ syncify (self .user_management .accept_invitation ("invitation_nonexistent" ))
1288+
1289+ def test_accept_invitation_already_accepted (
1290+ self , capture_and_mock_http_client_request
1291+ ):
1292+ error_response = {
1293+ "message" : "Invite has already been accepted." ,
1294+ "code" : "invite_accepted" ,
1295+ }
1296+ capture_and_mock_http_client_request (self .http_client , error_response , 400 )
1297+
1298+ with pytest .raises (Exception ):
1299+ syncify (self .user_management .accept_invitation ("invitation_accepted" ))
1300+
12631301 def test_list_feature_flags (
12641302 self , mock_feature_flags , capture_and_mock_http_client_request
12651303 ):
0 commit comments