diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/queries/models.py | 1 | ||||
| -rw-r--r-- | tests/queries/tests.py | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/tests/queries/models.py b/tests/queries/models.py index a4f6245aa8..a5faa2a84b 100644 --- a/tests/queries/models.py +++ b/tests/queries/models.py @@ -42,6 +42,7 @@ class Note(models.Model): note = models.CharField(max_length=100) misc = models.CharField(max_length=10) tag = models.ForeignKey(Tag, models.SET_NULL, blank=True, null=True) + negate = models.BooleanField(default=True) class Meta: ordering = ['note'] diff --git a/tests/queries/tests.py b/tests/queries/tests.py index 2863cfb568..f9a57b088a 100644 --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -47,7 +47,7 @@ class Queries1Tests(TestCase): cls.n1 = Note.objects.create(note='n1', misc='foo', id=1) cls.n2 = Note.objects.create(note='n2', misc='bar', id=2) - cls.n3 = Note.objects.create(note='n3', misc='foo', id=3) + cls.n3 = Note.objects.create(note='n3', misc='foo', id=3, negate=False) ann1 = Annotation.objects.create(name='a1', tag=cls.t1) ann1.notes.add(cls.n1) @@ -1216,6 +1216,13 @@ class Queries1Tests(TestCase): [self.a3, self.a4], ) + def test_negate_field(self): + self.assertSequenceEqual( + Note.objects.filter(negate=True), + [self.n1, self.n2], + ) + self.assertSequenceEqual(Note.objects.exclude(negate=True), [self.n3]) + class Queries2Tests(TestCase): @classmethod |
