Просмотр исходного кода

Added client test for anonymous checkout

master
David Winterbottom 14 лет назад
Родитель
Сommit
dfdbbb3dfb

+ 33
- 0
examples/vanilla/test_settings.py Просмотреть файл

@@ -20,3 +20,36 @@ DATABASES = {
20 20
         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
21 21
     }
22 22
 }
23
+
24
+LOGGING = {
25
+    'version': 1,
26
+    'disable_existing_loggers': True,
27
+    'handlers': {
28
+        'null': {
29
+            'level':'DEBUG',
30
+            'class':'django.utils.log.NullHandler',
31
+        },
32
+    },
33
+    'loggers': {
34
+        'django': {
35
+            'handlers':['null'],
36
+            'propagate': True,
37
+            'level':'INFO',
38
+        },
39
+        'django.request': {
40
+            'handlers': ['null'],
41
+            'level': 'ERROR',
42
+            'propagate': False,
43
+        },
44
+        'oscar.checkout': {
45
+            'handlers': ['null'],
46
+            'propagate': True,
47
+            'level':'INFO',
48
+        },
49
+        'django.db.backends': {
50
+            'handlers':['null'],
51
+            'propagate': False,
52
+            'level':'DEBUG',
53
+        },
54
+    }
55
+}

+ 1
- 0
oscar/apps/basket/views.py Просмотреть файл

@@ -65,6 +65,7 @@ class BasketView(ModelView):
65 65
         factory = FormFactory()
66 66
         form = factory.create(item, self.request.POST)
67 67
         if not form.is_valid():
68
+            print form.errors
68 69
             self.response = HttpResponseRedirect(item.get_absolute_url())
69 70
             messages.error(self.request, "Unable to add your item to the basket - submission not valid")
70 71
         else:

+ 0
- 0
oscar/apps/checkout/models.py Просмотреть файл


+ 42
- 5
oscar/apps/checkout/tests.py Просмотреть файл

@@ -1,16 +1,53 @@
1
+from decimal import Decimal as D
2
+
1 3
 from django.utils import unittest
2 4
 from django.test.client import Client
3 5
 from django.core.urlresolvers import reverse
4 6
 
5
-from oscar.apps.checkout.utils import ProgressChecker
7
+from oscar.test.helpers import create_product
8
+
6 9
         
7 10
 class CheckoutViewsTest(unittest.TestCase):
8 11
     
9 12
     def setUp(self):
10 13
         self.client = Client()
11 14
     
12
-#    def test_redirect_returned_when_trying_to_skip_steps(self):
13
-#        url = reverse('oscar-checkout-preview')
14
-#        response = self.client.get(url)
15
-#        self.assertEquals(302, response.status_code)
15
+    def test_anonymous_checkout(self):
16
+        
17
+        # Add a product to the basket
18
+        p = create_product(price=D('10.00'))
19
+        response = self.client.post(reverse('oscar-basket'), {'action': 'add', 
20
+                                                              'product_id': str(p.id),
21
+                                                              'quantity': 1})
22
+        self.assertEqual(302, response.status_code)
23
+        
24
+        # Submit shipping address
25
+        response = self.client.post(reverse('oscar-checkout-shipping-address'), 
26
+                                    {'last_name': 'Smith',
27
+                                     'line1': '1 Portland Street',
28
+                                     'postcode': 'N12 9ET',
29
+                                     'country': 'GB'})
30
+        self.assertEqual(302, response.status_code)
31
+        
32
+        # Choose shipping method
33
+        response = self.client.post(reverse('oscar-checkout-shipping-method'),
34
+                                    {'method_code': 'royal-mail-first-class'})
35
+        self.assertEqual(302, response.status_code)
36
+        
37
+        # Shipping method
38
+        response = self.client.get(reverse('oscar-checkout-payment-method'))
39
+        self.assertEqual(302, response.status_code)
40
+        
41
+        # View preview
42
+        response = self.client.get(reverse('oscar-checkout-preview'))
43
+        self.assertEqual(200, response.status_code)
44
+        
45
+        # Submit
46
+        response = self.client.post(reverse('oscar-checkout-payment-details'), {})
47
+        self.assertEqual(302, response.status_code)
48
+        
49
+        
50
+        
51
+        
52
+        
16 53
         

Загрузка…
Отмена
Сохранить