ó
ø¢TQc           @@  sœ   d  d l  m Z d  d l m Z d  d l m Z d  d l Z d  d l m Z d  d l	 m
 Z
 d  d l m Z d d	 l m Z m Z d
 e f d „  ƒ  YZ d S(   i    (   t   absolute_import(   t   BytesIO(   t   minidomN(   t   settings(   t   Site(   t   TestCasei   (   t   Cityt   Countryt   GeoSitemapTestc           B@  sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s$   django.contrib.gis.tests.geoapp.urlsc         C@  sA   t  d t j d d d d ƒ j ƒ  t  j j |  _ t t  j _ d  S(   Nt   idt   domains   example.comt   name(   R   R   t   SITE_IDt   savet   _metat	   installedt   old_Site_meta_installedt   True(   t   self(    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   setUp   s    "c         C@  s   |  j  t j _ d  S(   N(   R   R   R   R   (   R   (    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   tearDown   s    c         C@  sE   t  g  | j D] } | j ^ q ƒ } t  | ƒ } |  j | | ƒ d S(   s0   Taken from regressiontests/syndication/tests.py.N(   t   sett
   childNodest   nodeNamet   assertEqual(   R   t   elemt   expectedt   nt   actual(    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   assertChildNodes   s    %c         C@  sc   t  j |  j j d ƒ j ƒ } | j } |  j | j d ƒ d ƒ |  j d t | j	 d ƒ ƒ ƒ d S(   s   Tests geographic sitemap index.s   /sitemap.xmlt   xmlnss+   http://www.sitemaps.org/schemas/sitemap/0.9i   t   sitemapN(
   R   t   parseStringt   clientt   gett   contentt
   firstChildR   t   getAttributet   lent   getElementsByTagName(   R   t   doct   index(    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   test_geositemap_index    s    	c         C@  s+  x$d D]} t  j |  j j d | ƒ j ƒ } | j } |  j | j d ƒ d ƒ |  j | j d ƒ d ƒ | j d ƒ } |  j d	 t	 | ƒ ƒ x‘| D]‰} |  j
 | d
 d g ƒ | j d ƒ d } | j d ƒ d } |  j | | j d j ƒ | j d
 ƒ d j d j j d ƒ d } | d k rIt  j |  j j | ƒ j ƒ }	 n„ | d k rÍt |  j j | ƒ j ƒ }
 t j |
 ƒ } |  j d t	 | j ƒ ƒ |  j d | j d j ƒ t  j | j d ƒ ƒ }	 n  d | k rât } n d | k r÷t } n  |  j | j j ƒ  t	 |	 j d ƒ ƒ ƒ q– Wq Wd S(   s"   Tests KML/KMZ geographic sitemaps.t   kmlt   kmzs   /sitemaps/%s.xmlR   s+   http://www.sitemaps.org/schemas/sitemap/0.9s	   xmlns:geos-   http://www.google.com/geo/schemas/sitemap/1.0t   urli   t   locs   geo:geoi    s
   geo:formats   http://example.comi   s   doc.kmlt   cityt   countryt	   PlacemarkN(   R+   R,   (   R   R    R!   R"   R#   R$   R   R%   R'   R&   R   R   t   datat   splitR   t   zipfilet   ZipFilet   filelistt   filenamet   readR   R   t   objectst   count(   R   t   kml_typeR(   t   urlsett   urlsR-   t   geo_elemt
   geo_formatt   kml_urlt   kml_doct   buft   zft   model(    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   test_geositemap_kml(   s4    "	*!		c         C@  sÿ   d d l  m } t j |  j j d ƒ j ƒ } | j } |  j | j	 d ƒ d ƒ |  j | j	 d ƒ d ƒ | j
 d ƒ } |  j t | ƒ t | ƒ ƒ xd | D]\ } |  j | d	 d
 g ƒ | j
 d
 ƒ d } | j
 d ƒ d } |  j d | j d j ƒ q› Wd S(   s!   Tests GeoRSS geographic sitemaps.i   (   t	   feed_dicts   /sitemaps/georss.xmlR   s+   http://www.sitemaps.org/schemas/sitemap/0.9s	   xmlns:geos-   http://www.google.com/geo/schemas/sitemap/1.0R-   R.   s   geo:geoi    s
   geo:formatt   georssN(   t   feedsRF   R   R    R!   R"   R#   R$   R   R%   R'   R&   R   R   R2   (   R   RF   R(   R<   R=   R-   R>   R?   (    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   test_geositemap_georssO   s    	(	   t   __name__t
   __module__R=   R   R   R   R*   RE   RI   (    (    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyR      s   					'(   t
   __future__R    t   ioR   t   xml.domR   R4   t   django.confR   t   django.contrib.sites.modelsR   t   django.testR   t   modelsR   R   R   (    (    (    sF   ../Django//lib/python/django/contrib/gis/tests/geoapp/test_sitemaps.pyt   <module>   s   