def test_process_postpay_accepted(self): """ Tests the ACCEPTED path of process_postpay """ student1 = UserFactory() student1.save() order1 = Order.get_cart_for_user(student1) params = { 'card_accountNumber': '1234', 'card_cardType': '001', 'billTo_firstName': student1.first_name, 'orderNumber': str(order1.id), 'orderCurrency': 'usd', 'decision': 'ACCEPT', 'ccAuthReply_amount': '0.00' } result = process_postpay_callback(params) self.assertTrue(result['success']) self.assertEqual(result['order'], order1) order1 = Order.objects.get( id=order1.id ) # reload from DB to capture side-effect of process_postpay_callback self.assertEqual(order1.status, 'purchased') self.assertFalse(result['error_html'])
def test_process_postpay_exception(self): """ Tests the exception path of process_postpay_callback """ baseline = { 'orderNumber': '1', 'orderCurrency': 'usd', 'decision': 'ACCEPT', } # tests for missing key for key in baseline: params = baseline.copy() del params[key] result = process_postpay_callback(params) self.assertFalse(result['success']) self.assertIsNone(result['order']) self.assertIn('error_msg', result['error_html'])
def test_process_postpay_not_accepted(self): """ Tests the non-ACCEPTED path of process_postpay """ student1 = UserFactory() student1.save() order1 = Order.get_cart_for_user(student1) params = { 'card_accountNumber': '1234', 'card_cardType': '001', 'billTo_firstName': student1.first_name, 'orderNumber': str(order1.id), 'orderCurrency': 'usd', 'decision': 'REJECT', 'ccAuthReply_amount': '0.00', 'reasonCode': '207' } result = process_postpay_callback(params) self.assertFalse(result['success']) self.assertEqual(result['order'], order1) self.assertEqual(order1.status, 'cart') self.assertIn(REASONCODE_MAP['207'], result['error_html'])
def test_process_postpay_accepted(self): """ Tests the ACCEPTED path of process_postpay """ student1 = UserFactory() student1.save() order1 = Order.get_cart_for_user(student1) params = { 'card_accountNumber': '1234', 'card_cardType': '001', 'billTo_firstName': student1.first_name, 'orderNumber': str(order1.id), 'orderCurrency': 'usd', 'decision': 'ACCEPT', 'ccAuthReply_amount': '0.00' } result = process_postpay_callback(params) self.assertTrue(result['success']) self.assertEqual(result['order'], order1) order1 = Order.objects.get(id=order1.id) # reload from DB to capture side-effect of process_postpay_callback self.assertEqual(order1.status, 'purchased') self.assertFalse(result['error_html'])