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.

test_models.py 975B

123456789101112131415161718192021222324252627282930
  1. from decimal import Decimal as D
  2. from django.core.exceptions import ValidationError
  3. from django.test import TestCase
  4. from oscar.apps.shipping import models
  5. class TestWeightBasedMethod(TestCase):
  6. def test_doesnt_allow_negative_default_weights(self):
  7. method = models.WeightBased(
  8. name="Dummy", default_weight=D('-0.1'))
  9. with self.assertRaises(ValidationError):
  10. method.full_clean()
  11. class TestWeightBand(TestCase):
  12. def test_doesnt_allow_negative_upper_limit(self):
  13. band = models.WeightBand(upper_limit=D('-0.1'))
  14. with self.assertRaises(ValidationError) as cm:
  15. band.full_clean()
  16. self.assertTrue('upper_limit' in cm.exception.message_dict)
  17. def test_doesnt_allow_negative_charge(self):
  18. band = models.WeightBand(charge=D('-0.1'))
  19. with self.assertRaises(ValidationError) as cm:
  20. band.full_clean()
  21. self.assertTrue('charge' in cm.exception.message_dict)