#36883: Split up aggregation_regress.tests.AggregationTests.test_more_more,
test_more_more_more
-------------------------------------+-------------------------------------
     Reporter:  Tim Graham           |                     Type:
                                     |  Cleanup/optimization
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  dev                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 These tests are extremely long and most queries are independent and test
 different functionality. While working on the MongoDB backend, I found
 that only parts of the test need to be skipped (e.g. `QuerySet.extra()`),
 so I split up the test like this so the entire thing doesn't need to be
 skipped. Use this patch as a starting point, but give the tests more
 meaningful names.

 {{{#!diff
 diff --git a/tests/aggregation_regress/tests.py
 b/tests/aggregation_regress/tests.py
 index c7d9271dd8..e2169be69d 100644
 --- a/tests/aggregation_regress/tests.py
 +++ b/tests/aggregation_regress/tests.py
 @@ -849,7 +848,7 @@ class AggregationTests(TestCase):
              ],
          )

 -    def test_more_more(self):
 +    def test_more_more1(self):
          # Regression for #10113 - Fields mentioned in order_by() must be
          # included in the GROUP BY. This only becomes a problem when the
          # order_by introduces a new join.
 @@ -869,6 +868,7 @@ class AggregationTests(TestCase):
              lambda b: b.name,
          )

 +    def test_more_more2(self):
          # Regression for #10127 - Empty select_related() works with
 annotate
          qs = (
              Book.objects.filter(rating__lt=4.5)
 @@ -897,6 +897,7 @@ class AggregationTests(TestCase):
              lambda b: (b.name, b.authors__age__avg, b.publisher.name,
 b.contact.name),
          )

 +    def test_more_more3(self):
          # Regression for #10132 - If the values() clause only mentioned
 extra
          # (select=) columns, those columns are used for grouping
          qs = (
 @@ -931,6 +932,7 @@ class AggregationTests(TestCase):
              ],
          )

 +    def test_more_more4(self):
          # Regression for #10182 - Queries with aggregate calls are
 correctly
          # realiased when used in a subquery
          ids = (
 @@ -947,6 +949,7 @@ class AggregationTests(TestCase):
              lambda b: b.name,
          )

 +    def test_more_more5(self):
          # Regression for #15709 - Ensure each group_by field only exists
 once
          # per query
          qstr = str(
 @@ -1046,7 +1049,7 @@ class AggregationTests(TestCase):
              query,
          )

 -    def test_more_more_more(self):
 +    def test_more_more_more1(self):
          # Regression for #10199 - Aggregate calls clone the original
 query so
          # the original query can still be used
          books = Book.objects.all()
 @@ -1065,6 +1068,7 @@ class AggregationTests(TestCase):
              lambda b: b.name,
          )

 +    def test_more_more_more2(self):
          # Regression for #10248 - Annotations work with dates()
          qs = (
              Book.objects.annotate(num_authors=Count("authors"))
 @@ -1079,6 +1083,7 @@ class AggregationTests(TestCase):
              ],
          )

 +    def test_more_more_more3(self):
          # Regression for #10290 - extra selects with parameters can be
 used for
          # grouping.
          qs = (
 @@ -1091,6 +1096,7 @@ class AggregationTests(TestCase):
              qs, [150, 175, 224, 264, 473, 566], lambda b:
 int(b["sheets"])
          )

 +    def test_more_more_more4(self):
          # Regression for 10425 - annotations don't get in the way of a
 count()
          # clause
          self.assertEqual(
 @@ -1100,6 +1106,7 @@ class AggregationTests(TestCase):
 Book.objects.annotate(Count("publisher")).values("publisher").count(), 6
          )

 +    def test_more_more_more5(self):
          # Note: intentionally no order_by(), that case needs tests, too.
          publishers = Publisher.objects.filter(id__in=[self.p1.id,
 self.p2.id])
          self.assertEqual(sorted(p.name for p in publishers), ["Apress",
 "Sams"])
 @@ -1123,6 +1130,7 @@ class AggregationTests(TestCase):
          )
          self.assertEqual(sorted(p.name for p in publishers), ["Apress",
 "Sams"])

 +    def test_more_more_more6(self):
          # Regression for 10666 - inherited fields work with annotations
 and
          # aggregations
          self.assertEqual(
 @@ -1175,6 +1183,7 @@ class AggregationTests(TestCase):
              ],
          )

 +    def test_more_more_more7(self):
          # Regression for #10766 - Shouldn't be able to reference an
 aggregate
          # fields in an aggregate() call.
          msg = "Cannot compute Avg('mean_age'): 'mean_age' is an
 aggregate"
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36883>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019bf2a69874-f2ff60ed-c391-4580-a155-0294c6a65c51-000000%40eu-central-1.amazonses.com.

Reply via email to