|
|
@@ -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
|
|