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.

wishlists_tests.py 957B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from oscar.core.loading import get_model
  3. from oscar.test.factories import create_product
  4. from oscar.test.testcases import WebTestCase
  5. WishList = get_model('wishlists', 'WishList')
  6. class TestProductDetailPage(WebTestCase):
  7. is_anonymous = False
  8. def setUp(self):
  9. super(TestProductDetailPage, self).setUp()
  10. self.product = create_product()
  11. def test_allows_a_product_to_be_added_to_wishlist(self):
  12. # Click add to wishlist button
  13. detail_page = self.get(self.product.get_absolute_url())
  14. form = detail_page.forms['add_to_wishlist_form']
  15. response = form.submit()
  16. self.assertIsRedirect(response)
  17. # Check a wishlist has been created
  18. wishlists = self.user.wishlists.all()
  19. self.assertEqual(1, len(wishlists))
  20. lines = wishlists[0].lines.all()
  21. self.assertEqual(1, len(lines))
  22. self.assertEqual(self.product, lines[0].product)