I have this function iam trying to test whether if discount amount is greater than the invoice amount then a validation error should be raised. Iam stuck in actually triggering the exception for it to be raised in the test. See below
class Invoice(models.Model):
@property
def inv_amount(self):
amount = Sum(quantity * price)
return amount
@property
def discount_amount(self):
amount = Sum(discount)
return amount
def validate_amount(self):
if self.discount_amount > self.inv_amount:
raise ValidationError("discount amount cannot be greater")
def_test_validate_amount_greater_than_discount():
with pytest.raises(ValidationError) as e:
#Trigger the exception