def test_init(self, parse, logger, ConfirmationPayload): data = {'TBK_PARAM': mock.Mock()} confirmation = Confirmation(self.commerce, self.request_ip, data) self.assertEqual(self.commerce, confirmation.commerce) self.assertEqual(self.request_ip, confirmation.request_ip) self.assertEqual(CONFIRMATION_TIMEOUT, confirmation.timeout) parse.assert_called_once_with(data['TBK_PARAM']) ConfirmationPayload.assert_called_once_with(parse.return_value) self.assertEqual(ConfirmationPayload.return_value, confirmation.payload)
def test_init(self, parse, logger, ConfirmationPayload): data = { 'TBK_PARAM': mock.Mock() } confirmation = Confirmation(self.commerce, self.request_ip, data) self.assertEqual(self.commerce, confirmation.commerce) self.assertEqual(self.request_ip, confirmation.request_ip) self.assertEqual(CONFIRMATION_TIMEOUT, confirmation.timeout) parse.assert_called_once_with(data['TBK_PARAM']) ConfirmationPayload.assert_called_once_with(parse.return_value) self.assertEqual( ConfirmationPayload.return_value, confirmation.payload)
def test_parse(self, logger, ConfirmationPayload): with open( os.path.join(os.path.dirname(__file__), 'fixtures', 'confirmation.txt')) as f: confirmation_data = f.read() data = {'TBK_PARAM': mock.Mock()} self.commerce.webpay_decrypt.return_value = (confirmation_data, "signature") confirmation = Confirmation(self.commerce, self.request_ip, data) params = CONFIRMATION_DATA.copy() params['TBK_MAC'] = "signature" self.commerce.webpay_decrypt.assert_called_once_with(data['TBK_PARAM']) ConfirmationPayload.assert_called_once_with(params) self.assertEqual(ConfirmationPayload.return_value, confirmation.payload)
def test_parse(self, logger, ConfirmationPayload): with open(os.path.join(os.path.dirname(__file__), 'fixtures', 'confirmation.txt')) as f: confirmation_data = f.read() data = { 'TBK_PARAM': mock.Mock() } self.commerce.webpay_decrypt.return_value = ( confirmation_data, "signature") confirmation = Confirmation(self.commerce, self.request_ip, data) params = CONFIRMATION_DATA.copy() params['TBK_MAC'] = "signature" self.commerce.webpay_decrypt.assert_called_once_with(data['TBK_PARAM']) ConfirmationPayload.assert_called_once_with(params) self.assertEqual( ConfirmationPayload.return_value, confirmation.payload)