Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_confInConstruct(self):
sdk = MangoPayApi()
# store auth data, to not break unit tests order-independency rule
clientId = sdk.Config.ClientID
clientPassword = sdk.Config.ClientPassword
token = sdk.OAuthTokenManager.GetToken()
sdk.Config.ClientID = "test_asd"
sdk.Config.ClientPassword = "00000"
sdk.OAuthTokenManager.StoreToken(None)
with self.assertRaises(ResponseException) as cm:
sdk.users.GetAll()
# bring valid auth data back
sdk.Config.ClientID = clientId
sdk.Config.ClientPassword = clientPassword
sdk.OAuthTokenManager.StoreToken(token)
def test_Clients_TryCreateInvalidClient(self):
with self.assertRaises(ResponseException) as cm:
# invalid id
client = self.sdk.clients.Create('0', 'test', 'test@o2.pl')
def test_Users_CreateLegal_FailsIfRequiredPropsNotProvided(self):
user = UserLegal()
with self.assertRaises(ResponseException) as cm:
self.sdk.users.Create(user)
self.assertEqual(400, cm.exception.Code)
self.assertTrue('One or several required parameters are missing or incorrect' in cm.exception.Message)
def _checkResponseCode(self, response, decodedResp):
"""Check response code.
param object response Response from REST API
@throws RequestException If response code not OK
"""
if response.status_code != requests.codes.ok and response.status_code != requests.codes.no_content:
message = str(response.status_code)
if decodedResp != None and decodedResp.get('Message') != None:
message = decodedResp.get('Message') + u' '
if decodedResp != None and decodedResp.get('errors') != None:
message = message + u'Errors: '
for e in decodedResp.get('errors'):
message = message + u'[' + e + u': ' + decodedResp.get('errors')[e] + u'] '
raise ResponseException(response.request.url, response.status_code, message)