
    Bh                     l   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 d d	lmZ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" d dl#m$Z$ dZ%dZ&dZ'd Z(d Z) ee%e%fdg       G d de             Z* ee%e%fe&e&fe'e'fdg       G d de             Z+y)    )cache)Http404)override_settings)reverse)SekizaiContext)plugin_rendering)
add_plugincreate_page)get_placeholder_cache)EmptyPageContentPagePlaceholder)PluginContext)Example1)CMSTestCase)override_placeholder_conf)FuzzyInt)
CMSToolbar)get_object_edit_url)detailsztests/rendering/base.htmlztests/rendering/inherit.htmlz$tests/rendering/inherit_with_or.htmlc                 N    |d   }| d| j                    d|j                   d| S )Noriginal_context_varz|test_plugin_processor_ok||bodyslot)instanceplaceholderrendered_contentoriginal_contextr   s        H/home/dcms/DCMS/lib/python3.12/site-packages/cms/tests/test_rendering.pysample_plugin_processorr"      s;    +,BC9(--+JZJZI[[\]q\rss    c                 Z    d| j                   z   dz   |j                  z   dz   |d   z   }d|iS )Nz!test_plugin_context_processor_ok|r   r   test_plugin_context_processorr   )r   r   r    contents       r!   sample_plugin_context_processorr'      sK    1HMMACG!12H!IJG 	( r#   )extra_context.htmlr(   CMS_TEMPLATESc                   *     e Zd Z fdZd Zd Z xZS )RenderingEmptyTestCasec           	         t         |           dddd| _        | j                         | _        | j
                  j                  | j                         t        | j                  d   t        d| j                  d   | j                  | j                  d   	      | _	        | j                  j                  j                         j                          y )
NRenderingTestCase-titlerenderingtestcase-slugrenderingtestcase-reverse-idtitleslug
reverse_idr2   enr3   r4   r3   
created_byr4   )supersetUp	test_dataget_superuseruserclientforce_loginr
   TEMPLATE_NAMEpagepagecontent_setalldeleteself	__class__s    r!   r9   zRenderingEmptyTestCase.setUp-   s    .,8
 &&(			*NN7#]D'DII~~l3
	 			!!%%'..0r#   c                 \   | j                   j                  dd      }| j                  t        |t              d       | j                  t              5  | j                   j                  d      }| j                  || j                         }t        ||       ddd       y# 1 sw Y   yxY w)z_
        A page with EmptyPageContent except root returns 404 when you try to view it.
        r5   Tforce_reloadpathr@   r3   N)
r@   get_content_objassertEqual
isinstancer   assertRaisesr   get_pathget_requestr   )rE   page_contentrK   requests       r!    test_page_with_empty_pagecontentz7RenderingEmptyTestCase.test_page_with_empty_pagecontent?   s     yy00D0IL2BCTJw' 	(99%%d+D&&Dtyy&AGG$'	( 	( 	(s   AB""B+c                    | j                   j                  dd      }| j                  t        |t              d       | j                  d| j                         }t        || j                   j                  d            }| j                  |j                  d       | j                  |j                  t        d             y	)
z[
        The root page with EmptyPageContent redirects to PageContent's changelist
        r5   TrH   z/en/rJ   rL   i.  z admin:cms_pagecontent_changelistN)r@   rM   rN   rO   r   rR   r   rQ   status_codeurlr   )rE   rS   rT   responses       r!   -test_page_with_empty_pagecontent_for_root_urlzDRenderingEmptyTestCase.test_page_with_empty_pagecontent_for_root_urlK   s     yy00D0IL2BCTJ""TYY"?7););D)AB--s3w/Q'RSr#   )__name__
