Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

custom_range_tests.py 755B

12345678910111213141516171819202122232425262728
  1. from django.test import TestCase
  2. from oscar.test.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=u"A tale")
  15. self.assertTrue(self.rng.contains_product(test_product))
  16. def test_correctly_excludes_nonmatch(self):
  17. test_product = create_product(title=u"B tale")
  18. self.assertFalse(self.rng.contains_product(test_product))