o
    ÌÉhÃ‚ ã                   @   s*  d dl 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 dlmZ d dl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mZ d dlmZ d dlmZ d dl m!Z! d dl"m#Z#m$Z$m%Z% d dl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 d dl3m4Z4 d dl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW d dlXmYZY d dlZm[Z[ dd„ Z\G dd„ deƒZ]eg d¢dG dd„ deƒƒZ^G dd„ deƒZ_ed d!d"g d#¢d$d%gd&G d'd(„ d(e_ƒƒZ`G d)d*„ d*eƒZaG d+d,„ d,eƒZbG d-d.„ d.eƒZcG d/d0„ d0eƒZdG d1d2„ d2eƒZeG d3d4„ d4eƒZfG d5d6„ d6eƒZgG d7d8„ d8eƒZhG d9d:„ d:eƒZiG d;d<„ d<eƒZjG d=d>„ d>eYeƒZkG d?d@„ d@eƒZlG dAdB„ dBeƒZmG dCdD„ dDeƒZnG dEdF„ dFeƒZoG dGdH„ dHeƒZpG dIdJ„ dJeƒZqG dKdL„ dLeƒZrG dMdN„ dNeƒZsG dOdP„ dPeƒZtG dQdR„ dReƒZuG dSdT„ dTeƒZvG dUdV„ dVeƒZwG dWdX„ dXeƒZxG dYdZ„ dZeƒZyed"d[G d\d]„ d]eƒƒZzG d^d_„ d_eƒZ{G d`da„ daeƒZ|G dbdc„ dceƒZ}G ddde„ deeeYƒZ~dS )fé    N)ÚMock)Úsettings)Úget_user_model)ÚAnonymousUserÚGroup)ÚContentType)ÚValidationError)ÚHttp404)ÚClientÚTestCaseÚoverride_settings)ÚRequestFactory)Úreverse)ÚtimezoneÚtranslation)Úfreeze_time)ÚParentNotTranslatedError)Úget_dummy_request)Ú	BasicLockÚScheduledForPublishLockÚWorkflowLock)ÚCommentÚGroupApprovalTaskÚLocaleÚPageÚPageLogEntryÚPageManagerÚPageViewRestrictionÚSiteÚWorkflowÚWorkflowTaskÚget_page_modelsÚget_translatable_models)Úpage_published)"ÚAbstractPageÚAdvertÚAlwaysShowInMenusPageÚBlogCategoryÚBlogCategoryBlogPageÚBusinessChildÚBusinessIndexÚBusinessNowherePageÚBusinessSubIndexÚCustomManagerÚCustomManagerPageÚCustomPageQuerySetÚEventCategoryÚ
EventIndexÚ	EventPageÚEventPageSpeakerÚGenericSnippetPageÚManyToManyBlogPageÚMTIBasePageÚMTIChildPageÚMyCustomPageÚOneToOnePageÚPageWithExcludedCopyFieldÚPageWithGenericRelationÚRelatedGenericRelationÚSimpleChildPageÚ
SimplePageÚSimpleParentPageÚSingleEventPageÚSingletonPageÚStandardIndexÚ
StreamPageÚTaggedGrandchildPageÚ
TaggedPage)ÚWagtailTestUtils)ÚRouteResultc                 C   s   t j | ¡S ©N)r   ÚobjectsÚget_for_model)Úmodel© rL   ú]/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/tests/test_page_model.pyÚget_ctK   s   rN   c                   @   sv   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Ze	dddd„ ƒZ
e	dddd„ ƒZdd„ Zdd„ Zdd„ ZdS )ÚTestValidationú	test.jsonc                 C   sJ   t jjdd}tdddd}|j|d t jj|jd}|  |jd¡ d	S )
z6
        Check that basic page creation works
        ú/home/©Úurl_pathúHello worldúhello-worldÚhello©ÚtitleÚslugÚcontent©Úinstance©ÚidN)r   rI   Úgetr>   Ú	add_childr^   ÚassertEqualrX   ©ÚselfÚhomepageÚ
hello_pageÚretrieved_pagerL   rL   rM   Útest_can_createR   s   ÿzTestValidation.test_can_createc                 C   sš   t jjdd}tddd}|  t¡ |j|d W d   ƒ n1 s#w   Y  tdddd}|  t¡ |j|d W d   ƒ d S 1 sFw   Y  d S )	NrQ   rR   rU   rV   )rY   rZ   r[   Ú rW   ©r   rI   r_   r>   ÚassertRaisesr   r`   )rc   rd   re   rL   rL   rM   Útest_title_is_required`   s   ÿ"ÿz%TestValidation.test_title_is_requiredc                 C   s~   t jjdd}tddd}|j|d t jj|jd}|  |jd¡ td	dd}|j|d t jj|jd}|  |jd
¡ d S )NrQ   rR   rT   rV   ©rX   rZ   r[   r]   rU   ÚEventszevents-2)r   rI   r_   r>   r`   r^   ra   rY   )rc   rd   re   rf   Úevents_pagerL   rL   rM   Útest_slug_is_autogeneratedk   s   z)TestValidation.test_slug_is_autogeneratedc                 C   sX   t jjdd}tdddd}|  t¡ |j|d W d   ƒ d S 1 s%w   Y  d S )NrQ   rR   rm   ÚeventsrV   rW   r[   ri   )rc   rd   rn   rL   rL   rM   Ú&test_slug_must_be_unique_within_parentz   s
   "ÿz5TestValidation.test_slug_must_be_unique_within_parentc                 C   sF   t jjdd}tdddd}|j|d |  t jj|jd ¡ ¡ d S )	NrQ   rR   Ú	ChristmasÚ	christmasrV   rW   r[   r]   )	r   rI   r_   r>   r`   Ú
assertTrueÚfilterr^   Úexists)rc   rd   Úchristmas_pagerL   rL   rM   Ú&test_slug_can_duplicate_other_sections   s   ÿz5TestValidation.test_slug_can_duplicate_other_sectionsT)ÚWAGTAIL_ALLOW_UNICODE_SLUGSc                 C   ó,   t dd}t  ¡ j|d |  |jd¡ d S )Nõ   A mÃ¶Ã¶se bit me Ã¶nce©rX   r[   u   a-mÃ¶Ã¶se-bit-me-Ã¶nce©r   Úget_first_root_noder`   ra   rY   ©rc   ÚpagerL   rL   rM   Ú2test_slug_generation_respects_unicode_setting_trueŒ   ó   
zATestValidation.test_slug_generation_respects_unicode_setting_trueFc                 C   rz   )Nr{   r|   r[   za-moose-bit-me-oncer}   r   rL   rL   rM   Ú3test_slug_generation_respects_unicode_setting_false’   r‚   zBTestValidation.test_slug_generation_respects_unicode_setting_falsec                 C   s$   t jjdd}|  |j| ¡ ¡ d S )NrQ   rR   )r   rI   r_   ra   Údraft_titleÚget_admin_display_title©rc   rd   rL   rL   rM   Útest_get_admin_display_title˜   s   z+TestValidation.test_get_admin_display_titlec                 C   s:   t jjddjddd t jjdd}|  | ¡ d¡ d S )NrQ   rR   z
live titlerh   )rX   r„   )r   rI   ru   Úupdater_   ra   r…   r†   rL   rL   rM   Ú3test_get_admin_display_title_with_blank_draft_titleœ   s
   ÿzBTestValidation.test_get_admin_display_title_with_blank_draft_titlec                 C   s€   t jjdd}tddd}|j|d t jj|jd}|  |jd¡ tdddd	}|j|d t jj|jd}|  |jd¡ d S )
NrQ   rR   rT   rV   rl   r[   r]   zHello world edited)rX   r„   rZ   )r   rI   r_   r>   r`   r^   ra   r„   rb   rL   rL   rM   Ú!test_draft_title_is_autopopulated¨   s   ÿz0TestValidation.test_draft_title_is_autopopulatedN)Ú__name__Ú
__module__Ú__qualname__Úfixturesrg   rk   ro   rq   rx   r   r   rƒ   r‡   r‰   rŠ   rL   rL   rL   rM   rO   O   s    

rO   )Ú	localhostúevents.example.comúabout.example.comúunknown.site.com©ÚALLOWED_HOSTSc                   @   sŠ   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd S )!ÚTestSiteRoutingrP   c                 C   s   t jjdd| _tjjdd}tjjdd}t jjd|d| _t jjd|dd	| _t jjd
|d| _t jj| jj	d| jj
d| _d| _d| _d S )NT©Úis_default_siteú/home/events/rR   ú/home/about-us/r   ©ÚhostnameÚ	root_pageÚ8765)r›   rœ   Úportr‘   )r›   rž   rœ   Ú8000r’   )r   rI   r_   Údefault_siter   ÚcreateÚevents_siteÚalternate_port_events_siteÚ
about_siter›   rœ   Úalternate_port_default_siteÚunrecognised_portÚunrecognised_hostname)rc   rn   Ú
about_pagerL   rL   rM   ÚsetUpÃ   s&   ÿÿÿý
zTestSiteRouting.setUpc                 C   s‚   t | jd}|  d¡ t ||j¡ W d   ƒ n1 sw   Y  |  d¡ t ||j¡ W d   ƒ d S 1 s:w   Y  d S )N©Úsiteé   r   )r   r¢   ÚassertNumQueriesr   Úroute_for_requestÚpath©rc   ÚrequestrL   rL   rM   Ú"test_route_for_request_query_countØ   s   þ"þz2TestSiteRouting.test_route_for_request_query_countc                 C   s†   t | jd}|  t|dƒ¡ t ||j¡}|  t|t	ƒ¡ |  
|d |d |d f| jjjg i f¡ |  t|dƒ¡ |  |j|¡ d S )Nrª   Ú_wagtail_route_for_requestr   é   r¬   )r   r¢   ÚassertFalseÚhasattrr   r®   r¯   rt   Ú
isinstancerG   ra   rœ   ÚspecificÚassertIsr³   )rc   r±   ÚresultrL   rL   rM   Útest_route_for_request_valueá   s   þz,TestSiteRouting.test_route_for_request_valuec                 C   s^   t | jd}tƒ }||_|  d¡ |  t ||j¡|¡ W d   ƒ d S 1 s(w   Y  d S )Nrª   r   )	r   r¢   r   r³   r­   ra   r   r®   r¯   )rc   r±   ÚmrL   rL   rM   Útest_route_for_request_cachedí   s   "ÿz-TestSiteRouting.test_route_for_request_cachedc                 C   s&   t d| jd}|  t ||j¡¡ d S )Núdoes-not-exist©r¯   r«   )r   r¢   ÚassertIsNoner   r®   r¯   r°   rL   rL   rM   Ú%test_route_for_request_suppresses_404ô   s   z5TestSiteRouting.test_route_for_request_suppresses_404c                 C   sP   t | jd}|  t ||j¡| jjj¡ t d| jd}|  t ||j¡d ¡ d S )Nrª   r¾   r¿   )r   r¢   ra   r   Úfind_for_requestr¯   rœ   r¸   )rc   Úrequest_200Úrequest_404rL   rL   rM   Útest_find_for_requestø   s   þþz%TestSiteRouting.test_find_for_requestc                 C   óP   t | jd}|  d¡ |  t |¡| j¡ W d   ƒ d S 1 s!w   Y  d S ©Nrª   r´   )r   r¢   r­   ra   r   rÂ   r°   rL   rL   rM   Ú)test_valid_headers_route_to_specific_site  s   "ÿz9TestSiteRouting.test_valid_headers_route_to_specific_sitec                 C   rÆ   rÇ   )r   r£   r­   ra   r   rÂ   r°   rL   rL   rM   Ú+test_ports_in_request_headers_are_respected
  s   ÿ"ÿz;TestSiteRouting.test_ports_in_request_headers_are_respectedc                 C   sV   t ƒ }| j|jd< |  d¡ |  t |¡| j¡ W d   ƒ d S 1 s$w   Y  d S )NÚ	HTTP_HOSTr´   )r   r§   ÚMETAr­   ra   r   rÂ   r    r°   rL   rL   rM   Ú4test_unrecognised_host_header_routes_to_default_site  s
   "ÿzDTestSiteRouting.test_unrecognised_host_header_routes_to_default_sitec                 C   s\   t | jd}| j|jd< |  d¡ |  t |¡| j¡ W d   ƒ d S 1 s'w   Y  d S ©Nrª   ÚSERVER_PORTr´   )r   r    r¦   rË   r­   ra   r   rÂ   r°   rL   rL   rM   Ú>test_unrecognised_port_and_default_host_routes_to_default_site  s
   "ÿzNTestSiteRouting.test_unrecognised_port_and_default_host_routes_to_default_sitec                 C   sb   t ƒ }| j|jd< | j|jd< |  d¡ |  t |¡| j¡ W d   ƒ d S 1 s*w   Y  d S ©NrÊ   rÎ   r´   )	r   r§   rË   r¦   r­   ra   r   rÂ   r    r°   rL   rL   rM   ÚCtest_unrecognised_port_and_unrecognised_host_routes_to_default_site   s   "ÿzSTestSiteRouting.test_unrecognised_port_and_unrecognised_host_routes_to_default_sitec                 C   sd   t ƒ }| jj|jd< | j|jd< |  d¡ |  t |¡| j¡ W d   ƒ d S 1 s+w   Y  d S rÐ   )	r   r¤   r›   rË   r¦   r­   ra   r   rÂ   r°   rL   rL   rM   ÚEtest_unrecognised_port_on_known_hostname_routes_there_if_no_ambiguity)  s   "ÿzUTestSiteRouting.test_unrecognised_port_on_known_hostname_routes_there_if_no_ambiguityc                 C   s\   t | jd}| j|jd< |  d¡ |  t |¡| j¡ W d   ƒ d S 1 s'w   Y  d S rÍ   )	r   r¢   r¦   rË   r­   ra   r   rÂ   r    r°   rL   rL   rM   ÚLtest_unrecognised_port_on_known_hostname_routes_to_default_site_if_ambiguity2  s
   "ÿz\TestSiteRouting.test_unrecognised_port_on_known_hostname_routes_to_default_site_if_ambiguityc                 C   sr   t ƒ }d | jj| jj¡|jd< | jj|jd< |  d¡ |  t	 