__module____qualname__r9   rU   rZ   __classcell__rF   s   @r!   r,   r,   &   s    1$
(
Tr#   r,   c                       e Zd Z fdZd Zd Z eedfg      d4d       Z eedfg      d        Z	d	 Z
 ed
d      d        Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd  Zd! Zd" Z  ed#$      d%        Z! ed&$      d'        Z" ed#$      d(        Z# ed&$      d)        Z$d* Z%d+ Z&d, Z'd- Z(d. Z) edd/d#ii0      d1        Z*d2 Z+d3 Z, xZ-S )5RenderingTestCasec                    t         |           | j                         | _        | j	                  | j                        5  dddddd| _        ddd	d
| _        ddddd| _        ddddddiiidd| _        dddddd| _	        ddddd| _
        ddd d!d| _        d"d#d$d%d| _        d&d'd(d)d| _        d*d+d,d-d| _        | j                          d d d        y # 1 sw Y   y xY w).Nr.   r/   r0   zRenderingTestCase-mainzRenderingTestCase-sub)r2   r3   r4   	text_maintext_subzRenderingTestCase-title2zRenderingTestCase-slug2zrenderingtestcase-reverse-id2r1   zRenderingTestCase-title3zRenderingTestCase-slug3zrenderingtestcase-reverse-id3zRenderingTestCase-sub3)r2   r3   r4   rd   zno extra var!extra_context	extra_varzfound extra var)r2   no_extraplaceholderconfextrazRenderingTestCase-title5zRenderingTestCase-slug5zrenderingtestcase-reverse-id5zRenderingTestCase-main-page5zRenderingTestCase-sub5zRenderingTestCase-title6zRenderingTestCase-slug6zrenderingtestcase-reverse-id6zRenderingTestCase-sub6zRenderingTestCase-title7zRenderingTestCase-slug7zrenderingtestcase-reverse-id7zRenderingTestCase-sub7zRenderingTestCase-title8zRenderingTestCase-slug8zrenderingtestcase-reverse-id8zRenderingTestCase-sub8zRenderingTestCase-title9zRenderingTestCase-slug9zrenderingtestcase-reverse-id9zRenderingTestCase-sub9zRenderingTestCase-title10zRenderingTestCase-slug10zrenderingtestcase-reverse-id10zRenderingTestCase-sub10)r8   r9   r;   	test_userlogin_user_contextr:   
test_data2
test_data3
test_data4
test_data5
test_data6
test_data7
test_data8
test_data9test_data10insert_test_contentrD   s    r!   r9   zRenderingTestCase.setUpb   sJ   ++-$$T^^4 >	'20<53DN 41=DO 41=4	DO 4+$3oUfGg5h#i*	DO 41=;4DO 41=4	DO 41=4	DO 41=4	DO 41=4	DO 52>5	 D $$&}>	' >	' >	's    BCC"c           	      z
   t        | j                  d   t        d| j                  d   | j                  | j                  d         }i | _        |j                  d      D ]  }|| j                  |j                  <    t        | j                  d   dd| j                  d   	       t        | j                  d
   dd| j                  d   	       t        | j                  d   t        d|| j                  d   | j                  d         }t        | j                  d   t        d| j                  d   || j                  d         }i | _        |j                  d      D ]  }|| j                  |j                  <    t        | j                  d
   dd| j                  d   	       t        | j                  d   dd|      }i | _        |j                  d      D ]  }|| j                  |j                  <    t        | j                  d   dd       t        | j                  d   t        d|| j                  d   | j                  d         }i | _        |j                  d      D ]  }|| j                  |j                  <    t        | j                  d
   dd| j                  d   	       t        | j                  d   dd| j                  d   	       t        | j                   d   t        d| j                   d   || j                   d         }i | _        |j                  d      D ]  }|| j"                  |j                  <    t        | j"                  d
   dd| j                   d   	       t        | j$                  d   t        d| j$                  d   || j$                  d         }t        | j&                  d   t(        d| j&                  d   || j&                  d         }	t        | j*                  d   t(        d| j*                  d   | j*                  d         }
t        | j,                  d   t(        d| j,                  d   |
| j,                  d         }| j/                  |      | _        | j/                  |      | _        | j/                  |      | _        | j/                  |      | _        | j/                  |      | _        | j/                  |      | _        | j/                  |      | _        | j/                  |	      | _        | j/                  |
      | _         | j/                  |      | _!        y )Nr2   r5   r3   r4   r6   main
TextPluginrc   r   subrd   )parentr3   r4   )r3   r{   r4   r(   )r{   re   ExtraContextPlugin)r3   r4   )"r
   r:   r?   rj   test_placeholdersget_placeholdersr   r	   rl   INHERIT_TEMPLATE_NAMErm   test_placeholders3rn   test_placeholders4ro   test_placeholders5rp   test_placeholders6rq   rr   INHERIT_WITH_OR_TEMPLATE_NAMErs   rt   reload	test_page
