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.

custom_range_tests.py 760B

12345678910111213141516171819202122232425262728
  1. from django.test import TestCase
  2. from oscar_testsupport.factories import create_product
  3. from oscar.apps.offer import custom
  4. class CustomRange(object):
  5. name = "Custom range"
  6. def contains_product(self, product):
  7. return product.title.startswith("A")
  8. def num_products(self):
  9. return None
  10. class TestACustomRange(TestCase):
  11. def setUp(self):
  12. self.rng = custom.create_range(CustomRange)
  13. def test_correctly_includes_match(self):
  14. test_product = create_product(title="A tale")
  15. self.assertTrue(self.rng.contains_product(test_product))
  16. def test_correctly_excludes_nonmatch(self):
  17. test_product = create_product(title="B tale")
  18. self.assertFalse(self.rng.contains_product(test_product))