Ejemplo n.º 1
0
def credit_fixture():
    credit = litleXmlFields.credit()
    credit.amount = 110
    credit.orderId = "12344"
    credit.orderSource = 'ecommerce'

    return credit
    def testCreditWithSecondaryAmountFirst(self):
        credit = litleXmlFields.credit()
        credit.orderId = "12344"
        credit.orderSource = 'ecommerce'
        credit.secondaryAmount = 100

        card = litleXmlFields.cardType()
        card.type = 'VI'
        card.number = "4100000000000001"
        card.expDate = "1210"
        credit.card = card

        comm = Communications(config)
        comm.http_post = MagicMock()

        litle = litleOnlineRequest(config)
        litle.setCommunications(comm)
        litle._processResponse = MagicMock(return_value=None)
        litle.sendRequest(credit)

        comm.http_post.assert_called_once()
        match_re = RegexMatcher(
            ".*?<litleOnlineRequest.*?<credit.*?<secondaryAmount>100</secondaryAmount>.*?<card>.*?<number>4100000000000001</number>.*?</card>.*?</credit>.*?"
        )
        comm.http_post.assert_called_with(match_re,
                                          url=ANY,
                                          proxy=ANY,
                                          timeout=ANY)
    def testAddCredit(self):
        batchRequest = self.litleBatchFileRequest.createBatch()
        credit = litleXmlFields.credit()
        credit.amount = 25
        self.litleBatchFileRequest.tnxToXml = MagicMock(return_value='')

        batchRequest.addTransaction(credit)
        assert(batchRequest._batchRequest.creditAmount == 25)
        assert(batchRequest._batchRequest.numCredits == 1)
        assert(batchRequest.numOfTxn == 1)
    def testCreditWithSecondaryAmountSecond(self):
        credit = litleXmlFields.credit()
        credit.litleTxnId=1000
        credit.secondaryAmount=100
        
        comm = Communications(config)
        comm.http_post = MagicMock()

        litle = litleOnlineRequest(config)
        litle.setCommunications(comm)
        litle._processResponse = MagicMock(return_value=None)
        litle.sendRequest(credit)
        
        match_re = RegexMatcher(".*?<litleOnlineRequest.*?<credit.*?<secondaryAmount>100</secondaryAmount>*?</credit>.*?")
        comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
    def testCreditWithSecondaryAmountSecond(self):
        credit = litleXmlFields.credit()
        credit.litleTxnId=1000
        credit.secondaryAmount=100
	credit.id="id"
        
        comm = Communications(config)
        comm.http_post = MagicMock()

        litle = litleOnlineRequest(config)
        litle.setCommunications(comm)
        litle._processResponse = MagicMock(return_value=None)
        litle.sendRequest(credit)
        
        comm.http_post.assert_called_once()
        match_re = RegexMatcher(".*?<litleOnlineRequest.*?<credit.*?<secondaryAmount>100</secondaryAmount>*?</credit>.*?")
        comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
    def testCredit(self):
        credit = litleXmlFields.credit()
        credit.orderId = "12344"
        credit.orderSource = 'ecommerce'
        
        card = litleXmlFields.cardType()
        card.type = 'VI'
        card.number = "4100000000000001"
        card.expDate = "1210"
        credit.card = card
        
        comm = Communications(config)
        comm.http_post = MagicMock()

        litle = litleOnlineRequest(config)
        litle.setCommunications(comm)
        litle._processResponse = MagicMock(return_value=None)
        litle.sendRequest(credit)
        
        match_re = RegexMatcher(".*?<litleOnlineRequest.*?<credit.*?<card>.*?<number>4100000000000001</number>.*?</card>.*?</credit>.*?")
        comm.http_post.assert_called_with(match_re, url=ANY, proxy=ANY, timeout=ANY)
Ejemplo n.º 7
0
def credit_txn_fixture():
    credit = litleXmlFields.credit()
    credit.amount = 110
    credit.litleTxnId = "12345"

    return credit