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