test_page2
test_page3
test_page4
test_page5
test_page6
test_page7
test_page8
test_page9test_page10)rE   pr   p2p3p4p5p6p7p8p9p10s               r!   ru   z%RenderingTestCase.insert_test_content   s   w/!^^F3#'>>,#?A "$--d3 	CK7BD"";#3#34	C 	4))&1<{3	54))%0,z2	4 13H$ !(?$(OOL$AC
 13H$"oof5b$(OOL$AC #%..t4 	DK8CD##K$4$45	D 	4**51<DOO\fLgh 13GVWX"$..t4 	DK8CD##K$4$45	D 	4**?;=QSWX OOG$&;T4??62|4
 #%..t4 	DK8CD##K$4$45	D 	4**51<DOO\fLgh4**62L$T__]hMij OOG$&;T(|4
 #%..t4 	DK8CD##K$4$45	D 	4**51<DOO\fLghOOG$&;T(|4

 OOG$&CT(|4

 OOG$&CT(|4

 W%'Dd!!&)"''57 Q++b/++b/++b/++b/++b/++b/++b/++b/;;s+r#   c                 B    |j                         j                  dd      S )N
 )stripreplace)rE   r&   s     r!   strip_renderedz RenderingTestCase.strip_rendered  s    }}&&tR00r#   r   r)   Nc                    |"| j                  |      }t        |      |_        |i }|4|j                         }| j                  |      }|j	                  ||      }n| j                  |||      }| j                  |      S )Nr@   )rR   r   toolbarget_templaterenderrender_template_objr   )rE   r@   templatecontext_varsrT   template_objoutputs          r!   r   zRenderingTestCase.render  s    ?&&D&1G(1GOL((*H,,X6L!((w?F--hgNF""6**r#   c                 f   t        | j                  | j                        | j                  j                  d            }|j	                          | j                  |j                  j                  d            }| j                  |d| j                  d   z   dz   | j                  d   z   dz          y)z:
        Tests that the `detail` view is working.
        r   r5   utf8r   rc   rd   N)
