def testSale(self): sale = litleXmlFields.sale() sale.amount = 106 sale.litleTxnId = 123456 sale.orderId = "12344" sale.orderSource = 'ecommerce' sale.id="id" card = litleXmlFields.cardType() card.type = 'VI' card.number = "4100000000000002" card.expDate = "1210" sale.card = card comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(sale) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<sale.*?<card>.*?<number>4100000000000002</number>.*?</card>.*?</sale>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testSale(self): sale = litleXmlFields.sale() sale.amount = 106 sale.litleTxnId = 123456 sale.orderId = "12344" sale.orderSource = 'ecommerce' card = litleXmlFields.cardType() card.type = 'VI' card.number = "4100000000000002" card.expDate = "1210" sale.card = card comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(sale) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<sale.*?<card>.*?<number>4100000000000002</number>.*?</card>.*?</sale>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def sale_fixture(): sale = litleXmlFields.sale() sale.litleTxnId = 123456 sale.amount = 106 sale.orderId = '12344' sale.orderSource = 'ecommerce' return sale
def testAddSale(self): batchRequest = self.litleBatchFileRequest.createBatch() sale = litleXmlFields.sale() sale.amount = 25 self.litleBatchFileRequest.tnxToXml = MagicMock(return_value='') batchRequest.addTransaction(sale) assert(batchRequest._batchRequest.saleAmount == 25) assert(batchRequest._batchRequest.numSales == 1) assert(batchRequest.numOfTxn == 1)
def createTestSale(amount, orderId): sale = litleXmlFields.sale() sale.amount = amount sale.orderId = orderId sale.orderSource = 'ecommerce' card = litleXmlFields.cardType() card.type = 'VI' card.number = "4100000000000001" card.expDate = "1210" sale.card = card sale.reportGroup = 'test' return sale
def prepareTestRequest(self, request): batchRequest = request.createBatch() sale = litleXmlFields.sale() sale.reportGroup = 'Test Report Group' sale.orderId = 'orderId11' sale.amount = 1099 sale.orderSource = 'ecommerce' card = litleXmlFields.cardType() card.type = 'VI' card.number = "4457010000000009" card.expDate = "0114" sale.card = card batchRequest.addTransaction(sale)
def testAddAUBlock_Sale_side(self): batchRequest = self.litleBatchFileRequest.createBatch() sale = litleXmlFields.sale() sale.amount = 5 self.litleBatchFileRequest.tnxToXml = MagicMock(return_value='') batchRequest.addTransaction(sale) assert(batchRequest._batchRequest.numSales == 1) assert(batchRequest._batchRequest.saleAmount == 5) assert(batchRequest.numOfTxn == 1) accountUpdate = litleXmlFields.accountUpdate() exception = None try: batchRequest.addTransaction(accountUpdate) except Exception as e: exception = e assert(exception is not None)
def testSaleWithSecondaryAmountAndApplepayAndWallet(self): sale = litleXmlFields.sale() sale.amount = 106 sale.litleTxnId = 123456 sale.orderId = "12344" sale.orderSource = 'ecommerce' sale.secondaryAmount = 100 wallet = litleXmlFields.wallet() wallet.walletSourceType = 'MasterPass' wallet.walletSourceTypeId = '12345' applepay = litleXmlFields.applepayType() applepay.data = "4100000000000000" applepay.signature = "yoyo" applepay.version = '9.3' header = litleXmlFields.applepayHeaderType() header.applicationData = 'applicationData' header.ephemeralPublicKey = 'UWIRNRSKSXMXEYEINR' header.publicKeyHash = 'UYTGHJKMNBVFYWUWI' header.transactionId = '1024' applepay.header = header sale.applepay = applepay sale.wallet = wallet comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(sale) comm.http_post.assert_called_once() match_re = RegexMatcher( ".*?<litleOnlineRequest.*?<sale.*?<applepay>.*?<data>4100000000000000</data>.*?</applepay>.*?<wallet.*?</wallet>.*?</sale>.*?" ) comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
def testSaleWithSecondaryAmountAndApplepayAndWallet(self): sale = litleXmlFields.sale() sale.amount = 106 sale.litleTxnId = 123456 sale.orderId = "12344" sale.orderSource = 'ecommerce' sale.secondaryAmount=100 sale.id="id" wallet=litleXmlFields.wallet() wallet.walletSourceType='MasterPass' wallet.walletSourceTypeId='12345' applepay = litleXmlFields.applepayType() applepay.data = "4100000000000000" applepay.signature = "yoyo" applepay.version = '9.3' header=litleXmlFields.applepayHeaderType() header.applicationData='applicationData' header.ephemeralPublicKey ='UWIRNRSKSXMXEYEINR' header.publicKeyHash='UYTGHJKMNBVFYWUWI' header.transactionId='1024' applepay.header=header sale.applepay = applepay sale.wallet=wallet comm = Communications(config) comm.http_post = MagicMock() litle = litleOnlineRequest(config) litle.setCommunications(comm) litle._processResponse = MagicMock(return_value=None) litle.sendRequest(sale) comm.http_post.assert_called_once() match_re = RegexMatcher(".*?<litleOnlineRequest.*?<sale.*?<applepay>.*?<data>4100000000000000</data>.*?</applepay>.*?<wallet.*?</wallet>.*?</sale>.*?") comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)