|¡| j¡ W d   ƒ d S 1 s2w   Y  d S )Nz{}:{}rÊ   rÎ   r´   )r   Úformatr¢   r›   rž   rË   r£   r­   ra   r   rÂ   r°   rL   rL   rM   Ú(test_port_in_http_host_header_is_ignored=  s   
þÿ"ÿz8TestSiteRouting.test_port_in_http_host_header_is_ignoredc                 C   sT   t ƒ }d|jd< |  d¡ |  t |¡| j¡ W d   ƒ d S 1 s#w   Y  d S )Nzdisallowed:80rÊ   r´   )r   rË   r­   ra   r   rÂ   r    r°   rL   rL   rM   Útest_site_with_disallowed_hostJ  s
   
"ÿz.TestSiteRouting.test_site_with_disallowed_hostN)r‹   rŒ   r   rŽ   r©   r²   r»   r½   rÁ   rÅ   rÈ   rÉ   rÌ   rÏ   rÑ   rÒ   rÓ   rÕ   rÖ   rL   rL   rL   rM   r•   ¸   s"    				r•   c                   @   sº   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zeg d
¢ddd„ ƒZ	edddd„ ƒZ
edddd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zedddiid ed!gdd"d#„ ƒƒZd$d%„ Zd&S )'ÚTestRoutingrP   c                 C   ó   ddl m} |ƒ  d S ©Nr   )Úclear_url_caches©Údjango.urlsrÚ   ©rc   rÚ   rL   rL   rM   r©   V  ó   
zTestRouting.setUpc                 C   rØ   rÙ   rÛ   rÝ   rL   rL   rM   ÚtearDown[  rÞ   zTestRouting.tearDownc                 C   óÚ   t jjdd}tjjdd}tjjdd}|  | ¡ |jddf¡ |  |jd¡ |  |jd¡ |  | 	|¡d¡ |  | 
¡ |¡ |  | ¡ |jdd	f¡ |  |jd
¡ |  |jd	¡ |  | 	|¡d	¡ |  | 
¡ |¡ d S )NTr–   rQ   rR   ú/home/events/christmas/úhttp://localhostú/úhttp://localhost/ú/events/christmas/z"http://localhost/events/christmas/©r   rI   r_   r   ra   Úget_url_partsr^   Úfull_urlÚurlÚrelative_urlÚget_site©rc   r    rd   rw   rL   rL   rM   Ú	test_urls`  s(   ÿ
þ
ÿzTestRouting.test_urlsc                 C   sd   t jjdd}tjjdd}|  | ¡ ¡ |  |j¡ |  |j¡ |  | |¡¡ |  | 	¡ ¡ d S )Nrã   rR   Tr–   )
r   rI   r_   r   rÀ   rç   rè   ré   rê   rë   )rc   Úrootr    rL   rL   rM   Útest_page_with_no_urly  s   z!TestRouting.test_page_with_no_url©r   Ú
testserverr   úsecond-events.example.comr“   c           	      C   óx  t jjdd}tjjd|d}tjjd|d}tjjdd}t jjdd}t jjd	d}|  | ¡ |jd
df¡ |  |jd¡ |  |j	d¡ |  | 
|¡d¡ |  | 
|¡d¡ |  | ¡ |¡ |  | ¡ |jddf¡ |  |jd¡ |  |j	d¡ |  | 
|¡d¡ |  | 
|¡d¡ |  | ¡ |¡ t|d}|  |j|d|jddf¡ t|d}|  |j|d|jddf¡ d S )Nr˜   rR   r   rš   rò   Tr–   rQ   rá   râ   rã   rä   úhttp://events.example.comú/christmas/z$http://events.example.com/christmas/rª   ©r±   ú http://second-events.example.com©r   rI   r_   r   r¡   ra   rç   r^   rè   ré   rê   rë   r   ©	rc   rn   r¢   Úsecond_events_siter    rd   rw   r±   Úrequest2rL   rL   rM   Útest_urls_with_multiple_sitesƒ  sT   	ÿÿÿ
þÿþ


þ


þz)TestRouting.test_urls_with_multiple_sitesúwagtail.test.non_root_urls©ÚROOT_URLCONFc                 C   rà   )NTr–   rQ   rR   rá   râ   z/site/zhttp://localhost/site/ú/site/events/christmas/z'http://localhost/site/events/christmas/ræ   rì   rL   rL   rM   Útest_urls_with_non_root_urlconfÂ  s,   ÿ
þÿ
ÿz+TestRouting.test_urls_with_non_root_urlconfzwagtail.test.headless_urlsc                 C   sP   t jjdd}tjjdd}|  | ¡ |jd d f¡ |  |j¡ |  |j	¡ d S )NTr–   rQ   rR   )
r   rI   r_   r   ra   rç   r^   rÀ   rè   ré   )rc   r    rd   rL   rL   rM   Útest_urls_headlessÞ  s
   zTestRouting.test_urls_headlessc                 C   sL   t jjdd}tjjdd}tdd}| |ddg¡\}}}|  ||¡ d S )NrQ   rR   rá   rå   ©r¯   rp   rs   )r   rI   r_   r2   r   Úroutera   )rc   rd   rw   r±   Ú
found_pageÚargsÚkwargsrL   rL   rM   Útest_request_routingé  s
   
z TestRouting.test_request_routingc                 C   s`   t jjdd}ttj ¡ d}tƒ |_| |¡}|  	|j
d¡ |  	|jd |¡ |  |d¡ d S )Nrá   rR   rª   éÈ   rc   ú<h2>Event</h2>)r2   rI   r_   r   r   Úfirstr   ÚuserÚservera   Ústatus_codeÚcontext_dataÚassertContains)rc   rw   r±   ÚresponserL   rL   rM   Útest_request_servingñ  s   
z TestRouting.test_request_servingc                 C   óX   t jjdd}tdd}|  t¡ | |ddg¡ W d   ƒ d S 1 s%w   Y  d S )NrQ   rR   ú/events/quinquagesima/r  rp   Úquinquagesima©r   rI   r_   r   rj   r	   r  ©rc   rd   r±   rL   rL   rM   Ú&test_route_to_unknown_page_returns_404ý  ó
   
"ÿz2TestRouting.test_route_to_unknown_page_returns_404c                 C   r  )NrQ   rR   ú$/events/tentative-unpublished-event/r  rp   ztentative-unpublished-eventr  r  rL   rL   rM   Ú*test_route_to_unpublished_page_returns_404  r  z6TestRouting.test_route_to_unpublished_page_returns_404ÚdefaultÚBACKENDú+django.core.cache.backends.dummy.DummyCache©ÚCACHESÚdummyc                 C   ó  t jjdd}tjjdd}|  d¡ |  | ¡ d¡ W d   ƒ n1 s&w   Y  |  d¡ |  | ¡ d¡ W d   ƒ n1 sCw   Y  |  d¡ |  | ¡ d¡ W d   ƒ n1 s`w   Y  tƒ }|  d¡ |  |j|d	d¡ W d   ƒ n1 s‚w   Y  |  d¡ |  |j|d	d¡ W d   ƒ n1 s¡w   Y  |  d¡ |  |j|d	d¡ W d   ƒ d S 1 sÁw   Y  d S )
NrQ   rR   rá   r´   rã   r   rå   r¬   rö   ©r   rI   r_   r2   r­   ra   Úget_urlr   ©rc   rd   rw   r±   rL   rL   rM   Ú(test_request_scope_site_root_paths_cache  ó.   ÿÿÿÿÿÿ"ÿz4TestRouting.test_request_scope_site_root_paths_cachec           	      C   s    t jjdd}tjjdd}tdd}| |ddg¡\}}}|  ||¡ t jjddj}|  d	¡ |j	d
d}|  ||¡ W d   ƒ d S 1 sIw   Y  d S )NrQ   rR   rá   rå   r  rp   rs   r˜   r   F©rˆ   )
r   rI   r_   r2   r   r  ra   r¸   r­   Ú
get_parent)	rc   rd   rw   r±   r  r  r  rn   ÚparentrL   rL   rM   Útest_cached_parent_obj_set-  s   
"þz&TestRouting.test_cached_parent_obj_setN)r‹   rŒ   r   rŽ   r©   rß   rí   rï   r   rü   r  r  r  r  r  r  r&  r+  rL   rL   rL   rM   r×   Q  s0    
ÿ
7


	
ÿ
r×   zwagtail.test.urls_multilangÚenT©©r,  ÚEnglish)úen-uszEnglish (United States)©ÚfrÚFrenchr.  r1  )rÿ   ÚLANGUAGE_CODEÚWAGTAIL_I18N_ENABLEDÚ	LANGUAGESÚWAGTAIL_CONTENT_LANGUAGESc                   @   sˆ   e Zd Zddd„Zdd„ Zdd„ Zeg d¢d	d
d„ ƒZdd„ Zdd„ Z	eg d¢ddd„ ƒZ
edddiidedgddd„ ƒƒZdS )ÚTestRoutingWithI18Nr,  c                 C   sú   t jjdd}tjjdd}tjjdd}|  |jd|› d¡ |  |jd|› d¡ |  | |¡d|› d¡ |  | ¡ |¡ |  | 	¡ |j
dd|› d	f¡ |  |jd|› d	¡ |  |jd|› d	¡ |  | |¡d|› d	¡ |  | ¡ |¡ d S )
NTr–   rQ   rR   rá   rä   rã   râ   rå   )r   rI   r_   r   ra   rè   ré   rê   rë   rç   r^   )rc   Úexpected_language_coder    rd   rw   rL   rL   rM   rí   K  s<   ÿÿ
ýþ
þÿ
þzTestRoutingWithI18N.test_urlsc                 C   ó8   t  d¡ |  ¡  W d   ƒ d S 1 sw   Y  d S ©Nr2  ©r   Úoverriderí   ©rc   rL   rL   rM   Ú$test_urls_with_translation_activateds  ó   
"ÿz8TestRoutingWithI18N.test_urls_with_translation_activatedc                 C   s<   t  d¡ | jdd W d   ƒ d S 1 sw   Y  d S )Nr0  )r9  r<  r>  rL   rL   rM   Ú4test_urls_with_region_specific_translation_activatedy  s   "ÿzHTestRoutingWithI18N.test_urls_with_region_specific_translation_activatedr-  )r7  c                 C   r:  )Nr0  r<  r>  rL   rL   rM   ÚWtest_urls_with_region_specific_translation_activated_thats_in_wagtail_content_languagesƒ  s   
"ÿzkTestRoutingWithI18N.test_urls_with_region_specific_translation_activated_thats_in_wagtail_content_languagesc                 C   r:  )NÚser<  r>  rL   rL   rM   Ú8test_urls_with_language_not_in_wagtail_content_languages’  r@  zLTestRoutingWithI18N.test_urls_with_language_not_in_wagtail_content_languagesc                 C   s  t jjdd}tjjdd}tjjdd}tjjdd}| |¡}|j|dd}d	|_|jd
gd |  	| 
¡ |jddf¡ |  	|jd¡ |  	|jd¡ |  	| |¡d¡ |  	| ¡ |¡ |  	| 
¡ |jddf¡ |  	|jd¡ |  	|jd¡ |  	| |¡d¡ |  	| ¡ |¡ d S )NTr–   rQ   rR   rá   r2  ©Úlanguage_code©Úcopy_parentsÚnoelrY   ©Úupdate_fieldsrâ   z/fr/zhttp://localhost/fr/z/fr/events/noel/z http://localhost/fr/events/noel/)r   rI   r_   r   r   r¡   Úcopy_for_translationrY   Úsavera   rç   r^   rè   ré   rê   rë   )rc   r    rd   rw   Ú	fr_localeÚfr_homepageÚfr_christmas_pagerL   rL   rM   Ú&test_urls_with_different_language_tree˜  s6   
ÿÿ
þ
ÿz:TestRoutingWithI18N.test_urls_with_different_language_treerð   r“   c           	      C   ró   )Nr˜   rR   r   rš   rò   Tr–   rQ   rá   râ   ú/en/zhttp://localhost/en/rô   z/en/christmas/z'http://events.example.com/en/christmas/rª   rö   r÷   rø   rù   rL   rL   rM   rü   ¹  sZ   	ÿÿÿ
þÿþ


þ

ýþz1TestRoutingWithI18N.test_urls_with_multiple_sitesr  r  r  r  r!  c                 C   r"  )
NrQ   rR   rá   r¬   rR  r   z/en/events/christmas/é   rö   r#  r%  rL   rL   rM   r&  ÿ  r'  z<TestRoutingWithI18N.test_request_scope_site_root_paths_cacheN)r,  )r‹   rŒ   r   rí   r?  rA  r   rB  rD  rQ  rü   r&  rL   rL   rL   rM   r8  <  s&    
(
ÿ
!ÿ
>
ÿ
r8  c                   @   s‚   e Zd ZdgZdd„ Zdd„ Zdd„ Zedd	d
d„ ƒZdd„ Z	dd„ Z
eddgddd„ ƒZdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestServeViewrP   c                 C   s   t  ¡  ddlm} |ƒ  d S rÙ   )r   Úclear_site_root_paths_cacherÜ   rÚ   rÝ   rL   rL   rM   r©   #  s   
zTestServeView.setUpc                 C   rØ   rÙ   rÛ   rÝ   rL   rL   rM   rß   /  rÞ   zTestServeView.tearDownc                 C   ój   | j  d¡}|  |jd¡ |  |jd jd¡ tjjdd}|  |jd |¡ |  	|d¡ |  	|d	¡ d S )
Nrå   r	  r   útests/event_page.htmlrá   rR   rc   ú<h1>Christmas</h1>r
  ©
Úclientr_   ra   r  Ú	templatesÚnamer2   rI   Úcontextr  ©rc   r  rw   rL   rL   rM   Ú
test_serve4  s   zTestServeView.test_serverý   rþ   c                 C   rV  )
Nr   r	  r   rW  rá   rR   rc   rX  r
  rY  r^  rL   rL   rM   Útest_serve_with_non_root_urls?  s   z+TestServeView.test_serve_with_non_root_urlsc                 C   ó   | j  d¡}|  |jd¡ d S )Nr  é”  ©rZ  r_   ra   r  ©rc   r  rL   rL   rM   Ú#test_serve_unknown_page_returns_404K  ó   z1TestServeView.test_serve_unknown_page_returns_404c                 C   ra  )Nr  rb  rc  rd  rL   rL   rM   Ú'test_serve_unpublished_page_returns_404O  rf  z5TestServeView.test_serve_unpublished_page_returns_404r   r   r“   c                 C   s®   t jjdd}tjjd|d | jjddd}|  |jd¡ |  |jd j	d	¡ t
jjd
d}|  |jd |¡ |  |d¡ |  |d¡ tƒ }|jddd}|  |jd¡ d S )Nr˜   rR   r   rš   rõ   )rÊ   r	  r   rW  rá   rc   rX  r
  r   rb  )r   rI   r_   r   r¡   rZ  ra   r  r[  r\  r2   r]  r  r
   )rc   rn   r  rw   ÚcrL   rL   rM   Útest_serve_with_multiple_sitesS  s   z,TestServeView.test_serve_with_multiple_sitesc                 C   sZ   dt _t jjdd}| j d¡}|  |jd |¡ |  |jd |¡ |  |jd |¡ d S )NÚ
event_pagerá   rR   rå   r€   rc   )r2   Úcontext_object_namerI   r_   rZ  ra   r]  )rc   rw   r  rL   rL   rM   Ú#test_serve_with_custom_context_namef  s   z1TestServeView.test_serve_with_custom_context_namec                 C   s6   | j  d¡}|  |jd¡ |  |d¡ |  |d¡ d S )Nú/events/r	  ú<h1>Events</h1>ú*<a href="/events/christmas/">Christmas</a>)rZ  r_   ra   r  r  rd  rL   rL   rM   Útest_serve_with_custom_contextq  s   z,TestServeView.test_serve_with_custom_contextc                 C   s:   | j jddd}|  |jd¡ |  |d¡ |  |d¡ d S )Nrm  ÚXMLHttpRequest)ÚHTTP_X_REQUESTED_WITHr	  rn  ro  )rZ  r_   ra   r  ÚassertNotContainsr  rd  rL   rL   rM   Útest_ajax_response{  s   z TestServeView.test_ajax_responsec                 C   s    | j jddd}|  |d¡ d S )Nrm  Ú	GoogleBot)ÚHTTP_USER_AGENTzbad googlebot no cookie)rZ  r_   r  rd  rL   rL   rM   Útest_before_serve_hookƒ  s   z$TestServeView.test_before_serve_hookN)r‹   rŒ   r   rŽ   r©   rß   r_  r   r`  re  rg  ri  rl  rp  rt  rw  rL   rL   rL   rM   rT     s    