r   rR   r   rQ   r   r   r&   decoderN   r:   )rE   rY   rs      r!   test_details_viewz#RenderingTestCase.test_details_view  s    
 4+++@$..BYBYZ^B_` 0 0 7 7 ?@C$.."==CdnnU_F``cffgr#   c                    | j                  | j                        }t        |      |_        | j                  j                  d      }| j                  |_        |j                  j                  |       | j                  |      }|j                  | j                        }| j                  |_        | j                  t        |      d       y)zQContentRenderer._get_content_object uses toolbar to return placeholders of a pager   r5      N)rR   r   r   r   r   rM   r@   
set_objectget_content_renderer_get_content_objectrN   len)rE   rT   wrong_content_objcontent_rendererplaceholderss        r!   test_getting_placeholdersz+RenderingTestCase.test_getting_placeholders&  s    """7$W- OO;;DA!%""#4544W=';;DNNK!%\*A.r#   )z0cms.tests.test_rendering.sample_plugin_processor)z8cms.tests.test_rendering.sample_plugin_context_processor)CMS_PLUGIN_PROCESSORSCMS_PLUGIN_CONTEXT_PROCESSORSc                 X  
 ddl m} ddlm} | j                  d   j                  d      j                         j                         }| j                  
|j                   G 
fdd|             }d }d|_
        ||_        t        d	d
d|| j                  d   |f      }i t        _        | j                         }|j!                  ||| j                  d         }| j"                  d    d| j"                  d    d| j"                  d    d}	| j%                  ||	       i t        _        y
)z
        Tests that plugin processors and plugin context processors can be defined
        in settings and are working and that extra plugin context processors can be
        passed to PluginContext.
        r   )rx   )plugin_poolrw   r5   c                       e Zd ZdZ fdZy)>RenderingTestCase.test_processors.<locals>.ProcessorTestPluginzTest Pluginc                     d} |      S )Nzi{% load cms_tags %}{{ body }}|test_passed_plugin_context_processor_ok|{{ test_plugin_context_processor }} )rE   contextr   r   tload_from_strings        r!   get_render_templatezRRenderingTestCase.test_processors.<locals>.ProcessorTestPlugin.get_render_templateI  s    : (**r#   N)r[   r\   r]   namer   )r   s   r!   ProcessorTestPluginr   E  s     D+r#   r   c                 
    ddiS )N$test_passed_plugin_context_processor'test_passed_plugin_context_processor_okr   )r   r   r   s      r!   r   zORenderingTestCase.test_processors.<locals>.test_passed_plugin_context_processorO  s    :<effr#   original_context_var_okN)r   rT   )
processorsrc   zJ|test_passed_plugin_context_processor_ok|test_plugin_context_processor_ok|z7|main|original_context_var_ok|test_plugin_processor_ok|z|main|original_context_var_ok)#djangocms_text_ckeditor.cms_pluginsrx   cms.plugin_poolr   r}   get_pluginsfirstget_bound_pluginload_template_from_stringregister_pluginplugin_type_instr   r   _standard_processorsr   render_pluginr:   rN   )rE   rx   r   r   r   r   r   r   r   expectedr   s             @r!   test_processorsz!RenderingTestCase.test_processors3  s:    	C/))&1==dCIIK\\^99		$	$	+* 	+ 
%	+	g  5!%>4P""6*8\7^

 13-446**8Wd>T>TU[>\]~~k*++u~~k*++b~~k*++HJ 	
 	H%02-r#   c                     | j                  | j                        }| j                  |d| j                  d   z   dz   | j                  d   z   dz          y):
        Tests the {% placeholder %} templatetag.
        r   rc   rd   Nr   r   rN   r:   rE   r   s     r!   test_placeholderz"RenderingTestCase.test_placeholderf  sN     KK'C$.."==CdnnU_F``cffgr#   c                 |   d}| j                  | j                  |      }| j                  || j                  d          t	        j
                          t        | j                  d         5  | j                  | j                  |      }d d d        | j                  || j                  d          y # 1 sw Y   )xY w)Nz4{% load cms_tags %}{% placeholder "extra_context" %}r   rg   rh   CMS_PLACEHOLDER_CONFri   )r   r   rN   rn   r   clearr   rE   r   r   s      r!   test_placeholder_extra_contextz0RenderingTestCase.test_placeholder_extra_contextm  s    BKK!K4DOOJ78&DOOL]<^_ 	9DOOa8A	9DOOG45	9 	9s   ,B22B;c                 f    d}| j                  | j                  |      }| j                  |d       y)r   N{% load cms_tags %}|{% placeholder "empty" or %}No content{% endplaceholder %}r   z|No contentN)r   r   rN   r   s      r!   test_placeholder_orz%RenderingTestCase.test_placeholder_orv  s0    JKKK3M*r#   c                    d}| j                         }| j                  |      5  | j                  j                         dz   }| j	                  || j                        }d|j
                  d<   t        |      |_        ddd       | j                        }t               }||d<   | j                  j                  d      j                  d	
      }|j                  ||d| j                  d      }d| d}| j                  | j                  ||      }	| j                  |	| j                  |             y# 1 sw Y   xY w)zJ
        Tests the {% placeholder or %} templatetag in edit mode.
        r   z?editr   Tcms_editNcms_content_rendererr5   emptyr   )r   languager@   editabler   z
No content)r   rT   )r;   rk   r   get_absolute_urlrR   sessionr   r   r   r   r~   getrender_placeholderr   rN   r   )
rE   r   	superuserendpointrT   rendererr   r   r   rendereds
             r!    test_placeholder_or_in_edit_modez2RenderingTestCase.test_placeholder_or_in_edit_mode  s7   J&&(	$$Y/ 	2~~6687BH&&xdnn&EG*.GOOJ'(1GO		2 ,,W5 "*2&'nn55d;??W?M.. / 
 xj
+;;t~~7;K4#6#6x#@A'	2 	2s   AD77E c                 4   d}t        dddd      }|j                          t        |j                  dd|	       d
}| j	                  | j
                  |d|i      }| j                  d|z  |       | j                  d|       | j                  d|z  |       y)zA
        Tests the {% render_placeholder %} templatetag.
        I'm the render placeholder bodychar_1char_2char_3char_4r   r   r   r   rx   r5   ry   z{% extends "base.html" %}
{% load cms_tags %}

{% block content %}
<h1>{% render_placeholder ex1.placeholder %}</h1>
<h2>{% render_placeholder ex1.placeholder as tempvar %}</h2>
<h3>{{ tempvar }}</h3>
{% endblock content %}
ex1r   r   <h1>%s</h1>	<h2></h2><h3>%s</h3>Nr   saver	   r   r   r   assertIn)rE   render_placeholder_bodyr   r   r   s        r!   test_render_placeholder_tagz-RenderingTestCase.test_render_placeholder_tag  s     #Dhx&(
3??L$=TU KK%KN33	

 		

 	33	
r#   c                 4   d}t        dddd      }|j                          t        |j                  dd|	       d
}| j	                  | j
                  |d|i      }| j                  d|z  |       | j                  d|       | j                  d|z  |       y)zJ
        Tests the {% render_uncached_placeholder %} templatetag.
        (I'm the render uncached placeholder bodyr   r   r   r   r   rx   r5   ry   z{% extends "base.html" %}
{% load cms_tags %}

{% block content %}
<h1>{% render_uncached_placeholder ex1.placeholder %}</h1>
<h2>{% render_uncached_placeholder ex1.placeholder as tempvar %}</h2>
<h3>{{ tempvar }}</h3>
{% endblock content %}
r   r   r  r  r  Nr  )rE    render_uncached_placeholder_bodyr   r   r   s        r!   $test_render_uncached_placeholder_tagz6RenderingTestCase.test_render_uncached_placeholder_tag  s     ,V(hx&(
3??L$=]^ KK%KN<<	
 		

 	<<	
r#   c                    d}t        dddd      }|j                          | j                  d      }t        |j                  dd	|
       d}t        |j                  d	d|      }| j                  | j                  |d|i       t        |j                  d	d|      }| j                  ||       | j                  |       y)zW
        Tests that {% render_uncached_placeholder %} does not populate cache.
        r
  r   r   r   r   r   /rx   r5   ry   zM{% load cms_tags %}<h1>{% render_uncached_placeholder ex1.placeholder %}</h1>   r   N)
r   r  rR   r	   r   r   r   r   rN   assertIsNone)rE   r  r   rT   r   cache_value_beforecache_value_afters          r!   1test_render_uncached_placeholder_tag_no_use_cachezCRenderingTestCase.test_render_uncached_placeholder_tag_no_use_cache  s     ,V(hx&(
""3'3??L$=]^b23??D!WUDNNHucl;1#//4GT+->?+,r#   c                    d}t        dddd      }|j                          | j                  d      }t        |j                  dd	|
       d}t        |j                  d	d|      }| j                  | j                  |d|i       t        |j                  d	d|      }| j                  ||       | j                  |       | j                  |       y)zF
        Tests that {% render_placeholder %} populates cache.
        r   r   r   r   r   r   r  rx   r5   ry   zD{% load cms_tags %}<h1>{% render_placeholder ex1.placeholder %}</h1>r  r   N)r   r  rR   r	   r   r   r   r   assertNotEqualr  assertIsNotNone)rE   r  r   rT   r   r  r  s          r!   %test_render_placeholder_tag_use_cachez7RenderingTestCase.test_render_placeholder_tag_use_cache  s     #Dhx&(
""3'3??L$=TUY23??D!WUDNNHucl;1#//4GT.0AB,-./r#   c                    dt        | j                  j                        z   dz   dz   dz   t        | j                  j                        z   dz   dz   }| j	                  | j                  || j                  d| j                  j                  id	      }| j                  |d
| j                  d   z   dz  d
| j                  d   z   dz  z          y)z}
        Tests the {% show_placeholder %} templatetag, using lookup by pk/dict/reverse_id and passing a Page object.
        z/{% load cms_tags %}|{% show_placeholder "main"  %}z(|{% show_placeholder "main" test_dict %}z|{% show_placeholder "sub" "" %}z'|{% show_placeholder "sub" test_page %}pkr   	test_dictr   r   rc   r   rd   N)strr   r  r4   r   rN   r:   r   s      r!   test_show_placeholderz'RenderingTestCase.test_show_placeholder  s    +-01B1B-CDFKL67 ++ .11J1J-KL OUU 6	6
 KKNN'+~~T4>>K\K\D]^  

 	S4>>+#>>!CsT^^\fMgGgklFllmr#   c                    dt        | j                  j                        z   dz   }| j                  | j                  |      }| j	                  || j
                  d          t        j                          t        | j
                  d         5  | j                  | j                  |      }| j	                  || j
                  d          d d d        y # 1 sw Y   y xY w)Nz@{% load cms_tags %}{% show_uncached_placeholder "extra_context" r  r   rg   rh   r   ri   )	r  r   r  r   rN   rn   r   r   r   r   s      r!   #test_show_placeholder_extra_contextz5RenderingTestCase.test_show_placeholder_extra_context  s    NQTUYUdUdUgUgQhhkppKK!K4DOOJ78&DOOL]<^_ 	:DOOa8AQ 89	: 	: 	:s   =CCc                     d| j                   j                  z  }| j                  | j                   |      }| j                  || j                  d          y)z\
        Tests the {% show_uncached_placeholder %} templatetag, using lookup by pk.
        z@{%% load cms_tags %%}{%% show_uncached_placeholder "main" %s %%}rc   N)r   r  r   rN   r:   rE   r   r   s      r!   $test_show_uncached_placeholder_by_pkz6RenderingTestCase.test_show_uncached_placeholder_by_pk%  sI     VX\XfXfXiXiiT^^X6!<=r#   c                     d}| j                  | j                  |dd| j                  j                  ii      }| j                  || j                  d          y )NzC{% load cms_tags %}{% show_uncached_placeholder "main" test_dict %}r  r  rc   )r   r   r  rN   r:   r#  s      r!   -test_show_uncached_placeholder_by_lookup_dictz?RenderingTestCase.test_show_uncached_placeholder_by_lookup_dict-  sJ    XT^^XdDNNL]L]E^7_`!<=r#   c                     d| j                   j                  z  }| j                  | j                   |      }| j                  || j                  d          y )NzA{%% load cms_tags %%}{%% show_uncached_placeholder "sub" "%s" %%}rd   )r   r4   r   rN   r:   r#  s      r!   ,test_show_uncached_placeholder_by_reverse_idz>RenderingTestCase.test_show_uncached_placeholder_by_reverse_id2  sF    VY]YgYgYrYrrT^^X6
