Ticket #18583: 18583.diff

File 18583.diff, 3.3 KB (added by Fabián Ezequiel Gallina, 12 years ago)
  • tests/regressiontests/queries/models.py

    diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
    index 28c8585..f1dc27d 100644
    a b import threading  
    88from django.db import models
    99from django.utils import six
    1010from django.utils.encoding import python_2_unicode_compatible
     11from django.contrib.auth.models import Group
    1112
    1213
    1314class DumbCategory(models.Model):
    class Program(models.Model):  
    454455class Channel(models.Model):
    455456    programs = models.ManyToManyField(Program)
    456457    identifier = models.OneToOneField(Identifier)
     458
     459# Models for #19659
     460@python_2_unicode_compatible
     461class A(models.Model):
     462    pass
     463
     464    def __str__(self):
     465        return str(self.pk)
     466
     467@python_2_unicode_compatible
     468class B(models.Model):
     469    a = models.ForeignKey(A)
     470
     471    def __str__(self):
     472        return str(self.pk)
     473
     474@python_2_unicode_compatible
     475class C(models.Model):
     476    b = models.ForeignKey(B)
     477
     478    def __str__(self):
     479        return str(self.pk)
     480
     481@python_2_unicode_compatible
     482class D(models.Model):
     483    a = models.ForeignKey(A)
     484    group = models.ForeignKey(Group)
     485
     486    def __str__(self):
     487        return str(self.pk)
  • tests/regressiontests/queries/tests.py

    diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
    index 82a8de0..9328817 100644
    a b from django.test.utils import str_prefix  
    1717from django.utils import unittest
    1818from django.utils.datastructures import SortedDict
    1919
    20 from .models import (Annotation, Article, Author, Celebrity, Child, Cover,
    21     Detail, DumbCategory, ExtraInfo, Fan, Item, LeafA, LoopX, LoopZ,
     20from .models import (A, Annotation, Article, Author, B, C, Celebrity, Child,
     21    Cover, D, Detail, DumbCategory, ExtraInfo, Fan, Group, Item, LeafA, LoopX, LoopZ,
    2222    ManagedModel, Member, NamedCategory, Note, Number, Plaything, PointerA,
    2323    Ranking, Related, Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten,
    2424    Node, ObjectA, ObjectB, ObjectC, CategoryItem, SimpleCategory,
    class Queries1Tests(BaseQuerysetTest):  
    11131113            ['<Report: r1>']
    11141114        )
    11151115
     1116    def test_ticket19659(self):
     1117        foo = Group.objects.create(name='foo')
     1118        bar = Group.objects.create(name='bar')
     1119        baz = Group.objects.create(name='baz')
     1120        a1 = A.objects.create()
     1121        a2 = A.objects.create()
     1122        a3 = A.objects.create()
     1123        b1 = B.objects.create(a=a2)
     1124        b2 = B.objects.create(a=a1)
     1125        b3 = B.objects.create(a=a3)
     1126        c1 = C.objects.create(b=b3)
     1127        c2 = C.objects.create(b=b2)
     1128        c3 = C.objects.create(b=b1)
     1129        d1 = D.objects.create(a=a1, group=baz)
     1130        d2 = D.objects.create(a=a2, group=bar)
     1131        d3 = D.objects.create(a=a3, group=foo)
     1132        q = C.objects.exclude(b__a__d__group__in=[foo]).order_by('pk')
     1133        self.assertQuerysetEqual(q, ['<C: 2>', '<C: 3>'])
     1134        q = C.objects.exclude(b__a__d__group__in=[bar]).order_by('pk')
     1135        self.assertQuerysetEqual(q, ['<C: 1>', '<C: 2>'])
     1136        q = C.objects.exclude(b__a__d__group__in=[baz]).order_by('pk')
     1137        self.assertQuerysetEqual(q, ['<C: 1>', '<C: 3>'])
     1138
    11161139
    11171140class Queries2Tests(TestCase):
    11181141    def setUp(self):
Back to Top