Ticket #28781: 28781.diff

File 28781.diff, 2.3 KB (added by Mariusz Felisiak, 5 years ago)

Tests.

  • tests/queries/test_qs_combinators.py

    diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
    index 84fb0fb81c..9b5d538bae 100644
    a b class QuerySetSetOperationTests(TestCase): 
    3030        qs3 = Number.objects.filter(num__gte=4, num__lte=6)
    3131        self.assertNumbersEqual(qs1.intersection(qs2, qs3), [5], ordered=False)
    3232
     33    @skipUnlessDBFeature('supports_select_intersection')
     34    def test_intersection_with_values(self):
     35        ReservedName.objects.create(name='a', order=2)
     36        qs1 = ReservedName.objects.all()
     37        reserved_name = qs1.intersection(qs1).values('name', 'order', 'id').get()
     38        self.assertEqual(reserved_name['name'], 'a')
     39        self.assertEqual(reserved_name['order'], 2)
     40
    3341    @skipUnlessDBFeature('supports_select_difference')
    3442    def test_simple_difference(self):
    3543        qs1 = Number.objects.filter(num__lte=5)
    class QuerySetSetOperationTests(TestCase): 
    6674        self.assertEqual(len(qs2.difference(qs2)), 0)
    6775        self.assertEqual(len(qs3.difference(qs3)), 0)
    6876
     77    @skipUnlessDBFeature('supports_select_difference')
     78    def test_difference_with_values(self):
     79        ReservedName.objects.create(name='a', order=2)
     80        qs1 = ReservedName.objects.all()
     81        qs2 = ReservedName.objects.none()
     82        reserved_name = qs1.difference(qs2).values('name', 'order', 'id').get()
     83        self.assertEqual(reserved_name['name'], 'a')
     84        self.assertEqual(reserved_name['order'], 2)
     85
    6986    def test_union_with_empty_qs(self):
    7087        qs1 = Number.objects.all()
    7188        qs2 = Number.objects.none()
    class QuerySetSetOperationTests(TestCase): 
    89106        qs2 = Number.objects.filter(num__gte=2, num__lte=3)
    90107        self.assertNumbersEqual(qs1.union(qs2).order_by('-num'), [3, 2, 1, 0])
    91108
     109    def test_union_with_values(self):
     110        ReservedName.objects.create(name='a', order=2)
     111        qs1 = ReservedName.objects.all()
     112        reserved_name = qs1.union(qs1).values('name', 'order', 'id').get()
     113        self.assertEqual(reserved_name['name'], 'a')
     114        self.assertEqual(reserved_name['order'], 2)
     115
    92116    def test_count_union(self):
    93117        qs1 = Number.objects.filter(num__lte=1).values('num')
    94118        qs2 = Number.objects.filter(num__gte=2, num__lte=3).values('num')
Back to Top