rT  c                   @   ó   e Zd ZdgZdd„ ZdS )ÚTestMovePagerP   c                 C   sš   t jjdd}tjjdd}|j|dd tjj|jd}|  |jd¡ |  |jd¡ |  | 	¡ j|j¡ | 
¡ jd	d
}|  |jd¡ |  |jd¡ d S )Nr™   rR   r˜   ú
last-child©Úposr]   z/home/about-us/events/é   rs   ©rY   é   z /home/about-us/events/christmas/)r>   rI   r_   r1   Úmover^   ra   rS   Údepthr)  Úget_children)rc   Úabout_us_pageÚevents_indexrs   rL   rL   rM   Útest_move_page‹  s   zTestMovePage.test_move_pageN)r‹   rŒ   r   rŽ   r…  rL   rL   rL   rM   ry  ˆ  ó    ry  c                   @   s*   e Zd ZdgZdd„ Zdd„ Zdd„ ZdS )	ÚTestPrevNextSiblingsrP   c                 C   s,   t jjdd}|  | ¡ jdd ¡ ¡ d S )Nrá   rR   ú/home/events/final-event/)r   rI   r_   rt   Úget_next_siblingsru   rv   ©rc   Úchristmas_eventrL   rL   rM   Útest_get_next_siblings   s   ÿýz+TestPrevNextSiblings.test_get_next_siblingsc                 C   s*   t jjdd}|  |jdd ¡ |¡ d S )Nrá   rR   T©Ú	inclusive)r   rI   r_   ra   r‰  r  rŠ  rL   rL   rM   Ú test_get_next_siblings_inclusive¨  s   ÿz5TestPrevNextSiblings.test_get_next_siblings_inclusivec                 C   sD   t jjdd}|  | ¡ jdd ¡ ¡ |  |jdd ¡ |¡ d S )Nrˆ  rR   rá   Tr  )	r   rI   r_   rt   Úget_prev_siblingsru   rv   ra   r  )rc   Úfinal_eventrL   rL   rM   Útest_get_prev_siblings°  s   ÿýÿz+TestPrevNextSiblings.test_get_prev_siblingsN)r‹   rŒ   r   rŽ   rŒ  r  r’  rL   rL   rL   rM   r‡    s
    r‡  c                   @   rx  )ÚTestSaveRevisionrP   c                 C   sX   t jjdd}|  t¡}| ¡  W d   ƒ n1 sw   Y  |  |jjd d¡ d S )Nrá   rR   r   ztpage.save_revision() must be called on the specific version of the page. Call page.specific.save_revision() instead.)	r   rI   r_   rj   ÚRuntimeErrorÚsave_revisionra   Ú	exceptionr  )rc   r‹  ÚerL   rL   rM   Ú+test_raises_error_if_non_specific_page_usedÁ  s   
ÿ
þz<TestSaveRevision.test_raises_error_if_non_specific_page_usedN)r‹   rŒ   r   rŽ   r˜  rL   rL   rL   rM   r“  ¾  r†  r“  c                   @   sb   e Zd ZdgZedƒdd„ ƒZedƒdd„ ƒZedƒdd„ ƒZd	d
„ Zdd„ Z	edƒdd„ ƒZ
dS )ÚTestLiveRevisionrP   z2017-01-01 12:00:00c                 C   sØ   t jjdd}| ¡ }| ¡  | ¡  |  |j|¡ tj	rE|  |j
tjddddddtjjd¡ |  |jtjddddddtjjd¡ d S |  |j
t dddddd¡¡ |  |jt tjddddddtjjd¡¡ d S )	Nr¬   r]   éá  r´   é   r   ©ÚtzinfoéÞ  )r   rI   r_   r•  ÚpublishÚrefresh_from_dbra   Úlive_revisionr   ÚUSE_TZÚlast_published_atÚdatetimer   ÚutcÚfirst_published_atÚ
make_naive©rc   r€   ÚrevisionrL   rL   rM   Ú*test_publish_method_will_set_live_revisionÐ  s4   þþýÿÿýz;TestLiveRevision.test_publish_method_will_set_live_revisionc                 C   sæ   t jjdd}| ¡ }| ¡  | ¡  | ¡  | ¡  |  |j¡ t	j
rL|  |jtjddddddtjjd¡ |  |jtjddddddtjjd¡ d S |  |jt tjddddddtjjd¡¡ |  |jt dddddd¡¡ d S )	Nr¬   r]   rž  r´   r›  r   rœ  rš  )r   rI   r_   r•  rŸ  r   Ú	unpublishrÀ   r¡  r   r¢  ra   r¦  r¤  r   r¥  r£  r§  r¨  rL   rL   rM   Ú.test_unpublish_method_will_clean_live_revisionô  s8   þþÿÿý	ýz?TestLiveRevision.test_unpublish_method_will_clean_live_revisionc                 C   s  t jjdd}| ¡ }| ¡  |jddddœd}|  |j¡ |  |j|j¡ t	j
rQ|  |jtjdd	d	d
ddtjjd¡ |  |jtjdd	d	d
ddtjjd¡ n|  |jt dd	d	d
dd¡¡ |  |jt dd	d	d
dd¡¡ | ¡  |  |jd¡ |  |jd¡ d S )Nr™   rR   TúNew about usúnew-about-us©rX   rY   ©Ú	keep_liveÚupdate_attrsrš  r´   r›  r   rœ  )r>   rI   r_   r•  rŸ  ÚcopyÚassertIsNotNoner¡  ÚassertNotEqualr   r¢  ra   r¦  r¤  r   r¥  r£  r   rX   r„   ©rc   Úabout_usr©  Únew_about_usrL   rL   rM   Ú9test_copy_method_with_keep_live_will_update_live_revision  s6   þþþÿÿzJTestLiveRevision.test_copy_method_with_keep_live_will_update_live_revisionc                 C   s’   t jjdd}| ¡ }| ¡  | ¡  |  |j¡ |jddddœd}|  	|j¡ |  	|j
¡ |  	|j¡ | ¡  |  |jd¡ |  |jd¡ d S )Nr™   rR   Fr­  r®  r¯  r°  )r>   rI   r_   r•  rŸ  r   r´  r¡  r³  rÀ   r¦  r£  ra   rX   r„   r¶  rL   rL   rM   Ú@test_copy_method_without_keep_live_will_not_update_live_revision@  s   þzQTestLiveRevision.test_copy_method_without_keep_live_will_not_update_live_revisionc                 C   sˆ   t jjdd}d|_| ¡  | ¡  |  | ¡ jd¡ |jddddœd}| ¡ }|  |jd¡ | ¡  |  |j	d¡ |  |j
d¡ d S )	Nr™   rR   zWe are even better than beforeFr­  r®  r¯  r°  )r>   rI   r_   rZ   r•  r   ra   Úget_latest_revision_as_objectr³  rX   r„   )rc   r·  r¸  Únew_about_us_draftrL   rL   rM   Ú'test_copy_method_copies_latest_revisionT  s"   þþz8TestLiveRevision.test_copy_method_copies_latest_revisionc                 C   s,  t jjdd}tjrtjddddddtjjd|_nt dddddd¡|_| 	¡ }| 
¡  | ¡  |  |j¡ |  |j¡ tjrh|  |jtjddddddtjjd¡ |  |jtjdd	ddddtjjd¡ d S |  |jt tjddddddtjjd¡¡ |  |jt tjdd	ddddtjjd¡¡ d S )
Nr™   rR   iâ  r´   r›  r   rœ  rž  r¬   )r>   rI   r_   r   r¢  r¤  r   r¥  Ú
go_live_atr•  rŸ  r   rµ   ÚliverÀ   r¡  ra   r¦  r£  r§  )rc   r·  r©  rL   rL   rM   Ú;test_publish_with_future_go_live_does_not_set_live_revisionk  sH   
ÿþþÿÿþÿÿþzLTestLiveRevision.test_publish_with_future_go_live_does_not_set_live_revisionN)r‹   rŒ   r   rŽ   r   rª  r¬  r¹  rº  r½  rÀ  rL   rL   rL   rM   r™  Í  s    
#
&
$r™  c                       sb   e Zd ZdgZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Z‡  ZS )ÚTestPageGetSpecificrP   c                    s:   t ƒ  ¡  tjjdd| _d| j_ddi| j_d| j_d S )Nr™   rR   ÚABCÚkeyÚvalueéç  )	Úsuperr©   r   rI   r_   r€   ÚfooÚbarÚbazr>  ©Ú	__class__rL   rM   r©   ›  s
   
zTestPageGetSpecific.setUpc              	   C   s  |   d¡ | j ¡ }W d   ƒ n1 sw   Y  |  |t¡ |   d¡ |  |j| jj¡ |  |j| jj¡ W d   ƒ n1 sBw   Y  |   d¡ |  |j	¡ W d   ƒ n1 s]w   Y  dD ]%}| j
|d |  t||ƒt| j|ƒ¡ W d   ƒ n1 s„w   Y  qdd S )Nr´   r   ©rÇ  rÈ  rÉ  ©Ú	attribute©r­   r€   Úget_specificÚassertIsInstancer>   ra   r^   rX   rt   rZ   ÚsubTestr¹   Úgetattr©rc   rº   ÚattrrL   rL   rM   Útest_default¢  s"   ÿþÿÿ€ÿz TestPageGetSpecific.test_defaultc              	   C   s  |   d¡ | jjdd}W d   ƒ n1 sw   Y  |  |t¡ |   d¡ |  |j| jj¡ |  |j| jj¡ W d   ƒ n1 sDw   Y  |   d¡ |  |j	¡ W d   ƒ n1 s_w   Y  dD ]%}| j
|d |  t||ƒt| j|ƒ¡ W d   ƒ n1 s†w   Y  qfd S )Nr   T)Údeferredr´   rÌ  rÍ  rÏ  rÔ  rL   rL   rM   Útest_deferred¸  s"   ÿþÿÿ€ÿz!TestPageGetSpecific.test_deferredc                 C   sJ   | j jddgd}|  |j| j j¡ |  |j| j j¡ |  t|dƒ¡ d S )NrÇ  rÈ  ©Ú
copy_attrsrÉ  ©r€   rÐ  r¹   rÇ  rÈ  rµ   r¶   ©rc   rº   rL   rL   rM   Útest_copy_attrsÎ  s   z#TestPageGetSpecific.test_copy_attrsc              	   C   sX   | j jdd}dD ] }| j|d |  t||ƒ¡ W d   ƒ n1 s$w   Y  q	d S )NrL   rÙ  rÌ  rÍ  )r€   rÐ  rÒ  rµ   r¶   rÔ  rL   rL   rM   Útest_copy_attrs_with_empty_listØ  s   ÿ€ÿz3TestPageGetSpecific.test_copy_attrs_with_empty_listc                 C   sH   | j jdgd}|  |j| j j¡ |  |j| j j¡ |  t|dƒ¡ d S )NrÉ  ©Úcopy_attrs_excluderÛ  rÜ  rL   rL   rM   Útest_copy_attrs_excludeà  s   z+TestPageGetSpecific.test_copy_attrs_excludec              	   C   sb   | j jdd}dD ]%}| j|d |  t||ƒt| j |ƒ¡ W d   ƒ n1 s)w   Y  q	d S )NrL   rß  rÌ  rÍ  )r€   rÐ  rÒ  r¹   rÓ  rÔ  rL   rL   rM   Ú'test_copy_attrs_exclude_with_empty_listê  s   ÿ€ÿz;TestPageGetSpecific.test_copy_attrs_exclude_with_empty_listc                 C   ó¢   |   d¡  | jj}| jj}| jj}|  ||¡ |  ||¡ W d   ƒ n1 s(w   Y  |  |t¡ |   d¡ |  |j¡ W d   ƒ d S 1 sJw   Y  d S )Nr´   r   )r­   r€   r¸   r¹   rÑ  r>   rt   rZ   ©rc   rº   Úresult_2Úresult_3rL   rL   rM   Útest_specific_cached_propertyò  s   û"ÿz1TestPageGetSpecific.test_specific_cached_propertyc                 C   rã  )Nr   r´   )r­   r€   Úspecific_deferredr¹   rÑ  r>   rt   rZ   rä  rL   rL   rM   Ú&test_specific_deferred_cached_property  s   û"ÿz:TestPageGetSpecific.test_specific_deferred_cached_property)r‹   rŒ   r   rŽ   r©   rÖ  rØ  rÝ  rÞ  rá  râ  rç  ré  Ú__classcell__rL   rL   rÊ  rM   rÁ  ˜  s    

rÁ  c                   @   s*  e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Z d<d=„ Z!d>d?„ Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHS )IÚTestCopyPagerP   c                 C   sj   t jjdd}|jdddœd}|  |t ¡ |  |jd¡ |  |jd¡ |  |j	|j	¡ |  |j
d¡ d S )Nr™   rR   r­  r®  r¯  ©r²  ú/home/new-about-us/)r>   rI   r_   r³  rÑ  ra   rX   rY   rµ  r^   rS   ©rc   r·  r¸  rL   rL   rM   Útest_copy_page_copies  s   ÿz"TestCopyPage.test_copy_page_copiesc                 C   st   t jjdd}|jdddœd}|  |j ¡ dd¡ |  |j ¡ dd	¡ |  |j ¡ dd
¡ |  |j ¡ dd¡ d S )Nrá   rR   úNew christmas eventúnew-christmas-eventr¯  rì  r´   úChild objects weren't copiedú1Child objects were removed from the original pageú6Child objects defined on the superclass weren't copiedúKChild objects defined on the superclass were removed from the original page)r2   rI   r_   r³  ra   ÚspeakersÚcountÚadvert_placements©rc   r‹  Únew_christmas_eventrL   rL   rM   Ú#test_copy_page_copies_child_objects(  s,   ÿÿýýýz0TestCopyPage.test_copy_page_copies_child_objectsc                 C   sš   t jjdd}tjjdd}tjjdd}||f|_| ¡  |jdddœd	}|  |j 	¡ d
d¡ |  |j 	¡ d
d¡ |  |j 
¡  ¡ |j 
¡  ¡ ¡ dS )úLTest that a page will be copied with parental many to many relations intact.rá   rR   ÚSummer©r\  ÚHolidaysrð  rñ  r¯  rì  r¬   úcChild objects (parental many to many) defined on the superclass were removed from the original pageú4Child objects (parental many to many) weren't copiedN)r2   rI   r_   r0   r¡   Ú
categoriesrM  r³  ra   r÷  ÚallÚin_bulk©rc   r‹  Úsummer_categoryÚholiday_categoryrú  rL   rL   rM   Ú(test_copy_page_copies_parental_relationsI  s,   
ÿýýþz5TestCopyPage.test_copy_page_copies_parental_relationsc                 C   sf   t jjdd}td|jdg|_| ¡  |jdddœd}|  |j 	¡ d	d
¡ | j
|j ¡ dd d S )Nrá   rR   Útest)Útextr  rð  rñ  r¯  rì  r´   z,Comments were removed from the original pagezComments were copied©Úmsg)r2   rI   r_   r   ÚownerÚwagtail_admin_commentsrM  r³  ra   r÷  rµ   rv   rù  rL   rL   rM   Ú%test_copy_page_does_not_copy_commentsl  s    ÿÿý
þz2TestCopyPage.test_copy_page_does_not_copy_commentsc                 C   sx   t jjdd}|jdddœdgd}|  |j ¡ dd	¡ |  |j ¡ dd
¡ | j|j 	¡ dd |  |j ¡ dd¡ d S )Nrá   rR   rð  rñ  r¯  rø  )r²  Úexclude_fieldsr´   rò  ró  zSChild objects were copied despite accessor_name being specified in `exclude_fields`r  rõ  )
r2   rI   r_   r³  ra   rö  r÷  rµ   rø  rv   rù  rL   rL   rM   ÚMtest_copy_page_does_not_copy_child_objects_if_accessor_name_in_exclude_fields‡  s0   þû	ÿýþýzZTestCopyPage.test_copy_page_does_not_copy_child_objects_if_accessor_name_in_exclude_fieldsc                 C   sÂ   t ƒ }tjjdd}|jdddœd}|j|dd |jd	d
dœ|dd}tj d¡}|j ¡ }| 	||||¡ tj d¡}|j
 ¡ }| 	||||¡ | ¡  ¡ j}|j
 ¡ }| 	||||¡ d S )Nrá   rR   zChild christmas eventzchild-christmas-eventr¯  rì  rz  r{  rð  rñ  T)r²  Úprocess_child_objectÚ	recursiverø  Úspeaker)r   r2   rI   r_   r³  r€  Ú_metaÚ	get_fieldrø  Úassert_any_callrö  r‚  r¸   )rc   Úmodify_childÚ	old_eventÚchild_eventÚ	new_eventÚrelationshipÚchild_objectÚnew_child_eventrL   rL   rM   Ú1test_copy_page_with_process_child_object_supplied­  s4   þÿþú


