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.

status_tests.py 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. from decimal import Decimal as D
  2. from django.test import TestCase
  3. from django_dynamic_fixture import G
  4. from oscar.apps.offer import models
  5. class TestAnOfferChangesStatusWhen(TestCase):
  6. def setUp(self):
  7. condition, benefit = G(models.Condition), G(models.Benefit)
  8. self.offer = models.ConditionalOffer(
  9. offer_type=models.ConditionalOffer.SITE,
  10. condition=condition, benefit=benefit)
  11. def test_the_max_discount_is_exceeded(self):
  12. self.offer.max_discount = D('10.00')
  13. self.assertTrue(self.offer.is_open)
  14. # Now bump the total discount and save to see if the status is
  15. # automatically updated.
  16. self.offer.total_discount += D('20.00')
  17. self.offer.save()
  18. self.assertFalse(self.offer.is_open)
  19. def test_the_max_global_applications_is_exceeded(self):
  20. self.offer.max_global_applications = 5
  21. self.assertTrue(self.offer.is_open)
  22. self.offer.num_applications += 10
  23. self.offer.save()
  24. self.assertFalse(self.offer.is_open)