Ticket #30854: test-30854.diff

File test-30854.diff, 1.2 KB (added by Mariusz Felisiak, 5 years ago)

Test.

  • tests/filtered_relation/tests.py

    diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py
    index 48154413a5..49ca4178ea 100644
    a b class FilteredRelationTests(TestCase):  
    5252                (self.author2, self.book3, self.editor_b, self.author2),
    5353            ], lambda x: (x, x.book_join, x.book_join.editor, x.book_join.author))
    5454
     55    def test_select_related_multiple(self):
     56        qs = Book.objects.annotate(
     57            author_join=FilteredRelation('author'),
     58            editor_join=FilteredRelation('editor'),
     59        ).select_related('author_join', 'editor_join').order_by('pk')
     60        self.assertQuerysetEqual(qs, [
     61                (self.book1, self.author1, self.editor_a),
     62                (self.book2, self.author2, self.editor_b),
     63                (self.book3, self.author2, self.editor_b),
     64                (self.book4, self.author1, self.editor_a),
     65            ],
     66            lambda x: (x, x.author_join, x.editor_join),
     67        )
     68
    5569    def test_select_related_with_empty_relation(self):
    5670        qs = Author.objects.annotate(
    5771            book_join=FilteredRelation('book', condition=Q(pk=-1)),
Back to Top