mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Refs #29641 -- Extracted reusable CheckConstraint logic into a base class.
This commit is contained in:
parent
9142bebff2
commit
24dc7d8940
2 changed files with 43 additions and 21 deletions
|
@ -1,9 +1,18 @@
|
|||
from django.db import IntegrityError, models
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
|
||||
|
||||
from .models import Product
|
||||
|
||||
|
||||
class BaseConstraintTests(SimpleTestCase):
|
||||
def test_constraint_sql(self):
|
||||
c = BaseConstraint('name')
|
||||
msg = 'This method must be implemented by a subclass.'
|
||||
with self.assertRaisesMessage(NotImplementedError, msg):
|
||||
c.constraint_sql(None, None)
|
||||
|
||||
|
||||
class CheckConstraintTests(TestCase):
|
||||
def test_repr(self):
|
||||
check = models.Q(price__gt=models.F('discounted_price'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue