'Testing the `extent` GeoQuerySet aggregates on related geographic models.'

@no_mysql
@no_spatialite
def test04a_related_extent_aggregate(self):

    aggs = City.objects.aggregate(Extent('location__point'))
    all_extent = ((-104.528056), 29.763374, (-79.460734), 40.18476)
    txpa_extent = ((-97.516111), 29.763374, (-79.460734), 40.18476)
    e1 = City.objects.extent(field_name='location__point')
    e2 = City.objects.exclude(state='NM').extent(field_name='location__point')
    e3 = aggs['location__point__extent']
    tol = 4
    for (ref, e) in [(all_extent, e1), (txpa_extent, e2), (all_extent, e3)]:
        for (ref_val, e_val) in zip(ref, e):
            self.assertAlmostEqual(ref_val, e_val, tol)
