You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests.py 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from decimal import Decimal as D
  2. from django.test import TestCase
  3. from django.test.client import Client
  4. from django.core.urlresolvers import reverse
  5. from oscar.test.helpers import create_product
  6. class CheckoutViewsTest(TestCase):
  7. fixtures = ['example-shipping-charges.json']
  8. def setUp(self):
  9. self.client = Client()
  10. super(CheckoutViewsTest, self).setUp()
  11. def _test_anonymous_checkout(self):
  12. # Add a product to the basket
  13. p = create_product(price=D('10.00'))
  14. response = self.client.post(reverse('basket:add'), {'action': 'add',
  15. 'product_id': str(p.id),
  16. 'quantity': 1})
  17. self.assertEqual(302, response.status_code)
  18. # Submit shipping address
  19. response = self.client.post(reverse('oscar-checkout-shipping-address'),
  20. {'last_name': 'Smith',
  21. 'line1': '1 Portland Street',
  22. 'postcode': 'N12 9ET',
  23. 'country': 'GB'})
  24. self.assertEqual(302, response.status_code)
  25. # Choose shipping method
  26. response = self.client.post(reverse('oscar-checkout-shipping-method'),
  27. {'method_code': 'royal-mail-first-class'})
  28. self.assertEqual(302, response.status_code)
  29. # Shipping method
  30. response = self.client.get(reverse('oscar-checkout-payment-method'))
  31. self.assertEqual(302, response.status_code)
  32. # View preview
  33. response = self.client.get(reverse('oscar-checkout-preview'))
  34. self.assertEqual(302, response.status_code)
  35. # Submit
  36. response = self.client.post(reverse('oscar-checkout-payment-details'), {})
  37. self.assertEqual(302, response.status_code)