def test_multibuy_must_not_have_value(self):
        benefit = models.Benefit(range=self.range,
                                 type=models.Benefit.MULTIBUY,
                                 value=1)

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_multibuy_range_required(self):
        benefit = models.Benefit(range=None,
                                 type=models.Benefit.MULTIBUY,
                                 value=1)

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_multibuy_must_not_have_max_affected_items(self):
        benefit = models.Benefit(range=self.range,
                                 type=models.Benefit.MULTIBUY,
                                 max_affected_items=2)

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_fixed_max_affected_items_must_not_be_set(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_FIXED_PRICE,
            value=10,
            max_affected_items=5,
        )

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_fixed_range_must_not_be_set(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_FIXED_PRICE,
            value=10,
            range=self.range,
        )

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_absolute_max_affected_items_must_not_be_set(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_ABSOLUTE,
            value=10,
            max_affected_items=5,
        )

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_absolute_range_must_not_be_set(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_ABSOLUTE,
            value=10,
            range=self.range,
        )

        with self.assertRaises(ValidationError):
            benefit.clean()
Esempio n. 8
0
 def test_requires_a_range(self):
     benefit = models.Benefit(type=models.Benefit.FIXED, value=10)
     with self.assertRaises(ValidationError):
         benefit.clean()
Esempio n. 9
0
 def test_requires_a_benefit_value(self):
     rng = models.Range.objects.create(name="", includes_all_products=True)
     benefit = models.Benefit(type=models.Benefit.FIXED, range=rng)
     with self.assertRaises(ValidationError):
         benefit.clean()
    def test_absolute_requires_value(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_ABSOLUTE)

        with self.assertRaises(ValidationError):
            benefit.clean()