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

@no_mysql
def test04b_related_union_aggregate(self):

    aggs = City.objects.aggregate(Union('location__point'))
    p1 = Point((-104.528056), 33.387222)
    p2 = Point((-97.516111), 33.058333)
    p3 = Point((-79.460734), 40.18476)
    p4 = Point((-96.801611), 32.782057)
    p5 = Point((-95.363151), 29.763374)
    if oracle:
        ref_u1 = MultiPoint(p4, p5, p3, p1, p2, srid=4326)
        ref_u2 = MultiPoint(p3, p2, srid=4326)
    else:
        ref_u1 = MultiPoint(p1, p2, p4, p5, p3, srid=4326)
        ref_u2 = MultiPoint(p2, p3, srid=4326)
    u1 = City.objects.unionagg(field_name='location__point')
    u2 = City.objects.exclude(name__in=('Roswell', 'Houston', 'Dallas', 'Fort    Worth')).unionagg(field_name='location__point')
    u3 = aggs['location__point__union']
    self.assertEqual(ref_u1, u1)
    self.assertEqual(ref_u2, u2)
    self.assertEqual(ref_u1, u3)
