def test_pay_ok(self): transaction_id = 2345 txn_id=123 error = (0,u'ОК',False) def callback(): return {'transaction_id':transaction_id, 'error_code':error[0]} pegas = PegasPaymentGateway({'txn_id':txn_id}, {'pay':callback}) response = \ u"""<?xml version="1.0" encoding="UTF-8"?> <response> <txn_id>%(txn_id)s</txn_id> <prv_txn>%(transaction_id)s</prv_txn> <result>%(result)d</result> </response>""" % {'txn_id':txn_id, 'transaction_id':transaction_id, 'result':error[0]} self.assertEquals(pegas.pay(), (response, error) )
def test_pay_timeout(self): transaction_id = 2345 txn_id=123 error = (1,u'Временная ошибка. Повторите запрос позже',False) def callback(): return {'transaction_id':transaction_id, 'error_code':error[0]} pegas = PegasPaymentGateway({'txn_id':txn_id}, {'pay':callback}) response = \ u"""<?xml version="1.0" encoding="UTF-8"?> <response> <txn_id>%(txn_id)s</txn_id> <prv_txn>%(transaction_id)s</prv_txn> <result>%(result)d</result> <comment>%(comment)s</comment> </response>""" % {'txn_id':txn_id, 'transaction_id':transaction_id, 'result':error[0], 'comment':error[1]} self.assertEquals(pegas.pay(), (response, error) )