|
|
@@ -1,10 +1,12 @@
|
|
1
|
1
|
from decimal import Decimal as D
|
|
|
2
|
+import datetime
|
|
2
|
3
|
|
|
3
|
4
|
from django.test import TestCase
|
|
4
|
5
|
from django_dynamic_fixture import G
|
|
5
|
6
|
|
|
6
|
7
|
from oscar.test import factories
|
|
7
|
8
|
from oscar.apps.payment import models
|
|
|
9
|
+from oscar.apps.payment.models import Bankcard
|
|
8
|
10
|
|
|
9
|
11
|
|
|
10
|
12
|
class TestAPaymentSource(TestCase):
|
|
|
@@ -31,3 +33,19 @@ class TestAPaymentSource(TestCase):
|
|
31
|
33
|
self.source.allocate(D('100.00'))
|
|
32
|
34
|
self.source.debit(D('80.00'))
|
|
33
|
35
|
self.source.refund(D('50.00'))
|
|
|
36
|
+
|
|
|
37
|
+
|
|
|
38
|
+class TestBankcard(TestCase):
|
|
|
39
|
+
|
|
|
40
|
+ def test_cardtype_persists_after_save(self):
|
|
|
41
|
+ user = factories.UserFactory()
|
|
|
42
|
+ end = datetime.date(day=1, month=1, year=2010)
|
|
|
43
|
+ bankcard = Bankcard(
|
|
|
44
|
+ user=user, number="5500000000000004", expiry_date=end)
|
|
|
45
|
+ self.assertEqual('Mastercard', bankcard.card_type)
|
|
|
46
|
+
|
|
|
47
|
+ bankcard.save()
|
|
|
48
|
+ self.assertEqual('Mastercard', bankcard.card_type)
|
|
|
49
|
+
|
|
|
50
|
+ reloaded_bankcard = Bankcard.objects.get(id=bankcard.id)
|
|
|
51
|
+ self.assertEqual('Mastercard', reloaded_bankcard.card_type)
|