ó
ø¢TQc           @   sÉ   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z e ri d  d l m	 Z	 d  d l
 m Z n  e j e ox e d ƒ d e j f d	 „  ƒ  Yƒ Z d
 „  Z d d „ Z e d k rÅ e ƒ  n  d S(   iÿÿÿÿ(   t   ValidationError(   t   HAS_GDAL(   t   HAS_SPATIALREFSYS(   t   unittest(   t   forms(   t   GEOSGeometrys;   GeometryFieldTest needs gdal support and a spatial databaset   GeometryFieldTestc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s7   t  j ƒ  } x$ d D] } |  j t | j | ƒ q Wd S(   s3   Testing GeometryField initialization with defaults.t   blahi   t   FoOi    N(   R   i   R   Ni    (   R   t   GeometryFieldt   Nonet   assertRaisesR    t   clean(   t   selft   fldt   bad_default(    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   test00_init   s    c         C   sŠ   t  j d d ƒ } | j d ƒ } |  j d | j ƒ t  j d d ƒ } d } t d d d ƒ} | j d ƒ } |  j | j | | ƒ ƒ d S(	   s&   Testing GeometryField with a SRID set.t   sridiæ  s   POINT(5 23)iŒ}  gH¯¼šò×z>s)   POINT (951640.547328465 4219369.26171664)s&   SRID=4326;POINT (-95.363151 29.763374)N(   R   R	   R   t   assertEqualR   R   t
   assertTruet   equals_exact(   R   R   t   geomt   tolt
   xform_geomt   cleaned_geom(    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   test01_srid   s    c         C   s…   t  j ƒ  } |  j t  j | j d ƒ t  j d t d t ƒ } |  j t  j | j d ƒ t  j d t ƒ } |  j d | j d ƒ ƒ d S(   s;   Testing GeometryField's handling of null (None) geometries.t   requiredt   nullN(   R   R	   R   R    R   R
   t   FalseR   (   R   R   (    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   test02_null$   s    c         C   s©   t  j ƒ  } x- d D]% } |  j t | ƒ | j | ƒ ƒ q Wt  j d d ƒ } |  j t d ƒ | j d ƒ ƒ |  j t d ƒ | j d ƒ ƒ |  j t  j | j d ƒ d S(   s=   Testing GeometryField's handling of different geometry types.s   POINT(5 23)s)   MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))s   LINESTRING(0 0, 1 1)t	   geom_typet   POINTN(   s   POINT(5 23)s)   MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))s   LINESTRING(0 0, 1 1)(   R   R	   R   R   R   t	   to_pythonR   R    (   R   R   t   wktt   pnt_fld(    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   test03_geom_type2   s    #c         C   sj   t  j ƒ  } x- d D]% } |  j t | ƒ | j | ƒ ƒ q Wx' d	 D] } |  j t  j | j | ƒ qC Wd S(
   sf   
        Testing to_python returns a correct GEOSGeometry object or
        a ValidationError
        s   POINT(5 23)s)   MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))s   LINESTRING(0 0, 1 1)s   POINT(5)s,   MULTI   POLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))s   BLAH(0 0, 1 1)N(   s   POINT(5 23)s)   MULTIPOLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))s   LINESTRING(0 0, 1 1)(   s   POINT(5)s,   MULTI   POLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))s   BLAH(0 0, 1 1)(   R   R	   R   R   R    R   R    (   R   R   R!   (    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   test04_to_python@   s
    #(   t   __name__t
   __module__R   R   R   R#   R$   (    (    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyR      s
   				c          C   s&   t  j ƒ  }  |  j t  j t ƒ ƒ |  S(   N(   R   t	   TestSuitet   addTestt	   makeSuiteR   (   t   s(    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   suiteN   s    i   c         C   s    t  j d |  ƒ j t ƒ  ƒ d  S(   Nt	   verbosity(   R   t   TextTestRunnert   runR+   (   R,   (    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyR.   S   s    t   __main__N(   t   django.formsR    t   django.contrib.gis.gdalR   t   django.contrib.gis.tests.utilsR   t   django.utilsR   t   django.contrib.gisR   t   django.contrib.gis.geosR   t
   skipUnlesst   TestCaseR   R+   R.   R%   (    (    (    s?   ../Django//lib/python/django/contrib/gis/tests/test_geoforms.pyt   <module>   s   B	