ÿz>TestCopyPage.test_copy_page_with_process_child_object_suppliedc                 C   s  t jjdd}| ¡  |jdddœd}|  |j ¡ d¡ |  |j ¡ dd	¡ | ¡ }|  |j	d¡ |  |j
d¡ | ¡  ¡ }|  |j	d¡ |  |j
d¡ |j ¡ }|j}|  |d
 |j¡ |  |d d d |j¡ t|jjdddƒ}dd„ |d D ƒ}| j| |¡dd d S )Nrá   rR   rð  rñ  r¯  rì  r¬   r´   ú-Revisions were removed from the original pageÚpkrö  r   r€   r^   T©Úflatc                 S   s   h | ]}|d  ’qS )r!  rL   )Ú.0r  rL   rL   rM   Ú	<setcomp>  s    ÿz?TestCopyPage.test_copy_page_copies_revisions.<locals>.<setcomp>z;Child objects in revisions were not given a new primary keyr  )r2   rI   r_   r•  r³  ra   Ú	revisionsr÷  r»  rX   rY   Úget_latest_revisionÚ	as_objectr  rZ   r^   Úsetrö  Úvalues_listrµ   Úintersection)rc   r‹  rú  Úlatest_revisionÚnew_revisionÚnew_revision_contentÚold_speakers_idsÚnew_speakers_idsrL   rL   rM   Útest_copy_page_copies_revisionsØ  s>   ÿý
ÿÿ
þz,TestCopyPage.test_copy_page_copies_revisionsc              	   C   sŠ   t jjdd}| ¡  | ¡ }tjddddddtjjd|_| 	¡  |j
ddd	œd
}|j d¡ ¡ j}|j d¡ ¡ j}|  ||¡ d S )Nrá   rR   rž  r´   r   rœ  rð  rñ  r¯  rì  Ú
created_at)r2   rI   r_   r•  r'  r¤  r   r¥  r2  rM  r³  r&  Úorder_byr  ra   )rc   r‹  r©  rú  Úchristmas_event_created_atÚnew_christmas_event_created_atrL   rL   rM   Ú<test_copy_page_copies_revisions_and_doesnt_change_created_at
  s   ÿÿÿÿzITestCopyPage.test_copy_page_copies_revisions_and_doesnt_change_created_atc                 C   sè   t jjdd}tjr|jtjddddddtjjdd	 n|jt dddddd¡d	 |j	d
ddœd}tjrQ|  
|j d¡ ¡ jtjddddddtjjd¡ n|  
|j d¡ ¡ jt dddddd¡¡ |  |j d¡ ¡ j¡ d S )Nrá   rR   rž  é	   é   r›  r   rœ  )Úapproved_go_live_atrð  rñ  r¯  rì  r2  )r2   rI   r_   r   r¢  r•  r¤  r   r¥  r³  ra   r&  r3  r  r9  rÀ   rù  rL   rL   rM   Ú3test_copy_page_copies_revisions_and_doesnt_schedule#  s>   ÿÿÿÿ
ü
ü
ýz@TestCopyPage.test_copy_page_copies_revisions_and_doesnt_schedulec                 C   sT   t jjdd}| ¡  |jdddœdd}|  |j ¡ d¡ |  |j ¡ dd	¡ d S )
Nrá   rR   rð  rñ  r¯  F)r²  Úcopy_revisionsr´   r   )r2   rI   r_   r•  r³  ra   r&  r÷  rù  rL   rL   rM   Ú9test_copy_page_doesnt_copy_revisions_if_told_not_to_do_soL  s   þû
ýzFTestCopyPage.test_copy_page_doesnt_copy_revisions_if_told_not_to_do_soc                 C   sD   t jjdd}|jdddœd}|  |t¡ |  |j ¡ dd¡ d S )	Nrá   rR   rð  rñ  r¯  rì  r´   rò  )	r   rI   r_   r³  rÑ  r2   ra   rö  r÷  rù  rL   rL   rM   Ú:test_copy_page_copies_child_objects_with_nonspecific_classd  s   ÿÿzGTestCopyPage.test_copy_page_copies_child_objects_with_nonspecific_classc                 C   st   t jjdd}|jddddœd}| ¡ jdd	 ¡ }| ¡ jdd	 ¡ }|  |d
¡ |  |d¡ |  |j	d¡ d S )Nr˜   rR   TúNew events indexúnew-events-indexr¯  ©r  r²  rs   r~  úChild pages weren't copiedú+Child pages were removed from original pageú!/home/new-events-index/christmas/)
r1   rI   r_   r³  r‚  ru   r  r´  ra   rS   ©rc   r„  Únew_events_indexÚold_christmas_eventrú  rL   rL   rM   Ú!test_copy_page_copies_recursivelyu  s    þÿÿÿÿz.TestCopyPage.test_copy_page_copies_recursivelyc                 C   sz   t jjdd}|jddddœd}| ¡ jdd	 ¡ }| ¡ jdd	 ¡ }|  |jj	 
¡ d
d¡ |  |jj	 
¡ d
d¡ d S )Nr˜   rR   Tr>  r?  r¯  r@  rs   r~  r´   rò  ró  )r1   rI   r_   r³  r‚  ru   r  ra   r¸   rö  r÷  rD  rL   rL   rM   Ú4test_copy_page_copies_recursively_with_child_objects‘  s&   þÿÿ
ý
ýzATestCopyPage.test_copy_page_copies_recursively_with_child_objectsc                 C   s‚   t jjdd}| ¡ jdd ¡ j}| ¡  |jddddœd	}| ¡ jdd ¡ }|  	|jj
 ¡ d
¡ |  	|jj
 ¡ dd¡ d S )Nr˜   rR   rs   r~  Tr>  r?  r¯  r@  r¬   r´   r   ©r1   rI   r_   r‚  ru   r  r¸   r•  r³  ra   r&  r÷  ©rc   r„  rF  rE  rú  rL   rL   rM   Ú0test_copy_page_copies_recursively_with_revisions°  s    ÿþÿ
ýz=TestCopyPage.test_copy_page_copies_recursively_with_revisionsc                 C   s„   t jjdd}| ¡ jdd ¡ }|j ¡  |jddddœd	d
}| ¡ jdd ¡ }|  	|jj
 ¡ d¡ |  	|jj
 ¡ dd¡ d S )Nr˜   rR   rs   r~  Tr>  r?  r¯  F)r  r²  r;  r´   r   rI  rJ  rL   rL   rM   ÚPtest_copy_page_copies_recursively_but_doesnt_copy_revisions_if_told_not_to_do_soÍ  s"   ÿ
ýÿ
ýz]TestCopyPage.test_copy_page_copies_recursively_but_doesnt_copy_revisions_if_told_not_to_do_soc                 C   s‚   t jjdd}| ¡ jdd ¡ j}| ¡  |  t	¡}|j
ddddœ|d	 W d   ƒ n1 s1w   Y  |  t|jƒd
¡ d S )Nr˜   rR   rs   r~  Tr>  r?  r¯  )r  r²  Útoú5You cannot copy a tree branch recursively into itself)r1   rI   r_   r‚  ru   r  r¸   r•  rj   Ú	Exceptionr³  ra   Ústrr–  ©rc   r„  rF  r–  rL   rL   rM   Ú2test_copy_page_copies_recursively_to_the_same_treeí  s   ÿýÿþz?TestCopyPage.test_copy_page_copies_recursively_to_the_same_treec                 C   s^   t ƒ jjdd}tjjdd}| ¡  |jdddœ|d}|  |j|¡ |  | ¡ j	|¡ d S )	Núeventmoderator@example.com©Úemailrá   rR   rð  rñ  r¯  )r²  r  )
r   rI   r_   r2   r•  r³  ra   r  r'  r  ©rc   Úevent_moderatorr‹  rú  rL   rL   rM   Útest_copy_page_updates_userÿ  s   ÿþû	
ÿz(TestCopyPage.test_copy_page_updates_userc                 C   s¸   t jjdd}|jddid}|  |t ¡ |  |j|j¡ |  |j|j¡ |  |j	j|j	j¡ |  |j	j
j|j	j
j¡ |  |jd¡ |  tjj|jdt¡ |  tjj|jdt¡ d S )Nú/home/events/saint-patrick/rR   rY   únew-saint-patrickrì  ú/home/events/new-saint-patrick/r]   )r@   rI   r_   r³  rÑ  ra   Úexcerptrµ  r^   Úeventpage_ptrÚpage_ptrrS   r2   r   ©rc   Úsaint_patrick_eventÚnew_saint_patrick_eventrL   rL   rM   Ú!test_copy_multi_table_inheritance  s0   ÿÿþþÿÿz.TestCopyPage.test_copy_multi_table_inheritancec                    óî   t jjdd}tddd}|j dd¡ |j|d | ¡  ¡  d	d
„ |j	 
¡ D ƒ‰ |  tˆ ƒd¡ |  t
ˆ ƒ¡ t jjdd}|j|d}|  |j|j¡ dd
„ |j	 
¡ D ƒ}|  t|ƒd¡ |  t
|ƒ¡ |  t
‡ fdd„|D ƒƒ¡ d S )Nr˜   rR   úMy tagged pageúmy-tagged-pager¯  ÚwagtailÚbirdr[   c                 S   ó   g | ]}|j ‘qS rL   r]   ©r$  ÚitemrL   rL   rM   Ú
<listcomp>C  ó    z;TestCopyPage.test_copy_page_copies_tags.<locals>.<listcomp>r¬   rQ   ©rM  c                 S   rh  rL   r]   ri  rL   rL   rM   rk  O  rl  c                 3   ó    | ]}|ˆ vV  qd S rH   rL   ©r$  Úitem_id©Úold_tagged_item_idsrL   rM   Ú	<genexpr>U  ó   € z:TestCopyPage.test_copy_page_copies_tags.<locals>.<genexpr>)r   rI   r_   rE   ÚtagsÚaddr`   r•  rŸ  Útagged_itemsr  ra   Úlenrt   r³  rµ  r^   ©rc   Úevent_indexÚtagged_pagerd   Únew_tagged_pageÚnew_tagged_item_idsrL   rq  rM   Útest_copy_page_copies_tags;  ó"   ÿz'TestCopyPage.test_copy_page_copies_tagsc                    rc  )Nr˜   rR   zMy very special tagged pagezmy-special-tagged-pager¯  rf  rg  r[   c                 S   rh  rL   r]   ri  rL   rL   rM   rk  b  rl  zFTestCopyPage.test_copy_subclassed_page_copies_tags.<locals>.<listcomp>r¬   rQ   rm  c                 S   rh  rL   r]   ri  rL   rL   rM   rk  n  s    ÿc                 3   rn  rH   rL   ro  rq  rL   rM   rs  v  rt  zETestCopyPage.test_copy_subclassed_page_copies_tags.<locals>.<genexpr>)r   rI   r_   rD   ru  rv  r`   r•  rŸ  rw  r  ra   rx  rt   r³  rµ  r^   )rc   rz  Úsub_tagged_pagerd   Únew_sub_tagged_pager}  rL   rq  rM   Ú%test_copy_subclassed_page_copies_tagsX  s*   ÿÿÿz2TestCopyPage.test_copy_subclassed_page_copies_tagsc                 C   óš   t jjdd}tjjdd}tjjddd}tdd	d
}|j|d |j 	|¡ t
jj||d | ¡  ¡  t jjdd}|j|d}|  |j|j¡ d S )Nr˜   rR   ÚBirdsrþ  úhttp://www.heinz.com/úbeanz meanz heinz©ré   r
  úMy blog pageúmy-blog-pager¯  r[   ©Úcategoryr€   rQ   rm  )r   rI   r_   r'   r¡   r%   r5   r`   Úadvertsrv  r(   r•  rŸ  r³  rµ  r^   ©rc   rz  r‹  ÚadvertÚ	blog_pagerd   Únew_blog_pagerL   rL   rM   Ú!test_copy_page_with_m2m_relationsy  ó   ÿz.TestCopyPage.test_copy_page_with_m2m_relationsc                 C   ó„   t jjdd}tjjddd}tddd}||_|j|d	 | ¡  	¡  t jjd
d}|j
|d}|  |j|j¡ |  |j|¡ d S )Nr˜   rR   r…  r†  r‡  úMy snippet pageúmy-snippet-pager¯  r[   rQ   rm  )r   rI   r_   r%   r¡   r4   Úsnippet_content_objectr`   r•  rŸ  r³  rµ  r^   ra   ©rc   rz  rŽ  r€   rd   Únew_pagerL   rL   rM   Ú'test_copy_page_with_generic_foreign_key  ó   ÿz4TestCopyPage.test_copy_page_with_generic_foreign_keyc                 C   óT   t jjdd}tddd}|j|d t jjdd}|j|d}|  |j|j¡ d S )	Nr˜   rR   úMy pageúmy-pager¯  r[   rQ   rm  )r   rI   r_   r9   r`   r³  rµ  r^   ©rc   rz  r€   rd   r˜  rL   rL   rM   Ú test_copy_page_with_o2o_relation¤  ó   z-TestCopyPage.test_copy_page_with_o2o_relationc                 C   sž   t jjdd}|jtdddddd}| ¡  |j|d	d
id}|jjd }|  	|j
|j
¡ |  |j|j¡ |  |j|j¡ |  |j|j¡ |  	|j|¡ d S )NrQ   rR   Ú	DiscoveryÚdiscoúNCC-1031úContext is for Kings©rX   rY   rZ   Úspecial_fieldr[   rY   údisco-2©rM  r²  r¦  )r   rI   r_   r`   r:   r•  r³  r,  rZ   ra   rX   rµ  r^   r¯   r¦  )rc   rd   r€   r˜  Úexclude_fieldrL   rL   rM   Ú.test_copy_page_with_additional_excluded_fields°  s"   üÿz;TestCopyPage.test_copy_page_with_additional_excluded_fieldsc                 C   sr   t jjdd}|jtdddddd}tjj|d	 |  |j 	¡ ¡ |j
|d
|j› did}|  |j 	¡ ¡ dS )zfTest that a page with a GenericRelation will have that relation ignored when
        copying.
        rQ   rR   r;   zpage-with-generic-relationTF)rX   rY   r¿  Úhas_unpublished_changesr[   )Úcontent_objectrY   z-2r¨  N)r   rI   r_   r`   r;   r<   r¡   r´  Úgeneric_relationr  r³  rY   rÀ   )rc   rd   Úoriginal_pageÚ	page_copyrL   rL   rM   Útest_page_with_generic_relationÅ  s   üÿÿz,TestCopyPage.test_page_with_generic_relationc                 C   sà   zkg d¢t _t jjdd}tjjdd}tjjdd}d|_||f|_| ¡  |j	dd	d
