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