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 1023B

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