œd}|  
|jd¡ |  
|jd¡ |  
|j ¡ dd¡ |  
|j ¡ dd¡ |  
|j ¡ dd¡ |  
|j ¡ dd¡ W g t _dS g t _w )úVTest that a page will be copied with parental and child relations removed if excluded.©rø  r  Úsignup_linkrá   rR   rý  rþ  rÿ  ú%https://christmas-is-awesome.com/rsvprð  rñ  r¯  rì  rh   r¬   r   r   úHChild objects (parental many to many) were copied but should be excludedr´   úHChild objects defined on the original superclass were edited when copiedúEChild objects defined on the superclass were copied and should not beN)r2   Úexclude_fields_in_copyrI   r_   r0   r¡   r³  r  rM  r³  ra   r÷  rø  r  rL   rL   rM   Ú9test_copy_page_with_excluded_parental_and_child_relationsÙ  sL   

þÿÿýýýýzFTestCopyPage.test_copy_page_with_excluded_parental_and_child_relationsc                 C   sD   t ddd}|  t¡ | ¡  W d  ƒ dS 1 sw   Y  dS )z*Test that unsaved page will not be copied.ÚtestpurpÚtestpurpose)rY   rX   N)r>   rj   r”  r³  )rc   r˜  rL   rL   rM   Útest_copy_unsaved_page  s   
"ÿz#TestCopyPage.test_copy_unsaved_pagec                 C   st   t jjdd}|j tddd¡ | ¡  | ¡  ¡  |j	dddœd	}| ¡  ¡  |  
|j ¡ j|j ¡ j¡ d
S )zn
        Test that a page with orderables can be copied and the translation
        keys are updated.
        rá   rR   ÚSantaÚClaus©Ú
first_nameÚ	last_namezOrderable Pageztranslated-orderable-pager¯  rì  N)r2   rI   r_   rö  rv  r3   rM  r•  rŸ  r³  rµ  r  Útranslation_key)rc   rw   r˜  rL   rL   rM   Ú.test_copy_page_with_unique_uuids_in_orderables$  s&   þÿþÿ

þz;TestCopyPage.test_copy_page_with_unique_uuids_in_orderablesc              	      st   t jjdd}d‰ d‰‡ ‡fdd„}t |¡ z|jddd	œd
}|  ˆ ¡ |  ˆ|¡ W t |¡ dS t |¡ w )zDTest that copying of a published page emits a page_published signal.rá   rR   FNc                    s   d‰ |‰d S ©NTrL   ©Úsenderr\   r  ©Úsignal_firedÚsignal_pagerL   rM   Úpage_published_handlerG  s   zMTestCopyPage.test_copy_published_emits_signal.<locals>.page_published_handlerzNew christmasznew-christmasr¯  rì  )	r2   rI   r_   r#   Úconnectr³  rt   ra   Ú
disconnect)rc   rw   rÊ  Ú	copy_pagerL   rÇ  rM   Ú test_copy_published_emits_signal@  s   
ÿ
z-TestCopyPage.test_copy_published_emits_signalc              	      sn   t jjdd}d|_| ¡  d‰ ‡ fdd„}t |¡ z|jddid |  ˆ ¡ W t 	|¡ d	S t 	|¡ w )
zKTest that copying of an unpublished page not emits a page_published signal.rQ   rR   Fc                    ó   d‰ d S rÄ  rL   rÅ  ©rÈ  rL   rM   rÊ  `  ó   zSTestCopyPage.test_copy_unpublished_not_emits_signal.<locals>.page_published_handlerrY   Únew_slugrì  N)
r   rI   r_   r¿  rM  r#   rË  r³  rµ   rÌ  ©rc   rd   rÊ  rL   rÐ  rM   Ú&test_copy_unpublished_not_emits_signalX  s   
z3TestCopyPage.test_copy_unpublished_not_emits_signalc              	      sb   t jjdd}d‰ ‡ fdd„}zt |¡ |jdddid |  ˆ ¡ W t |¡ d	S t |¡ w )
zXTest that copying of a live page with keep_live=False not emits a page_published signal.rQ   rR   Fc                    rÏ  rÄ  rL   rÅ  rÐ  rL   rM   rÊ  q  rÑ  zWTestCopyPage.test_copy_keep_live_false_not_emits_signal.<locals>.page_published_handlerrY   rÒ  r°  N)r   rI   r_   r#   rË  r³  rµ   rÌ  rÓ  rL   rÐ  rM   Ú*test_copy_keep_live_false_not_emits_signall  s   
z7TestCopyPage.test_copy_keep_live_false_not_emits_signalc                 C   sr   t jjdd}|jdd}|jddid}|  |t ¡ |  |jd¡ |  |j	|j	¡ |  |j
d¡ |  |j¡ d S )	Nr™   rR   zabout-us-alias©Úupdate_slugrY   zabout-us-alias-copyrì  z/home/about-us-alias-copy/)r>   rI   r_   Úcreate_aliasr³  rÑ  ra   rY   rµ  r^   rS   rÀ   Úalias_of)rc   r·  Úabout_us_aliasÚabout_us_alias_copyrL   rL   rM   Útest_copy_alias_page}  s   ÿz!TestCopyPage.test_copy_alias_pagec                 C   sf   t jjdd}tdddd}|j|d tjj|dd	 |jd
ddœd}|  tjj	|d 
¡ ¡ dS )úMTest that view restrictions attached to a page are copied along with the pagerQ   rR   úChild Page 1úchild-page-1úhello child page 1rW   r[   rV   ©r€   ÚpasswordúChild Page 2úchild-page-2r¯  rì  ©r€   N)r   rI   r_   r>   r`   r   r¡   r³  rt   ru   rv   )rc   rd   Úchild_page_1Úchild_page_2rL   rL   rM   Ú!test_copy_page_copies_restriction  s   ÿÿz.TestCopyPage.test_copy_page_copies_restrictionc                 C   sœ   t jjdd}tdddd}|j|d tjj|dd	 td
ddd}|j|d tdddd}|j|d |j|dddœd}|  tjj	|d 
¡ ¡ dS )úSTest that view restrictions on a page's ancestor are NOT copied along with the pagerQ   rR   úParent 1úparent-1úhello parent 1rW   r[   rV   rá  úParent 2úparent-2úhello parent 2rÞ  rß  rà  rã  rä  r¯  r¨  rå  N©r   rI   r_   r>   r`   r   r¡   r³  rµ   ru   rv   ©rc   rd   Úorigin_parentÚdestination_parentræ  rç  rL   rL   rM   Ú5test_copy_page_does_not_copy_restrictions_from_parent   s&   ÿÿÿþzBTestCopyPage.test_copy_page_does_not_copy_restrictions_from_parentc                 C   s¬   t jjdd}tdddd}|j|d tdd	d
d}|j|d tjj|dd tdddd}|j|d tjj|dd |j|dddœd}|  tjj	|d 
¡ ¡ dS )ré  rQ   rR   rê  rë  rì  rW   r[   rí  rî  rï  rV   rá  rÞ  rß  rà  rã  rä  r¯  r¨  rå  Nrð  rñ  rL   rL   rM   ÚItest_copy_page_does_not_copy_restrictions_when_new_parent_has_one_already¼  s(   ÿÿÿþzVTestCopyPage.test_copy_page_does_not_copy_restrictions_when_new_parent_has_one_alreadyN)'r‹   rŒ   r   rŽ   rï  rû  r  r  r  r  r1  r6  r:  r<  r=  rG  rH  rK  rL  rR  rX  rb  r~  r‚  r‘  r™  rŸ  rª  r°  r¹  r¼  rÃ  rÎ  rÔ  rÕ  rÜ  rè  rô  rõ  rL   rL   rL   rM   rë    sJ    !#&+2) $!Erë  c                   @   s¶   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zejdd„ ƒZejd d!„ ƒZd"d#„ Zd$d%„ Zd&d'„ Zd(S ))ÚTestCreateAliasrP   c                 C   s†   t jjdd}d|_|jdgd |jdd}|  |t ¡ |  |jd¡ |  |jd¡ |  	|j
|j
¡ |  |jd	¡ |  |j|¡ d S )
Nr™   rR   zDraft titler„   rJ  r®  rÖ  zAbout usrí  )r>   rI   r_   r„   rM  rØ  rÑ  ra   rY   rµ  r^   rS   rÙ  rî  rL   rL   rM   Útest_create_aliasÝ  s   z!TestCreateAlias.test_create_aliasc                 C   sn   t jjdd}|jdd}|  |j ¡ dd¡ |  |j ¡ dd¡ |  |j ¡ dd¡ |  |j ¡ dd	¡ d S )
Nrá   rR   rñ  rÖ  r´   rò  ró  rô  rõ  )r2   rI   r_   rØ  ra   rö  r÷  rø  rù  rL   rL   rM   Ú&test_create_alias_copies_child_objectsø  s,   ÿÿýýýz6TestCreateAlias.test_create_alias_copies_child_objectsc                 C   s”   t jjdd}tjjdd}tjjdd}||f|_| ¡  |jdd}|  |j 	¡ dd	¡ |  |j 	¡ dd
¡ |  |j 
¡  ¡ |j 
¡  ¡ ¡ dS )rü  rá   rR   rý  rþ  rÿ  rñ  rÖ  r¬   r   r  N)r2   rI   r_   r0   r¡   r  rM  rØ  ra   r÷  r  r  r  rL   rL   rM   Ú+test_create_alias_copies_parental_relations	  s,   
ÿýýþz;TestCreateAlias.test_create_alias_copies_parental_relationsc                 C   s8   t jjdd}| ¡  |jdd}|  |j ¡ d¡ d S )Nrá   rR   rñ  rÖ  r   )r2   rI   r_   r•  rØ  ra   r&  r÷  rù  rL   rL   rM   Ú'test_create_alias_doesnt_copy_revisions<	  s   ÿz7TestCreateAlias.test_create_alias_doesnt_copy_revisionsc                 C   s>   t jjdd}|jdd}|  |t¡ |  |j ¡ dd¡ d S )Nrá   rR   rñ  rÖ  r´   rò  )	r   rI   r_   rØ  rÑ  r2   ra   rö  r÷  rù  rL   rL   rM   Ú=test_create_alias_copies_child_objects_with_nonspecific_classH	  s   ÿÿzMTestCreateAlias.test_create_alias_copies_child_objects_with_nonspecific_classc                 C   s|   t jjdd}|jddd}| ¡ jdd ¡ }| ¡ jdd ¡ }|  |d¡ |  |d	¡ |  |j	d
¡ |  |j
|¡ d S )Nr˜   rR   Tr?  ©r  r×  rs   r~  rA  rB  rC  )r1   rI   r_   rØ  r‚  ru   r  r´  ra   rS   rÙ  rD  rL   rL   rM   Ú$test_create_alias_copies_recursivelyY	  s    ÿÿÿÿÿz4TestCreateAlias.test_create_alias_copies_recursivelyc                 C   st   t jjdd}|jddd}| ¡ jdd ¡ }| ¡ jdd ¡ }|  |jj	 
¡ dd	¡ |  |jj	 
¡ dd
¡ d S )Nr˜   rR   Tr?  rü  rs   r~  r´   rò  ró  )r1   rI   r_   rØ  r‚  ru   r  ra   r¸   rö  r÷  rD  rL   rL   rM   Ú7test_create_alias_copies_recursively_with_child_objectsw	  s$   ÿÿÿ
ý
ýzGTestCreateAlias.test_create_alias_copies_recursively_with_child_objectsc                 C   sz   t jjdd}| ¡ jdd ¡ j}| ¡  |  t	¡}|j
d|d W d   ƒ n1 s-w   Y  |  t|jƒd¡ d S )Nr˜   rR   rs   r~  T)r  r*  rN  )r1   rI   r_   r‚  ru   r  r¸   r•  rj   rO  rØ  ra   rP  r–  rQ  rL   rL   rM   Ú:test_create_alias_doesnt_copy_recursively_to_the_same_tree•	  s   ÿÿþzJTestCreateAlias.test_create_alias_doesnt_copy_recursively_to_the_same_treec                 C   sF   t ƒ jjdd}tjjdd}| ¡  |jd|d}|  |j|¡ d S )NrS  rT  rá   rR   rñ  )r×  r  )r   rI   r_   r2   r•  rØ  ra   r  rV  rL   rL   rM   Útest_create_alias_updates_user¤	  s   ÿÿz.TestCreateAlias.test_create_alias_updates_userc                 C   s´   t jjdd}|jdd}|  |t ¡ |  |j|j¡ |  |j|j¡ |  |j	j|j	j¡ |  |j	j
j|j	j
j¡ |  |jd¡ |  tjj|jdt¡ |  tjj|jdt¡ d S )NrY  rR   rZ  rÖ  r[  r]   )r@   rI   r_   rØ  rÑ  ra   r\  rµ  r^   r]  r^  rS   r2   r   r_  rL   rL   rM   Ú)test_create_alias_multi_table_inheritance³	  s0   ÿÿþþÿÿz9TestCreateAlias.test_create_alias_multi_table_inheritancec                    rc  )Nr˜   rR   rd  re  r¯  rf  rg  r[   c                 S   rh  rL   r]   ri  rL   rL   rM   rk  ß	  rl  zATestCreateAlias.test_create_alias_copies_tags.<locals>.<listcomp>r¬   rQ   ©r*  c                 S   rh  rL   r]   ri  rL   rL   rM   rk  ë	  rl  c                 3   rn  rH   rL   ro  rq  rL   rM   rs  ñ	  rt  z@TestCreateAlias.test_create_alias_copies_tags.<locals>.<genexpr>)r   rI   r_   rE   ru  rv  r`   r•  rŸ  rw  r  ra   rx  rt   rØ  rµ  r^   ry  rL   rq  rM   Útest_create_alias_copies_tags×	  r  z-TestCreateAlias.test_create_alias_copies_tagsc                 C   rƒ  )Nr˜   rR   r„  rþ  r…  r†  r‡  rˆ  r‰  r¯  r[   rŠ  rQ   r  )r   rI   r_   r'   r¡   r%   r5   r`   rŒ  rv  r(   r•  rŸ  rØ  rµ  r^   r  rL   rL   rM   Ú$test_create_alias_with_m2m_relationsô	  r’  z4TestCreateAlias.test_create_alias_with_m2m_relationsc                 C   r“  )Nr˜   rR   r…  r†  r‡  r”  r•  r¯  r[   rQ   r  )r   rI   r_   r%   r¡   r4   r–  r`   r•  rŸ  rØ  rµ  r^   ra   r—  rL   rL   rM   Ú*test_create_alias_with_generic_foreign_key
  rš  z:TestCreateAlias.test_create_alias_with_generic_foreign_keyc                 C   r›  )	Nr˜   rR   rœ  r  r¯  r[   rQ   r  )r   rI   r_   r9   r`   rØ  rµ  r^   rž  rL   rL   rM   Ú#test_create_alias_with_o2o_relation
  r   z3TestCreateAlias.test_create_alias_with_o2o_relationc                 C   sx   t jjdd}|jtdddddd}|j|d	d
}|  |j|j¡ |  |j	|j	¡ |  |j
|j
¡ |  |j|j¡ d S )NrQ   rR   r¡  r¢  r£  r¤  r¥  r[   r§  ©r*  r×  )r   rI   r_   r`   r:   rØ  ra   rX   rµ  r^   r¯   r¦  )rc   rd   r€   r˜  rL   rL   rM   Ú1test_create_alias_with_additional_excluded_fields+
  s   üÿzATestCreateAlias.test_create_alias_with_additional_excluded_fieldsc                 C   sÚ   zhg d¢t _t jjdd}tjjdd}tjjdd}d|_||f|_| ¡  |j	dd	}|  
|jd¡ |  
|jd
¡ |  
|j ¡ dd¡ |  
|j ¡ dd¡ |  
|j ¡ dd¡ |  
|j ¡ dd¡ W g t _dS g t _w )r±  r²  rá   rR   rý  rþ  rÿ  r´  rñ  rÖ  rh   r¬   r   r   rµ  r´   r¶  r·  N)r2   r¸  rI   r_   r0   r¡   r³  r  rM  rØ  ra   r÷  rø  r  rL   rL   rM   Ú<test_create_alias_with_excluded_parental_and_child_relations>
  sH   

ÿÿýýýýzLTestCreateAlias.test_create_alias_with_excluded_parental_and_child_relationsc                 C   s’   t jjdd}tdddd}|j|d tjjdd	}tjj|tjd
}|j	 
|¡ |jdd}tjj|d}|  t|j	jdddƒ|jg¡ dS )rÝ  rQ   rR   rÞ  rß  rà  rW   r[   z
Test Grouprþ  )r€   Úrestriction_typerä  rÖ  rå  r^   Tr"  N)r   rI   r_   r>   r`   r   r¡   r   ÚGROUPSÚgroupsrv  rØ  ra   Úlistr*  r!  )rc   rd   ræ  ÚgroupÚrestrictionrç  Úcopied_restrictionrL   rL   rM   Ú"test_alias_page_copies_restriction
  s   ÿÿÿz2TestCreateAlias.test_alias_page_copies_restrictionc                 C   s–   t jjdd}tdddd}|j|d tjj|dd	 td
