

def test_proxy(self):
    'Testing Lazy-Geometry support (using the GeometryProxy).'
    pnt = Point(0, 0)
    nullcity = City(name='NullCity', point=pnt)
    nullcity.save()
    for bad in [5, 2.0, LineString((0, 0), (1, 1))]:
        try:
            nullcity.point = bad
        except TypeError:
            pass
        else:
            self.fail('Should throw a TypeError')
    new = Point(5, 23)
    nullcity.point = new
    self.assertEqual(4326, nullcity.point.srid)
    nullcity.save()
    self.assertEqual(new, City.objects.get(name='NullCity').point)
    nullcity.point.x = 23
    nullcity.point.y = 5
    self.assertNotEqual(Point(23, 5), City.objects.get(name='NullCity').point)
    nullcity.save()
    self.assertEqual(Point(23, 5), City.objects.get(name='NullCity').point)
    nullcity.delete()
    shell = LinearRing((0, 0), (0, 100), (100, 100), (100, 0), (0, 0))
    inner = LinearRing((40, 40), (40, 60), (60, 60), (60, 40), (40, 40))
    ply = Polygon(shell, inner)
    nullstate = State(name='NullState', poly=ply)
    self.assertEqual(4326, nullstate.poly.srid)
    nullstate.save()
    ns = State.objects.get(name='NullState')
    self.assertEqual(ply, ns.poly)
    if gdal.HAS_GDAL:
        self.assertEqual(True, isinstance(ns.poly.ogr, gdal.OGRGeometry))
        self.assertEqual(ns.poly.wkb, ns.poly.ogr.wkb)
        self.assertEqual(True, isinstance(ns.poly.srs, gdal.SpatialReference))
        self.assertEqual('WGS 84', ns.poly.srs.name)
    new_inner = LinearRing((30, 30), (30, 70), (70, 70), (70, 30), (30, 30))
    ns.poly[1] = new_inner
    ply[1] = new_inner
    self.assertEqual(4326, ns.poly.srid)
    ns.save()
    self.assertEqual(ply, State.objects.get(name='NullState').poly)
    ns.delete()

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