ó
öSQc           @  sø   d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z d  d	 l m Z d  d
 l m Z d  d l m Z d  d l m Z m Z d d l m Z m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   date(   t   settings(   t   Sitemapt   GenericSitemap(   t   Site(   t   ImproperlyConfigured(   t   override_settings(   t
   skipUnless(   t   localize(   t   upath(   t   activatet
   deactivatei   (   t	   TestModelt   SitemapTestsBaset   HTTPSitemapTestsc           B  s
  e  Z d  „  Z e d e j j e j j e e	 ƒ ƒ d ƒ f ƒ d „  ƒ Z
 d „  Z d „  Z e d e j j e j j e e	 ƒ ƒ d ƒ f ƒ d „  ƒ Z e e j d ƒ e d e ƒ d	 „  ƒ ƒ Z d
 „  Z e d e j k d ƒ d „  ƒ Z d „  Z d „  Z d „  Z RS(   c         C  s?   |  j  j d ƒ } d |  j } |  j | j j d ƒ | ƒ d S(   u&   A simple sitemap index can be renderedu   /simple/index.xmluµ   <?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
u   utf-8N(   t   clientt   gett   base_urlt   assertXMLEqualt   contentt   decode(   t   selft   responset   expected_content(    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_simple_sitemap_index   s    t   TEMPLATE_DIRSu	   templatesc         C  s?   |  j  j d ƒ } d |  j } |  j | j j d ƒ | ƒ d S(   u=   A simple sitemap index can be rendered with a custom templateu   /simple/custom-index.xmluÜ   <?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
u   utf-8N(   R   R   R   R   R   R   (   R   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt    test_simple_sitemap_custom_index   s    c         C  sK   |  j  j d ƒ } d |  j t j ƒ  f } |  j | j j d ƒ | ƒ d S(   u(   A simple sitemap section can be renderedu   /simple/sitemap-simple.xmluÜ   <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
u   utf-8N(   R   R   R   R   t   todayR   R   R   (   R   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_simple_sitemap_section.   s    c         C  sK   |  j  j d ƒ } d |  j t j ƒ  f } |  j | j j d ƒ | ƒ d S(   u    A simple sitemap can be renderedu   /simple/sitemap.xmluÜ   <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
u   utf-8N(   R   R   R   R   R   R   R   R   (   R   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_simple_sitemap8   s    c         C  sK   |  j  j d ƒ } d |  j t j ƒ  f } |  j | j j d ƒ | ƒ d S(   u7   A simple sitemap can be rendered with a custom templateu   /simple/custom-sitemap.xmlu  <?xml version="1.0" encoding="UTF-8"?>
<!-- This is a customised template -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
u   utf-8N(   R   R   R   R   R   R   R   R   (   R   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_simple_custom_sitemapB   s    u#   Internationalization is not enabledt   USE_L10Nc         C  sg   t  d ƒ |  j d t d ƒ ƒ |  j j d ƒ } |  j | d ƒ |  j | d t j ƒ  ƒ t ƒ  d S(   u8   The priority value should not be localized (Refs #14164)u   fru   0,3g333333Ó?u   /simple/sitemap.xmlu   <priority>0.5</priority>u   <lastmod>%s</lastmod>N(	   R   t   assertEqualR	   R   R   t   assertContainsR   R   R   (   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_localized_priorityP   s    
c         C  sN   t  t j _ |  j j d ƒ } d t j ƒ  } |  j | j	 j
 d ƒ | ƒ d  S(   Nu   /simple/sitemap.xmluë   <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
u   utf-8(   t   FalseR   t   _metat	   installedR   R   R   R   R   R   R   (   R   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_requestsite_sitemap^   s    u   django.contrib.sitesu'   django.contrib.sites app not installed.c         C  s-   t  j j ƒ  j ƒ  |  j t t ƒ  j ƒ d S(   uˆ   
        Check we get ImproperlyConfigured if we don't pass a site object to
        Sitemap.get_urls and no Site objects exist
        N(   R   t   objectst   allt   deletet   assertRaisesR   R   t   get_urls(   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_sitemap_get_urls_no_site_1j   s    c         C  s&   t  t j _ |  j t t ƒ  j ƒ d S(   uÃ   
        Check we get ImproperlyConfigured when we don't pass a site object to
        Sitemap.get_urls if Site objects exists, but the sites framework is not
        actually installed.
        N(   R$   R   R%   R&   R+   R   R   R,   (   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_sitemap_get_urls_no_site_2t   s    c         C  sQ   t  i t j j ƒ  d 6ƒ } d „  } t t | | j ƒ  ƒ ƒ } |  j | ƒ d S(   ur   
        Check to make sure that the raw item is included with each
        Sitemap.get_url() url result.
        u   querysetc         S  s   t  |  d t ƒ S(   Nu   item(   t
   isinstanceR   (   t   url(    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   is_testmodelƒ   s    N(   R   R   R(   R)   t   mapR,   t
   assertTrue(   R   t   test_sitemapR1   t   item_in_url_info(    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_sitemap_item}   s    	c         C  s?   |  j  j d ƒ } d |  j } |  j | j j d ƒ | ƒ d S(   uL   
        Check that a cached sitemap index can be rendered (#2713).
        u   /cached/index.xmluµ   <?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/cached/sitemap-simple.xml</loc></sitemap>
</sitemapindex>
u   utf-8N(   R   R   R   R   R   R   (   R   R   R   (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   test_cached_sitemap_indexˆ   s    (   t   __name__t
   __module__R   R   t   ost   patht   joint   dirnameR
   t   __file__R   R   R   R   R   R   t   USE_I18Nt   TrueR#   R'   t   INSTALLED_APPSR-   R.   R6   R7   (    (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyR      s   	
6	
	
6					(   t
   __future__R    R:   t   datetimeR   t   django.confR   t   django.contrib.sitemapsR   R   t   django.contrib.sites.modelsR   t   django.core.exceptionsR   t   django.test.utilsR   t   django.utils.unittestR   t   django.utils.formatsR	   t   django.utils._osR
   t   django.utils.translationR   R   t   baseR   R   R   (    (    (    s;   ../Django//lib/python/django/contrib/sitemaps/tests/http.pyt   <module>   s   