@@ -191,3 +191,33 @@ def test_get_current_user_mask(self):
191191 result = self .manager .get_current_user (objectmask = "mask[id]" )
192192 self .assert_called_with ('SoftLayer_Account' , 'getCurrentUser' , mask = "mask[id]" )
193193 self .assertEqual (result ['id' ], 12345 )
194+
195+ def test_create_user_handle_paas_exception (self ):
196+ user_template = {"username" : "foobar" , "email" : "foobar@example.com" }
197+
198+ self .manager .user_service = mock .Mock ()
199+
200+ # FaultCode IS NOT SoftLayer_Exception_User_Customer_DelegateIamIdInvitationToPaas
201+ any_error = exceptions .SoftLayerAPIError ("SoftLayer_Exception_User_Customer" ,
202+ "This exception indicates an error" )
203+
204+ self .manager .user_service .createObject .side_effect = any_error
205+
206+ try :
207+ self .manager .create_user (user_template , "Pass@123" )
208+ except exceptions .SoftLayerAPIError as ex :
209+ self .assertEqual (ex .faultCode , "SoftLayer_Exception_User_Customer" )
210+ self .assertEqual (ex .faultString , "This exception indicates an error" )
211+
212+ # FaultCode is SoftLayer_Exception_User_Customer_DelegateIamIdInvitationToPaas
213+ paas_error = exceptions .SoftLayerAPIError ("SoftLayer_Exception_User_Customer_DelegateIamIdInvitationToPaas" ,
214+ "This exception does NOT indicate an error" )
215+
216+ self .manager .user_service .createObject .side_effect = paas_error
217+
218+ try :
219+ self .manager .create_user (user_template , "Pass@123" )
220+ except exceptions .SoftLayerError as ex :
221+ self .assertEqual (ex .args [0 ], "Your request for a new user was received, but it needs to be processed by "
222+ "the Platform Services API first. Barring any errors on the Platform Services "
223+ "side, your new user should be created shortly." )
0 commit comments