!;<r#   c                     d}| j                  | j                  |d| j                  i      }| j                  || j                  d          y )NzB{% load cms_tags %}{% show_uncached_placeholder "sub" test_page %}r   rd   r   r#  s      r!   &test_show_uncached_placeholder_by_pagez8RenderingTestCase.test_show_uncached_placeholder_by_page7  s?    WT^^XT^^7TU
!;<r#   c                    d}| j                   j                  d      j                  d      }| j                  | j                         }t	        |dd|      }| j                  | j                   |d| j                   i      }t	        |dd|      }| j                  |d| j                  d	   z         | j                  ||       | j                  |       y
)zU
        Tests that {% show_uncached_placeholder %} does not populate cache.
        zK{% load cms_tags %}<h1>{% show_uncached_placeholder "sub" test_page %}</h1>r5   rz   r   r   r  r   r  rd   N)	r   r~   r   rR   r   r   rN   r:   r  )rE   r   r   rT   r  r   r  s          r!   /test_show_uncached_placeholder_tag_no_use_cachezARenderingTestCase.test_show_uncached_placeholder_tag_no_use_cache<  s     ann55d;??U?K"""72;aQT^^XT^^7TU1+tQP
1K!KL+->?+,r#   c                     d| j                   j                  z  }| j                  | j                  |      }| j	                  || j                   j                                y )Nz({%% load cms_tags %%}{%% page_url %s %%})r   r  r   r   rN   r   r#  s      r!   test_page_url_by_pkz%RenderingTestCase.test_page_url_by_pkK  sG    =@R@RRT^^X6!A!A!CDr#   c                     d}| j                  | j                  |dd| j                  j                  ii      }| j	                  || j                  j                                y )Nz+{% load cms_tags %}{% page_url test_dict %}r  r  )r   r   r   r  rN   r   r#  s      r!   test_page_url_by_dictionaryz-RenderingTestCase.test_page_url_by_dictionaryP  sN    @T^^XdDOOL^L^E_7`a!A!A!CDr#   c                     d| j                   j                  z  }| j                  | j                  |      }| j	                  || j                   j                                y Nz*{%% load cms_tags %%}{%% page_url "%s" %%})r   r4   r   r   rN   r   r#  s      r!   test_page_url_by_reverse_idz-RenderingTestCase.test_page_url_by_reverse_idU  sG    ?$//B\B\\T^^X6!A!A!CDr#   c                     d| j                   j                  z  }| j                  d |      }| j                  || j                   j	                                y r2  )r   r4   r   rN   r   r#  s      r!   )test_page_url_by_reverse_id_not_on_a_pagez;RenderingTestCase.test_page_url_by_reverse_id_not_on_a_pageZ  sC    ?$//B\B\\T8,!A!A!CDr#   c                     d}| j                  | j                  |d| j                  i      }| j                  || j                  j	                                y )Nz+{% load cms_tags %}{% page_url test_page %}r   r   r   r   rN   r   r#  s      r!   test_page_url_by_pagez'RenderingTestCase.test_page_url_by_page_  sC    @T^^XT__7UV!A!A!CDr#   c                     d}| j                  | j                  |d| j                  i      }| j                  || j                  j	                                y )NzE{% load cms_tags %}{% page_url test_page as test_url %}{{ test_url }}r   r7  r#  s      r!   test_page_url_by_page_asz*RenderingTestCase.test_page_url_by_page_asd  sC    ZT^^XT__7UV!A!A!CDr#   F)DEBUGc                 ~    d}| j                  | j                  |d| j                  i      }| j                  |d       y )N.{% load cms_tags %}{% page_url "bogus_page" %}r   r   r   r   r   rN   r#  s      r!   test_page_url_on_bogus_pagez-RenderingTestCase.test_page_url_on_bogus_pagem  s6    CT^^XT__7UV$r#   Tc                     d}| j                  t        j                  | j                  | j                  |d| j
                  i       y )Nr=  r   )rP   r   DoesNotExistr   r   r   )rE   r   s     r!   $test_page_url_on_bogus_page_in_debugz6RenderingTestCase.test_page_url_on_bogus_page_in_debugx  s;    CKKNN$//*	
r#   c                 ~    d}| j                  | j                  |d| j                  i      }| j                  |d       y NzH{% load cms_tags %}{% page_url "bogus_page" as test_url %}{{ test_url }}r   r   r>  r#  s      r!   test_page_url_as_on_bogus_pagez0RenderingTestCase.test_page_url_as_on_bogus_page  6    ]T^^XT__7UV$r#   c                 ~    d}| j                  | j                  |d| j                  i      }| j                  |d       y rD  r>  r#  s      r!   'test_page_url_as_on_bogus_page_in_debugz9RenderingTestCase.test_page_url_as_on_bogus_page_in_debug  rF  r#   c                    dt        | j                  j                        z   dz   dz   t        | j                  j                        z   dz   dz   dz   dz   dz   dz   t        | j                  j                        z   d	z   d
z   t        | j                  j                        z   dz   dz   dz   dz   dz   }| j	                  | j
                  || j                  d| j                  j                  id      }| j                  |d| j                  d   z   dz  d| j                  d   z   dz  z   d| j                  d   z   dz  z          y)z
        Tests the {% page_attribute %} templatetag, using current page, lookup by pk/dict/reverse_id and passing a
        Page object.
        zv{% load cms_tags %}|{% page_attribute title %}{% page_attribute title as title %}|{{ title }}|{% page_attribute title r  z{% page_attribute title z as title %}z|{{ title }}z%|{% page_attribute title test_dict %}z-{% page_attribute title test_dict as title %}z|{% page_attribute slug "r  z{% page_attribute slug "z" as slug %}z|{{ slug }}z$|{% page_attribute slug test_page %}z+{% page_attribute slug test_page as slug %}r  r  r   r   r2   r      r3   N)	r  r   r  r4   r   r   rN   r:   rl   r   s      r!   test_page_attributez%RenderingTestCase.test_page_attribute  s   
( +.doo.@.@*A	B EJ	J
 ''
 *-T__-?-?)@A
 DRR  44 << 	 (
( +.doo.H.H*I
J MS
S '' *-T__-G-G)HI LZZ  33 ::   KKNN'+dDOOL^L^E_`  

 	S4>>'#::a?3Y`IaCaefBff$//&))Qj/ / 	0r#   c                 D   | j                  | j                        }| j                  |d| j                  d   z   dz   | j                  d   z          | j                  | j
                        }| j                  |d| j                  d   z   dz   | j                  d   z          y Nr   rc   rd   )r   r   rN   r:   rm   r   ro   rp   r   s     r!   test_inherit_placeholderz*RenderingTestCase.test_inherit_placeholder  s    KK(C$.."==CdooV`Faab KK(C$//+">>DtWaGbbcr#   c                    d| j                   d   z   dz   | j                  d   z   }d| j                   d   z   dz   }| j                  | j                         | j                  | j                         | j                  | j                  | j                        |       | j                  | j                  | j                        |       | j                  | j                         | j                  | j                  | j                        d       y )Nr   rc   rd   |<p>Ultimate fallback</p>|)
ro   rp   r   r   r   rN   r   r   r   r   )rE   
expected_6
expected_7s      r!   #test_inherit_placeholder_with_cachez5RenderingTestCase.test_inherit_placeholder_with_cache  s    4??;77#=PZ@[[
4??;77#=
 	DNN# 	DOO$ 	T__5zBT__5zBDOO$T%5%568TUr#   c                     d| j                   d   z   dz   }| j                  | j                  | j                        |       d}| j                  | j                  | j                        |       y )Nr   rc   rP  )ro   rN   r   r   r   )rE   
expected_8expected_10s      r!    test_inherit_placeholder_with_orz2RenderingTestCase.test_inherit_placeholder_with_or  s]     4??;77#=
T__5zB2T%5%56Dr#   c                     | j                  | j                        }| j                  |d| j                  d   z   dz   | j                  d   z          y rM  )r   r   rN   ro   r   s     r!   !test_inherit_placeholder_overridez3RenderingTestCase.test_inherit_placeholder_override  sH     KK(C$//+">>DtWaGbbcr#   language_fallbackr   c                     | j                  t        dd            5  | j                  | j                        }| j	                  |d| j
                  d   z   dz          d d d        y # 1 sw Y   y xY w)N   
   r   rc   )assertNumQueriesr   r   r   rN   r:   r   s     r!    test_inherit_placeholder_queriesz2RenderingTestCase.test_inherit_placeholder_queries  sd    ""8Ar?3 	IDOO,AQdnn[&A AC GH	I 	I 	Is   AA&&A/c                    t               }d|_        dx|_        |_        | j	                  | j                               5  | j                  | j                        }| j                  t        |            }i |_
        t        |      |_        | j                  |      }t               }||d<   d d d        d|j                  z  dg}j                  |dd      }|D ]  }| j!                  ||v |d	|        y # 1 sw Y   PxY w)
Ntestc   rT   zcms-placeholder-%szcms-placeholderr5   T)r   z is not in )r   r   r  idrk   r;   get_pagecontent_objr   rR   r   r   r   r   r   r   r   
assertTrue)	rE   r   rS   rT   r   r   classesr   clss	            r!   test_render_placeholder_toolbarz1RenderingTestCase.test_render_placeholder_toolbar  s   !m!*,,$$T%7%7%9: 	)33DNNCL&&':<'HIG GO(1GO009H$&G!(GI	) !;>>1
 ,,['4RV,W 	LCOOC6McWKz+JK	L	) 	)s   A-C;;Dc                    | j                   }|j                  d      j                  d      }t        |dd      }t        |dd|      }t        |dd|      }||g|_        |||g}| j                  | j                               5  | j                  |      }| j                  t        |            }i |_
        t        |      |_        t               }	||	d<   |j                  j                         }
|
j                  ||	|d	      }d
}ddd       |D ]E  }j!                  |j"                  |j$                  |j&                        }| j)                  |       G y# 1 sw Y   TxY w)z>
        Ensures that the edit-mode markup is correct
        r5   rw   r   SolarSystemPluginPlanetPlugin)targetrT   T)r   r   r   r   zV<template class="cms-plugin cms-plugin-start cms-plugin-{}" data-cms-placeholder="{}">N)r   r~   r   r	   child_plugin_instancesrk   r;   rd  rR   r   r   r   r   r   r   r   formatr  placeholder_idpositionr  )rE   r@   r   parent_pluginchild_plugin_1child_plugin_2pluginsrS   rT   r   r   r   
tag_formatplugin	start_tags                  r!   !test_render_plugin_toolbar_markupz3RenderingTestCase.test_render_plugin_toolbar_markup  sv    ~~++D15565B";0CTJ#Km\#Km\0
,
 
 $$T%7%7%9: 	t33D9L&&':<'HIG GO(1GO$&G!(GI&CCE%33&'	 4 F sJ	t   	-F"))&))V5J5JFOO\IMM)V,	-!	t 	ts   BEE%)NNN).r[   r\   r]   r9   ru   r   r   r?   r   r   r   r   r   r   r   r   r  r  r  r  r  r!  r$  r&  r(  r*  r,  r.  r0  r3  r5  r8  r:  r?  rB  rE  rH  rK  rN  rS  rW  rY  r_  rh  rx  r^   r_   s   @r!   ra   ra   X   s   B'H`,D1 }b&9%:;+ <+  }b&9%:;h <h/ S&c-3	-3^h6+B:"
H!
F-(0*n :>>
=
=
-E
E
E
E
E
E U#% $% T"
 #
 U#% $% T"% #%
0:dV$Ed T4G3O,PQI RI
L.%-r#   ra   N),django.core.cacher   django.http.responser   django.test.utilsr   django.urlsr   sekizai.contextr   cmsr   cms.apir	   r
   cms.cache.placeholderr   
cms.modelsr   r   r   cms.plugin_renderingr   ,cms.test_utils.project.placeholderapp.modelsr   cms.test_utils.testcasesr   $cms.test_utils.util.context_managersr   cms.test_utils.util.fuzzy_intr   cms.toolbar.toolbarr   cms.toolbar.utilsr   	cms.viewsr   r?   r   r   r"   r'   r,   ra   r   r#   r!   <module>r     s    # ( /  *   + 7 : : . A 0 J 2 * 1 +6  F t
 	&4)T[ )T)TX 	&	 56	&(EF4	A- A-A-r#   