ddd}|j|d tdddd}|j|d |j|dd}|  tjj	|d 
¡ ¡ dS )ré  rQ   rR   rê  rë  rì  rW   r[   rV   rá  rí  rî  rï  rÞ  rß  rà  rä  r  rå  N©r   rI   r_   r>   r`   r   r¡   rØ  rµ   ru   rv   rñ  rL   rL   rM   Ú6test_alias_page_does_not_copy_restrictions_from_parentš
  s&   ÿÿÿþzFTestCreateAlias.test_alias_page_does_not_copy_restrictions_from_parentc                 C   s¦   t jjdd}tdddd}|j|d tdd	d
d}|j|d tjj|dd tdddd}|j|d tjj|dd |j|dd}|  tjj	|d 
¡ ¡ dS )ré  rQ   rR   rê  rë  rì  rW   r[   rí  rî  rï  rV   rá  rÞ  rß  rà  rä  r  rå  Nr  rñ  rL   rL   rM   ÚJtest_alias_page_does_not_copy_restrictions_when_new_parent_has_one_already¶
  s(   ÿÿÿþzZTestCreateAlias.test_alias_page_does_not_copy_restrictions_when_new_parent_has_one_alreadyN)r‹   rŒ   r   rŽ   r÷  rø  rù  rú  rû  rý  rþ  rÿ  r   r  r  r  r  r  ÚunittestÚexpectedFailurer  r	  r  r  r  rL   rL   rL   rM   rö  Ú  s.    !#$

Brö  c                   @   ó"   e Zd ZdgZdd„ Zdd„ ZdS )ÚTestUpdateAliasesrP   c                 C   sX  t jjdd}|jdd}|jdd}d|_d|_|j tdd	d
¡ | 	¡  | 
¡  | 
¡  |  |jd¡ |  |jd¡ |  |j ¡ d¡ |  |j ¡ d¡ tj ¡  ¡  | ¡  | 
¡  | 
¡  |  |jd¡ |  |jd¡ |  |j ¡ d¡ |  |j ¡ d¡ |  |jd¡ |  |jd¡ |  tjj|dd ¡ ¡ |  tjj|dd ¡ ¡ d S )Nrá   rR   únew-event-pagerÖ  únew-event-page-2zUpdated titlezA different draft titleÚTedÚCrillyr¿  rr   r´   r¬   úwagtail.publish©r€   Úaction)r2   rI   r_   rØ  rX   r„   rö  rv  r3   rM  r   ra   r÷  r   r  ÚdeleteÚupdate_aliasesrµ   ru   rv   ©rc   rj  ÚaliasÚalias_aliasrL   rL   rM   Útest_update_aliasesÙ
  sJ   þÿÿÿýz%TestUpdateAliases.test_update_aliasesc                 C   s  t jjdd}d|_d|_|jdd |jdd}|jdd}|  |j¡ |  |j¡ d|_d|_|jdd | ¡  | ¡  |  |j¡ |  |j¡ t	j 
¡  ¡  | ¡  | ¡  | ¡  |  |j¡ |  |j¡ |  t	jj|d	d
 ¡ ¡ |  t	jj|d	d
 ¡ ¡ d S )Nrá   rR   FT©Úcleanr  rÖ  r  r  r  )r2   rI   r_   r¿  r«  rM  rØ  rµ   r   r   r  r   r!  rt   ru   rv   r"  rL   rL   rM   Ú$test_update_aliases_publishes_drafts  s<   ÿÿýz6TestUpdateAliases.test_update_aliases_publishes_draftsN)r‹   rŒ   r   rŽ   r%  r(  rL   rL   rL   rM   r  Ö
  s    2r  c                   @   sR   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚTestCopyForTranslationrP   c                 C   sR   t jjddj| _tjjdd| _tjjdd| _| j 	¡ | _
tjjdd| _d S )NrQ   rR   r˜   rá   r2  rE  )r   rI   r_   r¸   Úen_homepager1   Úen_eventindexr2   Úen_eventpager)  rœ   r   r¡   rN  r>  rL   rL   rM   r©   <  s
   zTestCopyForTranslation.setUpc                 C   s¸   | j  | j¡}|  | j j|j¡ |  |j| j¡ |  |j| j j¡ |  |jd¡ |  	|j
¡ |  |j¡ tjjdd}|  |jd d d¡ |  |jd d d d	¡ |  |jd
¡ d S )Núhome-frúwagtail.copy_for_translation©r  Úsource_localerF  r,  r€   Úlocaler2  z*Copied for translation from Root (English))r*  rL  rN  rµ  r^   ra   r1  rÂ  rY   rµ   r¿  rt   r«  r   rI   r_   ÚdataÚmessage)rc   rO  Ú	log_entryrL   rL   rM   Útest_copy_homepageC  s   ÿz)TestCopyForTranslation.test_copy_homepagec                 C   s8   | j jtddddd | j | j¡}|  |jd¡ d S )NzOld french homepager-  zTest contentrW   r[   z	home-fr-1)rœ   r`   r>   r*  rL  rN  ra   rY   )rc   rO  rL   rL   rM   Útest_copy_homepage_slug_existsY  s   ÿÿz5TestCopyForTranslation.test_copy_homepage_slug_existsc                 C   sÔ   | j jtdd| j| jjdd}| j | j¡}|  | jj	|j	¡ |  
|j| j¡ |  
|j| jj¡ |  
| ¡ |¡ |  
| jj|j¡ tjjdd}|  
|jd d d	¡ |  
|jd
 d d d¡ |  
|jd¡ d S )Núfrench homepager-  ©rX   rY   r1  rÂ  r[   r.  r/  r0  rF  r,  r€   r1  r2  zGCopied for translation from Welcome to the Wagtail test site! (English))rœ   r`   r   rN  r*  rÂ  r+  rL  rµ  r^   ra   r1  r)  rY   r   rI   r_   r2  r3  )rc   rO  Úfr_eventindexr4  rL   rL   rM   Útest_copy_childpagee  s.   üÿ	
ÿþz*TestCopyForTranslation.test_copy_childpagec                 C   s>   |   t¡ | j | j¡ W d   ƒ d S 1 sw   Y  d S rH   )rj   r   r+  rL  rN  r>  rL   rL   rM   Ú"test_copy_childpage_without_parent‡  s   "ÿz9TestCopyForTranslation.test_copy_childpage_without_parentc                 C   s¦   | j j| jdd}|  | j j|j¡ |  |j| j¡ |  |j| j j¡ |  | j j|j¡ | 	¡ }|  | j
j|j¡ |  |j| j¡ |  |j| j
j¡ |  |jd¡ d S )NTrG  r-  )r+  rL  rN  rµ  r^   ra   r1  rÂ  rY   r)  r*  )rc   r9  rO  rL   rL   rM   Ú%test_copy_childpage_with_copy_parents  s   ÿ
ÿz<TestCopyForTranslation.test_copy_childpage_with_copy_parentsc                 C   sœ   | j jtdd| j| jjdd}|jtdd| j| jjdd | jj	 
¡ }| j | j¡}|j	 
¡ }|  |j| j¡ |  |j|j¡ |  t| ¡ ƒ|g¡ d S )Nr7  r-  r8  r[   rm   rp   )rœ   r`   r   rN  r*  rÂ  r1   r+  r,  rö  r_   rL  ra   r1  r  Úget_translations)rc   rO  Ú
en_speakerÚfr_eventpageÚ
fr_speakerrL   rL   rM   Ú.test_copy_page_with_translatable_child_objects¢  s,   üÿ	üÿ
zETestCopyForTranslation.test_copy_page_with_translatable_child_objectsc                 C   sP   | j j| jdd}| ¡ }|  |j| j¡ |  |j| jj¡ |  |j| j¡ d S )NTrG  )	r,  rL  rN  r)  ra   r1  rÂ  r+  rÙ  )rc   r?  r9  rL   rL   rM   Ú&test_copies_missing_parents_as_aliasesÌ  s   ÿ
ÿz=TestCopyForTranslation.test_copies_missing_parents_as_aliasesN)r‹   rŒ   r   rŽ   r©   r5  r6  r:  r;  r<  rA  rB  rL   rL   rL   rM   r)  9  s    "*r)  c                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚTestSubpageTypeBusinessRulesc                 C   s„   |   tt ¡ ¡ |   tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |   tt ¡ ¡ d S rH   )ÚassertInr>   Úallowed_subpage_modelsr*   ÚassertNotInr,   r)   r>  rL   rL   rM   Útest_allowed_subpage_modelsÝ  s   z8TestSubpageTypeBusinessRules.test_allowed_subpage_modelsc                 C   sd   |   tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |  tt ¡ ¡ |   tt ¡ ¡ d S rH   )	rD  r>   Úallowed_parent_page_modelsrF  r)   r+   rB   r,   r*   r>  rL   rL   rM   Útest_allowed_parent_page_modelsï  s   ÿz<TestSubpageTypeBusinessRules.test_allowed_parent_page_modelsc                 C   s¦   |   t tƒ ¡¡ |   t tƒ ¡¡ |  t tƒ ¡¡ |   t tƒ ¡¡ |   t tƒ ¡¡ |   t tƒ ¡¡ |  t tƒ ¡¡ |  t tƒ ¡¡ |  t tƒ ¡¡ d S rH   )	rt   r>   Úcan_exist_underrB   r   rµ   r,   r*   r)   r>  rL   rL   rM   Útest_can_exist_under   s   z1TestSubpageTypeBusinessRules.test_can_exist_underc                 C   s¦   |   t tƒ ¡¡ |  t tƒ ¡¡ |  t tƒ ¡¡ |   t tƒ ¡¡ |  t tƒ ¡¡ |  t tƒ ¡¡ |  t tƒ ¡¡ |   t tƒ ¡¡ |   t tƒ ¡¡ d S rH   )	rµ   r   Úcan_create_atrt   r>   rB   r,   r*   r)   r>  rL   rL   rM   Útest_can_create_at  s   z/TestSubpageTypeBusinessRules.test_can_create_atc                 C   s~   t jjdd}|jtdddd}|jtdddd}|  t |¡¡ |jtdd	dd |  t |¡¡ |  t |¡¡ d S )
NrQ   rR   zsimple parentzsimple-parentr¯  r[   zsimple-parent-2zsimple childzsimple-child)	r   rI   r_   r`   r?   rt   r=   rL  rµ   )rc   rœ   Úparent1Úparent2rL   rL   rM   Ú;test_can_create_at_with_max_count_per_parent_limited_to_one#  s   
ÿ
ÿ
ÿzXTestSubpageTypeBusinessRules.test_can_create_at_with_max_count_per_parent_limited_to_onec                 C   s¤   |   tƒ  tƒ ¡¡ |   tƒ  tƒ ¡¡ |  tƒ  tƒ ¡¡ |   tƒ  tƒ ¡¡ |   tƒ  tƒ ¡¡ |   tƒ  tƒ ¡¡ |  tƒ  tƒ ¡¡ |  tƒ  tƒ ¡¡ d S rH   )	rt   r>   Úcan_move_torB   r   rµ   r,   r*   r)   r>  rL   rL   rM   Útest_can_move_to:  s   z-TestSubpageTypeBusinessRules.test_can_move_toc                 C   sF   t jjdd}|  t |¡¡ |jtdddd |  t |¡¡ d S )NrQ   rR   Ú	singletonr¯  r[   )r   rI   r_   rt   rA   rL  r`   rµ   ©rc   rœ   rL   rL   rM   Útest_singleton_page_creationI  s   z9TestSubpageTypeBusinessRules.test_singleton_page_creationN)
r‹   rŒ   r   rG  rI  rK  rM  rP  rR  rU  rL   rL   rL   rM   rC  Ü  s    rC  c                   @   ó   e Zd ZdZdgZdd„ ZdS )ÚTestIssue735z~
    Issue 735 reports that URL paths of child pages are not
    updated correctly when slugs of parent pages are updated
    rP   c                 C   sR   t jjddj}tjjdd}d|_| ¡  ¡  tjj|jd}|  	|j
d¡ d S )Nr˜   rR   rá   z
old-eventsr]   z/home/old-events/christmas/)r   rI   r_   r¸   r2   rY   r•  rŸ  r^   ra   rS   )rc   rz  r‹  rú  rL   rL   rM   Ú)test_child_urls_updated_on_parent_publish^  s   z6TestIssue735.test_child_urls_updated_on_parent_publishN)r‹   rŒ   r   Ú__doc__rŽ   rX  rL   rL   rL   rM   rW  V  s    rW  c                   @   s   e Zd ZdZdd„ ZdS )ÚTestIssue756z
    Issue 756 reports that the latest_revision_created_at
    field was getting clobbered whenever a revision was published
    c                 C   sJ   t jjdd ¡ }|  t jjddj¡ | ¡  |  t jjddj¡ d S )Nr´   r]   )r   rI   r_   r•  r´  Úlatest_revision_created_atrŸ  )rc   r©  rL   rL   rM   Ú>test_publish_revision_doesnt_remove_latest_revision_created_atq  s   zKTestIssue756.test_publish_revision_doesnt_remove_latest_revision_created_atN)r‹   rŒ   r   rY  r\  rL   rL   rL   rM   rZ  k  s    rZ  c                   @   rV  )ÚTestIssue1216zG
    Test that url paths greater than 255 characters are supported
    rP   c                 C   s‚   t jjddj}tjjddj}dd }||_| ¡  ¡  dd }||_| ¡  ¡  tjj|jd}d 	||¡}|  
