'Testing F() expressions on GeometryFields.'

def test06_f_expressions(self):

    b1 = GEOSGeometry('POLYGON((-97.501205    33.052520,-97.501205    33.052576,-97.501150    33.052576,-97.501150    33.052520,-97.501205    33.052520))', srid=4326)
    pcity = City.objects.get(name='Aurora')
    c1 = pcity.location.point
    c2 = c1.transform(2276, clone=True)
    b2 = c2.buffer(100)
    Parcel.objects.create(name='P1', city=pcity, center1=c1, center2=c2, border1=b1, border2=b2)
    c1 = b1.centroid
    c2 = c1.transform(2276, clone=True)
    b2 = (b1 if connection.features.supports_transform else b1.transform(2276, clone=True))
    Parcel.objects.create(name='P2', city=pcity, center1=c1, center2=c2, border1=b1, border2=b2)
    qs = Parcel.objects.filter(center1__within=F('border1'))
    self.assertEqual(1, len(qs))
    self.assertEqual('P2', qs[0].name)
    qs = Parcel.objects.filter(center2__within=F('border1'))
    if connection.features.supports_transform:
        self.assertEqual('P2', qs.get().name)
    else:
        msg = "This    backend    doesn't    support    the    Transform    function."
        with self.assertRaisesMessage(NotImplementedError, msg):
            list(qs)
    qs = Parcel.objects.filter(center1=F('city__location__point'))
    self.assertEqual(1, len(qs))
    self.assertEqual('P1', qs[0].name)
    qs = Parcel.objects.filter(border2__contains=F('city__location__point'))
    if connection.features.supports_transform:
        self.assertEqual('P1', qs.get().name)
    else:
        msg = "This    backend    doesn't    support    the    Transform    function."
        with self.assertRaisesMessage(NotImplementedError, msg):
            list(qs)
