def test_Users_GetKycDocuments(self): kycDocument = self.getUserKycDocument() user = self.getJohn() pagination = Pagination(1, 10) self.sdk.users.GetKycDocuments(user.Id, pagination) pagination.Page = pagination.TotalPages getKycDocuments = self.sdk.users.GetKycDocuments(user.Id, pagination) kycFromList = self.getEntityFromList(kycDocument.Id, getKycDocuments) self.assertIsInstance(kycFromList, KycDocument) self.assertEqualInputProps(kycDocument, kycFromList)
def test_KycDocuments_GetAll(self): kycDocument = self.getUserKycDocument() pagination = Pagination(1, 100) self.sdk.kycdocuments.GetAll(pagination) pagination.Page = pagination.TotalPages list = self.sdk.kycdocuments.GetAll(pagination) kycFromList = self.getEntityFromList(kycDocument.Id, list) self.assertTrue(isinstance(kycFromList, KycDocument)) self.assertEqualInputProps(kycDocument, kycFromList) self.assertEqual(pagination.ItemsPerPage, 100)
def test_Disputes_GetTransactions(self): self.refreshClientDisputes() dispute = None for d in self._clientDisputes: if (d.DisputeType == DisputeType.NOT_CONTESTABLE): dispute = d break self.assertIsNotNone( dispute, 'Cannot test getting dispute\'s transactions because there\'s no not contestable dispute in the disputes list.' ) pagination = Pagination(1, 10) transactions = self.sdk.disputes.GetTransactions( dispute.Id, pagination) self.assertIsNotNone(transactions) self.assertTrue(len(transactions) > 0)
def test_Disputes_GetDisputesForWallet(self): self.refreshClientDisputes() dispute = None for d in self._clientDisputes: if (d.InitialTransactionId != None): dispute = d break self.assertIsNotNone( dispute, 'Cannot test getting disputes for wallet because there\'s no dispute with transaction ID in the disputes list.' ) walletId = self.sdk.payIns.Get( dispute.InitialTransactionId).CreditedWalletId pagination = Pagination(1, 10) disputes = self.sdk.disputes.GetDisputesForWallet(walletId, pagination) self.assertIsNotNone(disputes) self.assertTrue(len(disputes) > 0)
def _getList(self, methodKey, pagination, responseClassName=None, entityId=None, filter=None, sorting=None, secondEntityId=None): """Get list with entities object from API. param string methodKey Key with request data param pagination Pagination object param object responseClassName Name of entity class from response param string entityId Entity identifier param object filter Object to filter data param object sorting Object to sort data param string secondEntityId Second entity identifier return object Response data """ urlMethod = self._buildUrl(methodKey, entityId, secondEntityId) if pagination == None: pagination = Pagination() rest = RestTool(self._root, True) additionalUrlParams = {} if (filter != None): additionalUrlParams['filter'] = filter if (sorting != None): additionalUrlParams['sort'] = sorting.GetSortParameter() response = rest.Request(urlMethod, self._getRequestType(methodKey), None, pagination, additionalUrlParams) if responseClassName != None: return self._castResponseToEntity(response, responseClassName) return response
def test_isTokenLeaking(self): api = self.buildNewMangoPayApi() self.sdk.users.GetAll(Pagination(1, 2)) token1 = self.sdk.OAuthTokenManager.GetToken() token2 = api.OAuthTokenManager.GetToken() self.assertEqual(token1.access_token, token2.access_token)
def test_stadnardUseToken(self): self.sdk.users.GetAll(Pagination(1, 2)) token = self.sdk.OAuthTokenManager.GetToken() self.sdk.users.GetAll(Pagination(1, 2)) self.assertEqual(token.access_token, self.sdk.OAuthTokenManager.GetToken().access_token)
def test_Clients_GetWallets(self): feesWallets = self.sdk.clients.GetWallets(FundsType.FEES, Pagination(1, 1)) creditWallets = self.sdk.clients.GetWallets(FundsType.CREDIT, Pagination(1, 1)) self.assertIsNotNone(feesWallets) self.assertIsNotNone(creditWallets)
""" ## run some test #import tests.testapiusers #t = tests.testapiusers.Test_ApiUsers() #t.test_Users_GetNatural() from mangopaysdk.mangopayapi import MangoPayApi from mangopaysdk.types.pagination import Pagination api = MangoPayApi() # test client credentials api.Config.ClientID = 'sdk-unit-tests' api.Config.ClientPassword = '******' # optionally reuse token from previous requests (unless expired) token = api.authenticationManager.CreateToken() api.OAuthToken = token # GET USERS LIST: GET /users pagination = Pagination(1, 8) users = api.users.GetAll(pagination) # display result on screen print(users) # optionally store token for future requests (unless expires) print(api.OAuthToken) input('...')