|j|¡ d S )	Nr˜   rR   rá   zchristmas-%s-christmasÚÈ01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789zevents-%s-eventsr]   z/home/{}/{}/)r   rI   r_   r¸   r2   rY   r•  rŸ  r^   rÔ   ra   rS   )rc   rz  r‹  Únew_christmas_slugÚnew_event_index_slugrú  Úexpected_url_pathrL   rL   rM   Ú'test_url_path_can_exceed_255_characters†  s"   ÿþÿz5TestIssue1216.test_url_path_can_exceed_255_charactersN)r‹   rŒ   r   rY  rŽ   rb  rL   rL   rL   rM   r]    ó    r]  c                   @   ó,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTestIsCreatablec                 C   ó   |   tj¡ |  ttƒ ¡ dS )z%By default, pages should be creatableN)rt   r>   Úis_creatablerD  r!   r>  rL   rL   rM   Útest_is_creatable_default   s   z)TestIsCreatable.test_is_creatable_defaultc                 C   rf  )z3Page types should be able to disable their creationN)rµ   r6   rg  rD  r!   r>  rL   rL   rM   Útest_is_creatable_false¥  s   z'TestIsCreatable.test_is_creatable_falsec                 C   rf  )z„
        is_creatable should not be inherited in the normal manner, and should
        default to True unless set otherwise
        N)rt   r7   rg  rD  r!   r>  rL   rL   rM   Útest_is_creatable_not_inherited«  s   z/TestIsCreatable.test_is_creatable_not_inheritedc                 C   rf  )z9
        Abstract models should not be creatable
        N)rµ   r$   rg  rF  r!   r>  rL   rL   rM   Útest_abstract_pages³  s   z#TestIsCreatable.test_abstract_pagesN)r‹   rŒ   r   rh  ri  rj  rk  rL   rL   rL   rM   re  Ÿ  s
    re  c                   @   s   e Zd Zdd„ ZdS )ÚTestDeferredPageClassesc                 C   s2   t tj d¡ƒ dd„ tƒ D ƒ}|  |tg¡ dS )zò
        In Django <1.10, a call to `defer` such as `SimplePage.objects.defer('content')`
        will dynamically create a subclass of SimplePage. Ensure that these subclasses
        are not registered in the get_page_models() list
        rZ   c                 S   s   g | ]	}t |tƒr|‘qS rL   )Ú
issubclassr>   )r$  ÚclsrL   rL   rM   rk  Ã  s
    
ÿÿzYTestDeferredPageClasses.test_deferred_page_classes_are_not_registered.<locals>.<listcomp>N)r  r>   rI   Údeferr!   ra   )rc   Úsimplepage_subclassesrL   rL   rM   Ú-test_deferred_page_classes_are_not_registered¼  s
   ÿzETestDeferredPageClasses.test_deferred_page_classes_are_not_registeredN)r‹   rŒ   r   rq  rL   rL   rL   rM   rl  »  s    rl  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestPageManagerc                 C   ó   |   ttjƒt¡ dS )z=
        Assert that the Page class uses PageManager
        N)r¹   Útyper   rI   r   r>  rL   rL   rM   Útest_page_managerÊ  s   z!TestPageManager.test_page_managerc                 C   rs  )z¸
        Assert that Page subclasses get a PageManager without having to do
        anything special. MTI subclasses do *not* inherit their parents Manager
        by default.
        N)r¹   rt  r>   rI   r   r>  rL   rL   rM   Útest_page_subclass_managerÐ  ó   z*TestPageManager.test_page_subclass_managerc                 C   rs  )zÓ
        Subclasses should be able to override their default Manager, and
        Wagtail should respect this. It is up to the developer to ensure their
        custom Manager inherits from PageManager.
        N)r¹   rt  r.   rI   r-   r>  rL   rL   rM   Útest_custom_page_managerØ  rw  z(TestPageManager.test_custom_page_managerc                 C   sd   |   ttj ¡ ƒt¡ |   ttj ¡ ƒt¡ |   ttj ¡  ¡ ƒt¡ |   ttj ¡  ¡ ƒt¡ dS )z³
        Managers that are constructed from a custom PageQuerySet
        (via PageManager.from_queryset(CustomPageQuerySet)) should return
        querysets of that type
        N)r¹   rt  r.   rI   r  r/   Ú
about_spamr>  rL   rL   rM   Útest_custom_page_querysetà  s   ÿÿz)TestPageManager.test_custom_page_querysetc                 C   rs  )zÞ
        Abstract base classes should be able to override their default Manager,
        and Wagtail should respect this. It is up to the developer to ensure
        their custom Manager inherits from PageManager.
        N)r¹   rt  r8   rI   r-   r>  rL   rL   rM   Útest_abstract_base_page_managerï  rw  z/TestPageManager.test_abstract_base_page_managerN)r‹   rŒ   r   ru  rv  rx  rz  r{  rL   rL   rL   rM   rr  É  s    rr  c                   @   rV  )ÚTestIssue2024zP
    This tests that deleting a content type can't delete any Page objects.
    rP   c                 C   sD   t jjdd}|j}| ¡  t jjdd}|  |jtj t ¡¡ d S )Nr˜   rR   )r   rI   r_   Úcontent_typer   ra   r   rJ   )rc   rz  Úevent_index_content_typerL   rL   rM   Útest_delete_content_typeÿ  s   ÿz&TestIssue2024.test_delete_content_typeN)r‹   rŒ   r   rY  rŽ   r  rL   rL   rL   rM   r|  ø  rc  r|  c                   @   sb   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zed
gddd„ ƒZ	edgddd„ ƒZ
dd„ ZdS )ÚTestMakePreviewRequestrP   c                 C   s(  t jjdd}| ¡ }|  |jd¡ |jd }|  |jd¡ |  |jd d¡ |  |j	d d	¡ |  |j	d
 d¡ |  |j	d d¡ |  |j	d d¡ |  |j	d d¡ |  |j	d d¡ |  |j	d d¡ |  |j	d d¡ |  
d|j	¡ |  
d|j	¡ |  
d|j	¡ |  
d|j	¡ |  
d|j	¡ d S )Nr˜   rR   r	  r±   rm  Úhostr   ÚREQUEST_METHODÚGETÚSCRIPT_NAMErh   Ú	PATH_INFOÚSERVER_NAMErÎ   éP   ÚSERVER_PROTOCOLúHTTP/1.1úwsgi.version©r´   r   úwsgi.url_schemeÚhttpú
wsgi.inputúwsgi.errorsúwsgi.multithreadúwsgi.multiprocessúwsgi.run_once)r   rI   r_   Úmake_preview_requestra   r  r  r¯   ÚheadersrË   rD  ©rc   rz  r  r±   rL   rL   rM   Ú-test_make_preview_request_for_accessible_page  s&   
zDTestMakePreviewRequest.test_make_preview_request_for_accessible_pagec                 C   s6  t jjdd tjjdd}| ¡ }|  |jd¡ |jd }|  |j	d¡ |  |j
d d	¡ |  |jd
 d¡ |  |jd d¡ |  |jd d¡ |  |jd d	¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  d|j¡ |  d|j¡ |  d|j¡ |  d|j¡ |  d|j¡ d S )Ni»  ©rž   r˜   rR   r	  r±   rm  r  r   r‚  rƒ  r„  rh   r…  r†  rÎ   rˆ  r‰  rŠ  r‹  rŒ  ÚhttpsrŽ  r  r  r‘  r’  ©r   rI   rˆ   r   r_   r“  ra   r  r  r¯   r”  rË   rD  r•  rL   rL   rM   Ú3test_make_preview_request_for_accessible_page_https+  ó(   
zJTestMakePreviewRequest.test_make_preview_request_for_accessible_page_httpsc                 C   s6  t jjdd tjjdd}| ¡ }|  |jd¡ |jd }|  |j	d¡ |  |j
d d	¡ |  |jd
 d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  d|j¡ |  d|j¡ |  d|j¡ |  d|j¡ |  d|j¡ d S )Ni¸"  r—  r˜   rR   r	  r±   rm  r  zlocalhost:8888r‚  rƒ  r„  rh   r…  r†  r   rÎ   rˆ  r‰  rŠ  r‹  rŒ  r  rŽ  r  r  r‘  r’  r™  r•  rL   rL   rM   Ú?test_make_preview_request_for_accessible_page_non_standard_portF  r›  zVTestMakePreviewRequest.test_make_preview_request_for_accessible_page_non_standard_portc                 C   sª  t jjdd}ddddddœ}td)i |¤Ž}| d¡}| |¡}|  |jd	¡ |jd
 }|  |jd |jd ¡ |  |j	d |jd ¡ |  |j	d |jd ¡ |  |j	d |jd ¡ |  |j	d |jd ¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd d¡ |  |jd  d!¡ |  |jd" d#¡ |  
d$|j¡ |  
d%|j¡ |  
d&|j¡ |  
d'|j¡ |  
d(|j¡ d S )*Nr˜   rR   z192.168.0.1z192.168.0.2,192.168.0.3ztest=1;blah=2z
Test AgentzBasic V2FndGFpbDpXYWd0YWlsCg==)ÚREMOTE_ADDRÚHTTP_X_FORWARDED_FORÚHTTP_COOKIErv  ÚHTTP_AUTHORIZATIONr	  r±   r  zx-forwarded-forrž  ÚcookierŸ  z
user-agentrv  Úauthorizationr   r‚  rƒ  r„  rh   r…  rm  r†  r   rÎ   r‡  rˆ  r‰  rŠ  r‹  rŒ  r  rŽ  r  r  r‘  r’  rL   )r   rI   r_   r   r“  ra   r  r  rË   r”  rD  )rc   rz  Úoriginal_headersÚfactoryÚoriginal_requestr  r±   rL   rL   rM   ÚCtest_make_preview_request_for_accessible_page_with_original_requesta  sT   û


ÿþÿÿþzZTestMakePreviewRequest.test_make_preview_request_for_accessible_page_with_original_requestúproduction.example.comr“   c                 C   sD   t jjdd}| ¡ }|  |jd¡ |jd }|  |jd d¡ d S )Nrã   rR   r	  r±   r  r§  )r   rI   r_   r“  ra   r  r  r”  ©rc   rœ   r  r±   rL   rL   rM   ÚEtest_make_preview_request_for_inaccessible_page_should_use_valid_host’  s
   
z\TestMakePreviewRequest.test_make_preview_request_for_inaccessible_page_should_use_valid_hostÚ*c                 C   sD   t jjdd}| ¡ }|  |jd¡ |jd }|  |jd d¡ d S )Nrã   rR   r	  r±   r  rª  )	r   rI   r_   r“  ra   r  r  rµ  r”  r¨  rL   rL   rM   ÚKtest_make_preview_request_for_inaccessible_page_with_wildcard_allowed_hostsž  s
   
zbTestMakePreviewRequest.test_make_preview_request_for_inaccessible_page_with_wildcard_allowed_hostsc                 C   sæ   t jjdd}tddgd}|j|d t jj|jd}|  d¡ |  | ¡ ¡ W d   ƒ n1 s3w   Y  |  d	¡ |  | ¡ ¡ W d   ƒ n1 sOw   Y  |  d¡ |  	| ¡ ¡ W d   ƒ d S 1 slw   Y  d S )
Nr˜   rR   zstream page)r
  rV   )rX   Úbodyr[   r]   r   r´   )
r   rI   r_   rC   r`   r^   r­   rµ   Úis_previewablert   )rc   rz  Ústream_pageÚplain_stream_pagerL   rL   rM   Útest_is_previewableª  s   ÿÿ"ÿz*TestMakePreviewRequest.test_is_previewableN)r‹   rŒ   r   rŽ   r–  rš  rœ  r¦  r   r©  r«  r°  rL   rL   rL   rM   r€    s    
1


r€  c                   @   s&   e Zd ZdZdgZdd„ Zdd„ ZdS )ÚTestShowInMenusDefaultOptionzQ
    This tests that a page model can define the default for 'show_in_menus'
    rP   c                 C   ó   t ddd}|  |j¡ d S ©NzMy Awesome Pagezmy-awesome-pager¯  )r   rµ   Úshow_in_menusr   rL   rL   rM   Útest_show_in_menus_defaultÆ  ó   z7TestShowInMenusDefaultOption.test_show_in_menus_defaultc                 C   r²  r³  )r&   rt   r´  r   rL   rL   rM   Ú#test_show_in_menus_default_overrideÍ  r¶  z@TestShowInMenusDefaultOption.test_show_in_menus_default_overrideN)r‹   rŒ   r   rY  rŽ   rµ  r·  rL   rL   rL   rM   r±  ¿  s
    r±  c                   @   rx  )ÚTestPageWithContentJSONrP   c                 C   s&  t jjdd}tj t¡}| ¡ }|jd"i dd“dd“dd“dd	“d
|jd “d|j	d “d|j
d “d|jd “dd“dd“dd“d|j “dd“dd“dd“d|j “d|j“d|j “dd“Ž | |¡}dD ]}|  t||ƒt||ƒ¡ qjd D ]}|  t||ƒt||ƒ¡ q{|  |jd!¡ d S )#Nr™   rR   rX   z
About themr„   rY   z
about-themrS   z/home/some-section/about-them/r!  rÅ  Únumchildr  r¯   ÚABCDEFrZ   z<p>They are not as good</p>r¦  z2000-01-01T00:00:00Zr£  r¿  ÚlockedTÚ	locked_byr´   Ú	locked_atr«  r}  r´  r  )rX   rY   rZ   rS   r´  )r!  r¯   r  r¹  r}  r„   r¿  r«  r  r»  r¼  r½  r[  r¦  z/home/about-them/rL   )r>   rI   r_   r   rJ   r2   Úserializable_datarˆ   r!  r¹  r  r¯   r¿  r«  r^   r´  Úwith_content_jsonrµ  rÓ  ra   rS   )rc   r®  Úeventpage_content_typerZ   Úupdated_pageÚ	attr_namerL   rL   rM   Ú'test_with_content_json_preserves_valuesØ  sh   
ÿþýü
û
ú
ù
ø	÷
öõôóòñðïîí
ÿÿz?TestPageWithContentJSON.test_with_content_json_preserves_valuesN)r‹   rŒ   r   rŽ   rÃ  rL   rL   rL   rM   r¸  Õ  r†  r¸  c                   @   r  )ÚTestUnpublishrP   c                 C   s<   t jjdd}|jtddddd}|jdd	 | ¡  d S )
Nr´   r]   ÚHomepageÚhome2rV   rW   r[   Fr&  )r   rI   r_   r`   r>   rM  r«  )rc   rœ   Ú	home_pagerL   rL   rM   Ú1test_unpublish_doesnt_call_full_clean_before_save  s   ÿz?TestUnpublish.test_unpublish_doesnt_call_full_clean_before_savec                 C   sÌ   t jjdd}|jdd}|jdd}|  |j¡ |  |j¡ |  |j¡ tj ¡  ¡  | 	¡  | 
¡  | 
¡  |  |j¡ |  |j¡ |  |j¡ |  tjj|dd ¡ ¡ |  tjj|dd ¡ ¡ d S )Nrá   rR   r  rÖ  r  zwagtail.unpublishr  )r2   rI   r_   rØ  rt   r¿  r   r  r   r«  r   rµ   ru   rv   r"  rL   rL   rM   Ú'test_unpublish_also_unpublishes_aliases&  s,   ÿÿýz5TestUnpublish.test_unpublish_also_unpublishes_aliasesN)r‹   rŒ   r   rŽ   rÈ  rÉ  rL   rL   rL   rM   rÄ    s    
rÄ  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestCachedContentTypez"Tests for Page.cached_content_typec                 C   s4   t j ¡ }|jtddddd| _tj t¡| _d S ©NÚTest1Útest1r	  rW   r[   )	r   rI   r  r`   r>   r€   r   rJ   Úspecific_page_ctyperT  rL   rL   rM   r©   H  s
   
ÿzTestCachedContentType.setUpc                 C   sP   |   d¡ | jj}W d  ƒ n1 sw   Y  |  |tjj| jjd¡ dS )zà
        The return value should match the value you'd get
        if fetching the ContentType from the database,
        and shouldn't trigger any database queries when
        the ContentType is already in memory.
        r   Nr]   )r­   r€   Úcached_content_typera   r   rI   r_   Úcontent_type_idrÜ  rL   rL   rM   Útest_golden_pathO  s   
