

@no_mysql
def test_relate_lookup(self):
    "Testing the 'relate' lookup type."
    pnt1 = fromstr('POINT (649287.0363174 4177429.4494686)', srid=2847)
    pnt2 = fromstr('POINT(-98.4919715741052 29.4333344025053)', srid=4326)
    self.assertRaises(ValueError, Country.objects.filter, mpoly__relate=(23, 'foo'))
    for (bad_args, e) in [((pnt1, 0), ValueError), ((pnt2, 'T*T***FF*', 0), ValueError)]:
        qs = Country.objects.filter(mpoly__relate=bad_args)
        self.assertRaises(e, qs.count)
    if (postgis or spatialite):
        contains_mask = 'T*T***FF*'
        within_mask = 'T*F**F***'
        intersects_mask = 'T********'
    elif oracle:
        contains_mask = 'contains'
        within_mask = 'inside'
        intersects_mask = 'overlapbdyintersect'
    self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, contains_mask)).name)
    self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, contains_mask)).name)
    ks = State.objects.get(name='Kansas')
    self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, within_mask)).name)
    if (not oracle):
        self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt1, intersects_mask)).name)
        self.assertEqual('Texas', Country.objects.get(mpoly__relate=(pnt2, intersects_mask)).name)
        self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, intersects_mask)).name)

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/contrib/gis/tests/geoapp/tests.py GeoLookupTest.test_relate_lookup/original