2010-11-18 23:29:58 +00:00
|
|
|
from django.core.exceptions import ValidationError
|
2009-05-07 16:12:08 +00:00
|
|
|
from django.test import TestCase
|
|
|
|
|
2010-11-18 23:29:58 +00:00
|
|
|
from models import Worker, NonAutoPK
|
|
|
|
|
|
|
|
|
2009-05-07 16:12:08 +00:00
|
|
|
class RelatedModelOrderedLookupTest(TestCase):
|
|
|
|
"""
|
|
|
|
Regression test for #10153: foreign key __gte and __lte lookups.
|
|
|
|
"""
|
2010-11-18 23:29:58 +00:00
|
|
|
|
2009-05-07 16:12:08 +00:00
|
|
|
# The bug is that the following queries would raise:
|
|
|
|
# "TypeError: Related Field has invalid lookup: gte"
|
2010-11-18 23:29:58 +00:00
|
|
|
|
2009-05-07 16:12:08 +00:00
|
|
|
def test_related_gte_lookup(self):
|
|
|
|
Worker.objects.filter(department__gte=0)
|
|
|
|
|
|
|
|
def test_related_lte_lookup(self):
|
|
|
|
Worker.objects.filter(department__lte=0)
|
2010-11-18 23:29:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ModelValidationTest(TestCase):
|
|
|
|
def test_pk_validation(self):
|
|
|
|
one = NonAutoPK.objects.create(name="one")
|
|
|
|
again = NonAutoPK(name="one")
|
|
|
|
self.assertRaises(ValidationError, again.validate_unique)
|