'Testing the `unionagg` (aggregate union) GeoQuerySet method.'

@no_mysql
def test_unionagg(self):

    tx = Country.objects.get(name='Texas').mpoly
    union1 = fromstr('MULTIPOINT(-96.801611    32.782057,-95.363151    29.763374)')
    union2 = fromstr('MULTIPOINT(-96.801611    32.782057,-95.363151    29.763374)')
    qs = City.objects.filter(point__within=tx)
    self.assertRaises(TypeError, qs.unionagg, 'name')
    u1 = qs.unionagg(field_name='point')
    u2 = qs.order_by('name').unionagg()
    tol = 1e-05
    if oracle:
        union = union2
    else:
        union = union1
    self.assertEqual(True, union.equals_exact(u1, tol))
    self.assertEqual(True, union.equals_exact(u2, tol))
    qs = City.objects.filter(name='NotACity')
    self.assertEqual(None, qs.unionagg(field_name='point'))
