Skip to content

Commit

Permalink
Add test case for doableware#194 (doableware#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
finderseyes authored and nesdis committed Nov 18, 2018
1 parent 63a8560 commit 4bf5655
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/django_tests/tests/queries/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ def __str__(self):
return self.name


class ArticleDerived(Article):
pass


class Food(models.Model):
name = models.CharField(max_length=20, unique=True)

Expand Down
16 changes: 15 additions & 1 deletion tests/django_tests/tests/queries/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.test.utils import CaptureQueriesContext

from .models import (
FK1, Annotation, Article, Author, BaseA, Book, CategoryItem,
FK1, Annotation, Article, ArticleDerived, Author, BaseA, Book, CategoryItem,
CategoryRelationship, Celebrity, Channel, Chapter, Child, ChildObjectA,
Classroom, CommonMixedCaseForeignKeys, Company, Cover, CustomPk,
CustomPkTag, Detail, DumbCategory, Eaten, Employment, ExtraInfo, Fan, Food,
Expand Down Expand Up @@ -2326,9 +2326,23 @@ def setUpTestData(cls):
Article.objects.create(
name="Article {}".format(i), created=some_date)

for i in range(1, 8):
ArticleDerived.objects.create(
name="ArticleDerived {}".format(i), created=some_date)

def get_ordered_articles(self):
return Article.objects.all().order_by('name')

def get_ordered_derived_articles(self):
return ArticleDerived.objects.all().order_by('name')

def test_can_get_items_using_index_and_slice_notation_with_derived_model(self):
self.assertEqual(self.get_ordered_derived_articles()[0].name, 'ArticleDerived 1')
self.assertQuerysetEqual(
self.get_ordered_derived_articles()[4:6],
["<ArticleDerived: ArticleDerived 5>", "<ArticleDerived: ArticleDerived 6>"]
)

def test_can_get_items_using_index_and_slice_notation(self):
self.assertEqual(self.get_ordered_articles()[0].name, 'Article 1')
self.assertQuerysetEqual(
Expand Down

0 comments on commit 4bf5655

Please sign in to comment.