Beispiel #1
0
    def test_multibuy_range_required(self):
        benefit = models.Benefit(range=None,
                                 type=models.Benefit.MULTIBUY,
                                 value=1)

        with self.assertRaises(ValidationError):
            benefit.clean()
Beispiel #2
0
    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()
Beispiel #3
0
    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_shipping_percentage_validation(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_PERCENTAGE,
            value=105,  # Invalid value
        )

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_shipping_percentage_required(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_PERCENTAGE,
            value=None,  # This should be required
        )

        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()
    def test_shipping_max_affected_items_must_not_be_set(self):
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_PERCENTAGE,
            value=50,
            max_affected_items=5,
        )

        with self.assertRaises(ValidationError):
            benefit.clean()
    def test_shipping_range_must_not_be_set(self):
        product_range = models.Range.objects.create(name="Foo",
                                                    includes_all_products=True)
        benefit = models.Benefit(
            type=models.Benefit.SHIPPING_PERCENTAGE,
            value=50,
            range=product_range,  # Range shouldn't be allowed
        )

        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()
 def test_requires_a_range(self):
     benefit = models.Benefit(type=models.Benefit.FIXED, value=10)
     with self.assertRaises(ValidationError):
         benefit.clean()
 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()