ÿz&TestCachedContentType.test_golden_pathN)r‹   rŒ   r   rY  r©   rÑ  rL   rL   rL   rM   rÊ  E  s    rÊ  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestGetTranslatableModelsc                 C   sF   t ƒ }|  t|¡ |  t|¡ |  t|¡ |  t|¡ |  t|¡ d S rH   )r"   rF  r2   rD  r   r3   r   r%   ©rc   Útranslatable_modelsrL   rL   rM   Útest_get_translatable_models\  s   z6TestGetTranslatableModels.test_get_translatable_modelsc                 C   sJ   t dd}|  t|¡ |  t|¡ |  t|¡ |  t|¡ |  t|¡ d S )NT)Úinclude_subclasses)r"   rD  r2   r   r3   rF  r   r%   rÓ  rL   rL   rM   Ú/test_get_translatable_models_include_subclassesg  s   
zITestGetTranslatableModels.test_get_translatable_models_include_subclassesN)r‹   rŒ   r   rÕ  r×  rL   rL   rL   rM   rÒ  [  s    rÒ  c                   @   rd  )
ÚTestDefaultLocalec                 C   s   t j ¡ | _d S rH   )r   rI   r  rœ   r>  rL   rL   rM   r©   s  s   zTestDefaultLocale.setUpc                 C   s.   | j jtddddd}|  |j| j j¡ d S rË  )rœ   r`   r>   ra   r1  r   rL   rL   rM   Útest_default_localev  s   ÿz%TestDefaultLocale.test_default_localec                 C   s:   t jjdd}| jjtddd|dd}|  |j|¡ d S )Nr2  rE  rÌ  rÍ  r	  ©rX   rY   rZ   r1  r[   ©r   rI   r¡   rœ   r`   r>   ra   r1  )rc   rN  r€   rL   rL   rM   Útest_override_default_locale}  s   ÿÿz.TestDefaultLocale.test_override_default_localec                 C   sP   t jjdd}| jjtddd|dd}|jtddddd}|  |j|¡ d S )	Nr2  rE  rÌ  rÍ  r	  rÚ  r[   rW   rÛ  )rc   rN  Úfr_pager€   rL   rL   rM   Ú%test_always_defaults_to_parent_localeˆ  s   ÿÿÿz7TestDefaultLocale.test_always_defaults_to_parent_localeN)r‹   rŒ   r   r©   rÙ  rÜ  rÞ  rL   rL   rL   rM   rØ  r  s
    rØ  ©r5  c                   @   sT   e Zd ZdgZdd„ Zdd„ Zdd„ Zedd	d
d„ ƒZdd„ Z	dd„ Z
dd„ ZdS )ÚTestLocalizedrP   c                 C   s^   t jjdd| _tjjdd| _| jj| jdd| _d| j_	| jj
dgd	 | j ¡  ¡  d S )
Nr2  rE  rá   rR   TrG  u   NoÃ«lrX   rJ  )r   rI   r¡   rN  r   r_   rj  rL  Úfr_event_pagerX   rM  r•  rŸ  r>  rL   rL   rM   r©   œ  s   ÿzTestLocalized.setUpc                 C   s(   |   | jj| j¡ |   | jj| j¡ d S rH   )ra   rj  Ú	localizedÚlocalized_draftr>  rL   rL   rM   Útest_localized_same_language¦  s   z*TestLocalized.test_localized_same_languagec                 C   sX   t  d¡ |  | jj| jj¡ |  | jj| jj¡ W d   ƒ d S 1 s%w   Y  d S r;  )r   r=  ra   rj  râ  rá  r^  rã  r>  rL   rL   rM   Ú!test_localized_different_languageª  s   ÿ"þz/TestLocalized.test_localized_different_languageFrß  c                 C   sT   t  d¡ |  | jj| j¡ |  | jj| j¡ W d  ƒ dS 1 s#w   Y  dS )z<Should return the same page if WAGTAIL_I18N_ENABLED is Falser2  N)r   r=  ra   rj  râ  rã  r>  rL   rL   rM   ÚAtest_localized_different_language_with_wagtail_i18n_enabled_false±  s   "þzOTestLocalized.test_localized_different_language_with_wagtail_i18n_enabled_falsec                 C   sj   | j  ¡  | j  ¡  t d¡ |  | jj| j¡ |  | jj| j j	¡ W d   ƒ d S 1 s.w   Y  d S r;  )
rá  r«  rM  r   r=  ra   rj  râ  rã  r^  r>  rL   rL   rM   Ú-test_localized_different_language_unpublished¸  s   

ÿ"þz;TestLocalized.test_localized_different_language_unpublishedc                 C   s|   t  d¡/ |  | jj| j¡ |  | jj| jj¡ |  | jj| j¡ |  | jj| jj¡ W d   ƒ d S 1 s7w   Y  d S )NÚde)r   r=  ra   rj  râ  rá  r¸   rã  r>  rL   rL   rM   Ú-test_localized_with_non_content_active_localeÃ  s   ÿ"üz;TestLocalized.test_localized_with_non_content_active_localec                 C   s”   t jjdd}d|_| ¡  t d¡- |  | jj	| j¡ |  | j
j	| j
¡ |  | jj| j¡ |  | j
j| j
¡ W d   ƒ d S 1 sCw   Y  d S )Nr,  rE  Úplrè  )r   rI   r_   rF  rM  r   r=  ra   rj  râ  rá  rã  )rc   Ú	en_localerL   rL   rM   Ú*test_localized_with_missing_default_localeÍ  s   "üz8TestLocalized.test_localized_with_missing_default_localeN)r‹   rŒ   r   rŽ   r©   rä  rå  r   ræ  rç  ré  rì  rL   rL   rL   rM   rà  ˜  s    


rà  c                   @   sL   e Zd ZdgZdd„ Zdd„ Zdd„ Zedd	d
d„ ƒZdd„ Z	dd„ Z
dS )ÚTestGetLockrP   c                 C   s    t jjdd}|  | ¡ ¡ d S )Nrá   rR   )r2   rI   r_   rÀ   Úget_lockrŠ  rL   rL   rM   Útest_when_unlockedâ  s   zTestGetLock.test_when_unlockedc              	   C   sð   t ƒ jjdd}tjjdd}d|_||_tjr(tjdddd	d
dtj	j
d|_nt dddd	d
d¡|_| ¡ }|  |t¡ |  | |j¡¡ |  | |¡¡ tjrTd}nd}|  | |j¡dt|ƒ› d|› d¡ |  | |¡d|› d¡ d S ©NrS  rT  rá   rR   Tiæ  é   é   r›  é   r   rœ  zJuly 29, 2022, 9:19 p.m.zJuly 29, 2022, 12:19 p.m.z$<b>'Christmas' was locked</b> by <b>z</b> on <b>z</b>.z2<b>'Christmas' was locked</b> by <b>you</b> on <b>)r   rI   r_   r2   r»  r¼  r   r¢  r¤  r   r¥  r½  rî  rÑ  r   rt   Úfor_userr  rµ   ra   Úget_messagerP  ©rc   Ú	moderatorr‹  ÚlockÚexpected_date_stringrL   rL   rM   Útest_when_lockedç  s0   
ÿ
þ
þzTestGetLock.test_when_lockedc                 C   s\   t ƒ jjdd}tjjdd}d|_||_| ¡ }|  | |j	¡d¡ |  | |¡d¡ d S )NrS  rT  rá   rR   Tz<b>'Christmas' is locked</b>.z+<b>'Christmas' is locked</b> by <b>you</b>.)
r   rI   r_   r2   r»  r¼  rî  ra   rõ  r  )rc   r÷  r‹  rø  rL   rL   rM   Ú"test_when_locked_without_locked_at  s   
þþz.TestGetLock.test_when_locked_without_locked_atT)ÚWAGTAILADMIN_GLOBAL_EDIT_LOCKc              	   C   sð   t ƒ jjdd}tjjdd}d|_||_tjr(tjdddd	d
dtj	j
d|_nt dddd	d
d¡|_| ¡ }|  |t¡ |  | |j¡¡ |  | |¡¡ tjrTd}nd}|  | |j¡dt|ƒ› d|› d¡ |  | |¡d|› d¡ d S rð  )r   rI   r_   r2   r»  r¼  r   r¢  r¤  r   r¥  r½  rî  rÑ  r   rt   rô  r  ra   rõ  rP  rö  rL   rL   rM   Útest_when_locked_globally  s0   
ÿ
þ
þz%TestGetLock.test_when_locked_globallyc                 C   s  t ƒ jjdd}tjjdd}| ¡  tjjdd}tjjdd}|j 	t
jjdd¡ tjj||d	d
 | ||¡ | ¡ }|  |t¡ |  | |j¡¡ |  | |¡¡ |  | |j¡d¡ |  | |¡¡ tjjdd}tjj||dd
 | ¡ }|  | |j¡d¡ d S )NrS  rT  rá   rR   Útest_workflowrþ  Ú	test_taskzEvent moderatorsr´   )ÚworkflowÚtaskÚ
sort_orderz[This page is currently awaiting moderation. Only reviewers for this task can edit the page.Úanother_taskr¬   z€This page is awaiting <b>'test_task'</b> in the <b>'test_workflow'</b> workflow. Only reviewers for this task can edit the page.)r   rI   r_   r2   r•  r   r¡   r   r  rv  r   r    Ústartrî  rÑ  r   rt   rô  r  rµ   ra   rõ  rÀ   )rc   r÷  r‹  r   r  rø  Ú
other_taskrL   rL   rM   Útest_when_locked_by_workflow;  s0   
þ
þz(TestGetLock.test_when_locked_by_workflowc              	   C   sÎ   t jjdd}tjrtjddddddtjjd	|_nt dddddd¡|_| 	¡ }| 
¡  | ¡ }|  |t¡ |  | |j¡¡ tjrFd
}nd}|  | |j¡d|› ¡ tƒ jjdd}|  | |¡¡ d S )Nrá   rR   iî  rñ  rò  r8  é    r   rœ  zJuly 30, 2030, 1:32 a.m.zJuly 29, 2030, 4:32 p.m.z@Page 'Christmas' is locked and has been scheduled to go live at zsuperuser@example.comrT  )r2   rI   r_   r   r¢  r¤  r   r¥  r¾  r•  rŸ  rî  rÑ  r   rt   rô  r  ra   rõ  r   )rc   r‹  Úrvnrø  rù  Ú	superuserrL   rL   rM   Útest_when_scheduled_for_publish]  s(   
ÿ
þz+TestGetLock.test_when_scheduled_for_publishN)r‹   rŒ   r   rŽ   rï  rú  rû  r   rý  r  r
  rL   rL   rL   rM   rí  ß  s    !
!"rí  c                   @   s2   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚTestPageCacheKeyrP   c                 C   s   t j ¡ | _t j ¡ | _d S rH   )r   rI   Úlastr€   r  Ú
other_pager>  rL   rL   rM   r©   €  s   zTestPageCacheKey.setUpc                 C   s,   |   | jj| jj¡ |   | jj| jj¡ d S rH   )ra   r€   Ú	cache_keyr  r>  rL   rL   rM   Útest_cache_key_consistent„  s   z*TestPageCacheKey.test_cache_key_consistentc                 C   s@   |   d¡ | jj | jj W d   ƒ d S 1 sw   Y  d S )Nr   )r­   r€   r  r  r>  rL   rL   rM   Útest_no_queriesˆ  s   
"þz TestPageCacheKey.test_no_queriesc                 C   s.   | j j}d| j _| j  ¡  |  | j j|¡ d S )Nzsomething-else)r€   r  rY   rM  rµ  )rc   Úoriginal_cache_keyrL   rL   rM   Útest_changes_when_slug_changes  s   
z/TestPageCacheKey.test_changes_when_slug_changesN)r‹   rŒ   r   rŽ   r©   r  r  r  rL   rL   rL   rM   r  }  s    r  c                   @   rx  )ÚTestPageCachedParentObjExistsrP   c                 C   s2   t jjdd}d|_|jdd}|  |dd¡ d S )NrQ   rR   Ú_cached_parent_obj_existsFr(  zZPage.get_parent() (treebeard) no longer uses _cached_parent_obj to cache the parent object)r   rI   r_   Ú_cached_parent_objr)  ra   )rc   rd   r*  rL   rL   rM   Útest_cached_parent_obj_exists—  s   ýz;TestPageCachedParentObjExists.test_cached_parent_obj_existsN)r‹   rŒ   r   rŽ   r  rL   rL   rL   rM   r  ”  r†  r  c                   @   rd  )
Ú$TestPageServeWithPasswordRestrictionc                 C   sJ   t jjdd| _t ddd| _| jj| jd tjj| jtjdd| _	d S )	Nr¬   r]   z	Test Pager	  r¯  r[   Úpassword123)r€   r
  râ  )
r   rI   r_   rœ   Ú	test_pager`   r   r¡   ÚPASSWORDÚpassword_restrictionr>  rL   rL   rM   r©   §  s   þýz*TestPageServeWithPasswordRestriction.setUpc                 C   s´   t d| jj| jjgd}| j |dddœ¡}|  |d¡ | j d¡}|  d|v ¡ |  	d|d ¡ |  	d|d ¡ |  	d	|d ¡ |  	d
|d ¡ |  	d|d ¡ |  d|v ¡ d S )NÚ&wagtailcore_authenticate_with_password)r  r  ú/test/)râ  Ú
return_urlúCache-Controlú	max-age=0úno-cacheúno-storeúmust-revalidateÚprivateÚExpires)
r   r  r^   r  rZ  ÚpostÚassertRedirectsr_   rt   rD  )rc   Úauth_urlÚpost_responser  rL   rL   rM   ÚCtest_page_with_password_restriction_authenticated_has_cache_headersµ  s&   þþþzhTestPageServeWithPasswordRestriction.test_page_with_password_restriction_authenticated_has_cache_headersc                 C   s|   | j  d¡}|  d|v ¡ |  d|d ¡ |  d|d ¡ |  d|d ¡ |  d|d ¡ |  d|d ¡ |  d|v ¡ d S )	Nr  r  r   r!  r"  r#  r$  r%  )rZ  r_   rt   rD  rd  rL   rL   rM   Ú5test_page_with_password_restriction_has_cache_headersÏ  s   zZTestPageServeWithPasswordRestriction.test_page_with_password_restriction_has_cache_headersc                 C   s6   | j  ¡  | j d¡}|  d|v ¡ |  d|v ¡ d S )Nr  r  r%  )r  r   rZ  r_   rµ   rd  rL   rL   rM   Ú;test_page_without_password_restriction_has_no_cache_headersÚ  s   
z`TestPageServeWithPasswordRestriction.test_page_without_password_restriction_has_no_cache_headersN)r‹   rŒ   r   r©   r*  r+  r,  rL   rL   rL   rM   r  ¦  s
    r  )r¤  r  Úunittest.mockr   Údjango.confr   Údjango.contrib.authr   Údjango.contrib.auth.modelsr   r   Ú"django.contrib.contenttypes.modelsr   Údjango.core.exceptionsr   Údjango.httpr	   Údjango.testr
   r   r   Údjango.test.clientr   rÜ   r   Údjango.utilsr   r   Ú	freezegunr   Ú$wagtail.actions.copy_for_translationr   Úwagtail.coreutilsr   Úwagtail.locksr   r   r   Úwagtail.modelsr   r   r   r   r   r   r   r   r   r    r!   r"   Úwagtail.signalsr#   Úwagtail.test.testapp.modelsr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   Úwagtail.test.utilsrF   Úwagtail.url_routingrG   rN   rO   r•   r×   r8  rT  ry  r‡  r“  r™  rÁ  rë  rö  r  r)  rC  rW  rZ  r]  re  rl  rr  r|  r€  r±  r¸  rÄ  rÊ  rÒ  rØ  rà  rí  r  r  r  rL   rL   rL   rM   Ú<module>   sª    8$iÿ  l÷ Zh! Lz       O   c $z / 1D,&F 