summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/invalid_models_tests/test_models.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index 87a099f3a9..3bc6856480 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -566,6 +566,50 @@ class OtherModelTests(IsolatedModelsTestCase):
]
self.assertEqual(errors, expected)
+ def test_just_ordering_no_errors(self):
+ class Model(models.Model):
+ order = models.PositiveIntegerField()
+
+ class Meta:
+ ordering = ['order']
+
+ self.assertEquals(Model.check(), [])
+
+ def test_just_order_with_respect_to_no_errors(self):
+ class Question(models.Model):
+ pass
+
+ class Answer(models.Model):
+ question = models.ForeignKey(Question)
+
+ class Meta:
+ order_with_respect_to = 'question'
+
+ self.assertEquals(Answer.check(), [])
+
+ def test_ordering_with_order_with_respect_to(self):
+ class Question(models.Model):
+ pass
+
+ class Answer(models.Model):
+ question = models.ForeignKey(Question)
+ order = models.IntegerField()
+
+ class Meta:
+ order_with_respect_to = 'question'
+ ordering = ['order']
+
+ errors = Answer.check()
+ expected = [
+ Error(
+ "'ordering' and 'order_with_respect_to' cannot be used together.",
+ hint=None,
+ obj=Answer,
+ id='models.E021',
+ ),
+ ]
+ self.assertEqual(errors, expected)
+
def test_non_valid(self):
class RelationModel(models.Model):
pass