Ticket #24421: 24421-test.diff

File 24421-test.diff, 1023 bytes (added by Tim Graham, 10 years ago)
  • tests/foreign_object/tests.py

    diff --git a/tests/foreign_object/tests.py b/tests/foreign_object/tests.py
    index 5c4c097..a1a8e29 100644
    a b class MultiColumnFKTests(TestCase):  
    302302        normal_members_lists = [list(g.members.all()) for g in Group.objects.all()]
    303303        self.assertEqual(members_lists, normal_members_lists)
    304304
     305    def test_reverse_query(self):
     306        membership = Membership.objects.create(membership_country=self.usa, person=self.bob, group=self.cia)
     307        self.assertQuerysetEqual(
     308            Group.objects.filter(membership=1),
     309            ['<Group: CIA>']
     310        )
     311        self.assertQuerysetEqual(
     312            Group.objects.exclude(membership=1),
     313            []
     314        )
     315
    305316    def test_prefetch_related_m2m_reverse_works(self):
    306317        Membership.objects.create(membership_country=self.usa, person=self.bob, group=self.cia)
    307318        Membership.objects.create(membership_country=self.usa, person=self.jim, group=self.democrat)
Back to Top