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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from decimal import Decimal as D
  2. import httplib
  3. from django.test import TestCase
  4. from django.test.client import Client
  5. from django.core.urlresolvers import reverse, clear_url_caches
  6. from django.conf import settings
  7. from oscar.test.helpers import create_product
  8. class AnonCheckoutTests(TestCase):
  9. def setUp(self):
  10. clear_url_caches()
  11. self.client = Client()
  12. settings.OSCAR_ALLOW_ANON_CHECKOUT = True
  13. def tearDown(self):
  14. settings.OSCAR_ALLOW_ANON_CHECKOUT = False
  15. def _test_shipping_address_does_require_login(self):
  16. # Disabled until I can work out how to reload the URL config between tests
  17. url = reverse('checkout:shipping-address')
  18. response = self.client.get(url)
  19. self.assertEquals(httplib.OK, response.status_code)
  20. class CheckoutViewsTest(TestCase):
  21. fixtures = ['example-shipping-charges.json']
  22. def setUp(self):
  23. clear_url_caches()
  24. self.client = Client()
  25. super(CheckoutViewsTest, self).setUp()
  26. def test_user_address_views_require_a_login(self):
  27. urls = [reverse('checkout:user-address-create'),
  28. reverse('checkout:user-address-update', kwargs={'pk': 1}),
  29. reverse('checkout:user-address-delete', kwargs={'pk': 1}),]
  30. for url in urls:
  31. response = self.client.get(url)
  32. self.assertEqual(httplib.FOUND, response.status_code)
  33. def test_anon_checkout_disabled_by_default(self):
  34. self.assertFalse(settings.OSCAR_ALLOW_ANON_CHECKOUT)
  35. def test_index_does_not_require_login(self):
  36. url = reverse('checkout:index')
  37. response = self.client.get(url)
  38. self.assertEquals(httplib.OK, response.status_code)
  39. def test_core_checkout_requires_login(self):
  40. urls = [reverse('checkout:shipping-address'),
  41. reverse('checkout:payment-method'),
  42. reverse('checkout:shipping-method'),
  43. reverse('checkout:payment-details')]
  44. for url in urls:
  45. response = self.client.get(url)
  46. self.assertEquals(httplib.FOUND, response.status_code)