Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

got a bunch of test cards instead of throttling requests

  • Loading branch information...
commit 5f3b0a857f8556a77b39224d36dc532ff2f35ca9 1 parent fdea7de
Celso Pinto authored February 13, 2012

Showing 1 changed file with 38 additions and 6 deletions. Show diff stats Hide diff stats

  1. 44  billing/tests/paylane_tests.py
44  billing/tests/paylane_tests.py
... ...
@@ -1,8 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vim:tabstop=4:expandtab:sw=4:softtabstop=4
3 3
 
4  
-import time
5  
-
6 4
 from django.test import TestCase
7 5
 from billing.gateway import CardNotSupported
8 6
 from billing.utils.credit_card import Visa,CreditCard
@@ -15,6 +13,18 @@
15 13
 #This is needed because Paylane doesn't like too many requests in a very short time
16 14
 THROTTLE_CONTROL_SECONDS = 60
17 15
 
  16
+# VISA test card numbers
  17
+# 4929966723331981
  18
+# 4916437826836305
  19
+# 4532830407731057
  20
+# 4539824967650347
  21
+# 4278255665174428
  22
+# 4556096020428973
  23
+# 4929242798450290
  24
+# 4024007124529719
  25
+# 4024007172509597
  26
+# 4556969412054203
  27
+
18 28
 class PaylaneTestCase(TestCase):
19 29
     def setUp(self):
20 30
         self.merchant = get_gateway("paylane")
@@ -41,6 +51,18 @@ def testOneShotPurchaseOK(self):
41 51
         self.assertTrue('transaction' in res['response'])
42 52
         self.assertFalse('authorization' in res['response'])
43 53
         
  54
+    def testOneShotPurchaseError(self):
  55
+        credit_card = Visa(first_name='Celso',last_name='Pinto',month=10,year=2012,number='4929966723331981',verification_value=435)
  56
+        options = {}
  57
+        options['customer'] = self.customer
  58
+        options['product'] = self.product
  59
+        res = self.merchant.purchase(float(PaylaneError.ERR_CARD_EXPIRED),credit_card,options=options)
  60
+        self.assertEqual(res['status'],'FAILURE',unicode(res['response']))
  61
+        self.assertTrue('transaction' in res['response'])
  62
+        self.assertFalse('authorization' in res['response'])
  63
+        self.assertTrue('error' in res['response'])
  64
+        self.assertEqual(res['response']['error'].error_code,PaylaneError.ERR_CARD_EXPIRED)
  65
+
44 66
     def testRecurringSetupOK(self):
45 67
         credit_card = Visa(first_name='Celso',last_name='Pinto',month=10,year=2012,number='4242424242424242',verification_value=435)
46 68
         options = {}
@@ -51,6 +73,20 @@ def testRecurringSetupOK(self):
51 73
         self.assertTrue('transaction' in res['response'])
52 74
         self.assertTrue('authorization' in res['response'])
53 75
         self.assertTrue(res['response']['authorization'].sale_authorization_id > 0)
  76
+
  77
+
  78
+    def testRecurringSetupError(self):
  79
+        credit_card = Visa(first_name='Celso',last_name='Pinto',month=10,year=2012,number='4916437826836305',verification_value=435)
  80
+        options = {}
  81
+        options['customer'] = self.customer
  82
+        options['product'] = self.product
  83
+        res = self.merchant.recurring(float(PaylaneError.ERR_CARD_EXPIRED),credit_card,options=options)
  84
+        self.assertEqual(res['status'],'FAILURE',unicode(res['response']))
  85
+        self.assertTrue('transaction' in res['response'])
  86
+        self.assertFalse('authorization' in res['response'])
  87
+        self.assertTrue('error' in res['response'])
  88
+        self.assertEqual(res['response']['error'].error_code,PaylaneError.ERR_CARD_EXPIRED)
  89
+
54 90
         
55 91
     def testRecurringBillingOK(self):
56 92
         credit_card = Visa(first_name='Celso',last_name='Pinto',month=10,year=2012,number='4000111111111115',verification_value="100")
@@ -63,13 +99,11 @@ def testRecurringBillingOK(self):
63 99
         self.assertTrue('authorization' in res['response'])
64 100
         self.assertTrue(res['response']['authorization'].sale_authorization_id > 0)
65 101
                 
66  
-        time.sleep(THROTTLE_CONTROL_SECONDS)
67 102
         bill1 = self.merchant.bill_recurring(12.0,res['response']['authorization'],'OK recurring')
68 103
         self.assertEqual(bill1['status'],'SUCCESS',unicode(bill1['response']))
69 104
         self.assertTrue('transaction' in bill1['response'])
70 105
         self.assertTrue('authorization' in bill1['response'])
71 106
 
72  
-        time.sleep(THROTTLE_CONTROL_SECONDS)
73 107
         bill2 = self.merchant.bill_recurring(12.0,bill1['response']['authorization'],'OK recurring')
74 108
         self.assertEqual(bill2['status'],'SUCCESS',unicode(bill2['response']))
75 109
         self.assertTrue('transaction' in bill2['response'])
@@ -86,13 +120,11 @@ def testRecurringBillingFailWithChargeback(self):
86 120
         self.assertTrue('authorization' in res['response'])
87 121
         self.assertTrue(res['response']['authorization'].sale_authorization_id > 0)
88 122
 
89  
-        time.sleep(THROTTLE_CONTROL_SECONDS)
90 123
         bill1 = self.merchant.bill_recurring(12.0,res['response']['authorization'],'OK recurring')
91 124
         self.assertEqual(bill1['status'],'SUCCESS',unicode(bill1['response']))
92 125
         self.assertTrue('transaction' in bill1['response'])
93 126
         self.assertTrue('authorization' in bill1['response'])
94 127
 
95  
-        time.sleep(THROTTLE_CONTROL_SECONDS)
96 128
         bill2 = self.merchant.bill_recurring(float(PaylaneError.ERR_RESALE_WITH_CHARGEBACK),bill1['response']['authorization'],'Fail recurring')
97 129
         self.assertEqual(bill2['status'],'FAILURE',unicode(bill2['response']))
98 130
         self.assertTrue('transaction' in bill2['response'])

0 notes on commit 5f3b0a8

Please sign in to comment.
Something went wrong with that request. Please try again.