summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-09-01 21:04:01 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-09-01 21:04:01 +0000
commitd5cc16b47154e3788db5d38a39de70aef557eebb (patch)
tree9d1e2f71f3971ed44c9a66b12fb47571522fb2a8 /tests
parentb4d3f4e00420aee5167036d43752445b0959477d (diff)
Fixed #8076: fixed `get_(next/previous)_by_date` when used with subclasses. Thanks, bjornkri and jan_oberst.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8814 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/model_inheritance_regress/models.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/regressiontests/model_inheritance_regress/models.py b/tests/regressiontests/model_inheritance_regress/models.py
index 716c7f5ad8..45c516a855 100644
--- a/tests/regressiontests/model_inheritance_regress/models.py
+++ b/tests/regressiontests/model_inheritance_regress/models.py
@@ -59,6 +59,18 @@ class SelfRefParent(models.Model):
class SelfRefChild(SelfRefParent):
child_data = models.IntegerField()
+class Article(models.Model):
+ headline = models.CharField(max_length=100)
+ pub_date = models.DateTimeField()
+ class Meta:
+ ordering = ('-pub_date', 'headline')
+
+ def __unicode__(self):
+ return self.headline
+
+class ArticleWithAuthor(Article):
+ author = models.CharField(max_length=100)
+
__test__ = {'API_TESTS':"""
# Regression for #7350, #7202
# Check that when you create a Parent object with a specific reference to an
@@ -194,4 +206,29 @@ True
>>> obj = SelfRefChild.objects.create(child_data=37, parent_data=42)
>>> obj.delete()
+# Regression tests for #8076 - get_(next/previous)_by_date should
+>>> c1 = ArticleWithAuthor(headline='ArticleWithAuthor 1', author="Person 1", pub_date=datetime.datetime(2005, 8, 1, 3, 0))
+>>> c1.save()
+>>> c2 = ArticleWithAuthor(headline='ArticleWithAuthor 2', author="Person 2", pub_date=datetime.datetime(2005, 8, 1, 10, 0))
+>>> c2.save()
+>>> c3 = ArticleWithAuthor(headline='ArticleWithAuthor 3', author="Person 3", pub_date=datetime.datetime(2005, 8, 2))
+>>> c3.save()
+
+>>> c1.get_next_by_pub_date()
+<ArticleWithAuthor: ArticleWithAuthor 2>
+>>> c2.get_next_by_pub_date()
+<ArticleWithAuthor: ArticleWithAuthor 3>
+>>> c3.get_next_by_pub_date()
+Traceback (most recent call last):
+ ...
+DoesNotExist: ArticleWithAuthor matching query does not exist.
+>>> c3.get_previous_by_pub_date()
+<ArticleWithAuthor: ArticleWithAuthor 2>
+>>> c2.get_previous_by_pub_date()
+<ArticleWithAuthor: ArticleWithAuthor 1>
+>>> c1.get_previous_by_pub_date()
+Traceback (most recent call last):
+ ...
+DoesNotExist: ArticleWithAuthor matching query does not exist.
+
"""}