<s> import unittest <EOL> from django . db import connection <EOL> from django . contrib . gis . tests . utils import mysql , no_mysql , oracle , postgis , spatialite <EOL> test_srs = ( { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , True ) , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , '<STR_LIT>' : False , '<STR_LIT>' : True , <EOL> '<STR_LIT>' : ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:9> ) , <EOL> } , <EOL> { '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , False ) , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : False , '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> '<STR_LIT>' : ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:10> ) , <EOL> } , <EOL> ) <EOL> if oracle : <EOL> from django . contrib . gis . db . backends . oracle . models import SpatialRefSys <EOL> elif postgis : <EOL> from django . contrib . gis . db . backends . postgis . models import SpatialRefSys <EOL> elif spatialite : <EOL> from django . contrib . gis . db . backends . spatialite . models import SpatialRefSys <EOL> class SpatialRefSysTest ( unittest . TestCase ) : <EOL> @ no_mysql <EOL> def test01_retrieve ( self ) : <EOL> "<STR_LIT>" <EOL> for sd in test_srs : <EOL> srs = SpatialRefSys . objects . get ( srid = sd [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( sd [ '<STR_LIT>' ] , srs . srid ) <EOL> auth_name , oracle_flag = sd [ '<STR_LIT>' ] <EOL> if postgis or ( oracle and oracle_flag ) : <EOL> self . assertEqual ( True , srs . auth_name . startswith ( auth_name ) ) <EOL> self . assertEqual ( sd [ '<STR_LIT>' ] , srs . auth_srid ) <EOL> if postgis : <EOL> if connection . ops . spatial_version >= ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:0> ) : <EOL> srtext = sd [ '<STR_LIT>' ] <EOL> else : <EOL> srtext = sd [ '<STR_LIT>' ] <EOL> self . assertEqual ( srtext , srs . wkt ) <EOL> self . assertEqual ( sd [ '<STR_LIT>' ] , srs . proj4text ) <EOL> @ no_mysql <EOL> def test02_osr ( self ) : <EOL> "<STR_LIT>" <EOL> for sd in test_srs : <EOL> sr = SpatialRefSys . objects . get ( srid = sd [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( True , sr . spheroid . startswith ( sd [ '<STR_LIT>' ] ) ) <EOL> self . assertEqual ( sd [ '<STR_LIT>' ] , sr . geographic ) <EOL> self . assertEqual ( sd [ '<STR_LIT>' ] , sr . projected ) <EOL> if not ( spatialite and not sd [ '<STR_LIT>' ] ) : <EOL> self . assertEqual ( True , sr . name . startswith ( sd [ '<STR_LIT:name>' ] ) ) <EOL> if postgis or spatialite : <EOL> srs = sr . srs <EOL> self . assertEqual ( sd [ '<STR_LIT>' ] , srs . proj4 ) <EOL> if not spatialite : <EOL> if connection . ops . spatial_version >= ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:0> ) : <EOL> srtext = sd [ '<STR_LIT>' ] <EOL> else : <EOL> srtext = sd [ '<STR_LIT>' ] <EOL> self . assertEqual ( srtext , srs . wkt ) <EOL> @ no_mysql <EOL> def test03_ellipsoid ( self ) : <EOL> "<STR_LIT>" <EOL> for sd in test_srs : <EOL> ellps1 = sd [ '<STR_LIT>' ] <EOL> prec = sd [ '<STR_LIT>' ] <EOL> srs = SpatialRefSys . objects . get ( srid = sd [ '<STR_LIT>' ] ) <EOL> ellps2 = srs . ellipsoid <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> param1 = ellps1 [ i ] <EOL> param2 = ellps2 [ i ] <EOL> self . assertAlmostEqual ( ellps1 [ i ] , ellps2 [ i ] , prec [ i ] ) <EOL> def suite ( ) : <EOL> s = unittest . TestSuite ( ) <EOL> s . addTest ( unittest . makeSuite ( SpatialRefSysTest ) ) <EOL> return s <EOL> def run ( verbosity = <NUM_LIT:2> ) : <EOL> unittest . TextTestRunner ( verbosity = verbosity ) . run ( suite ( ) ) </s>
