U
    {h{                     @   sF  d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZmZ d d	lmZ d d
lmZ G dd dZG dd deeeZG dd deeeZG dd deeeZG dd deeeZG dd deeeZG dd deeeZG dd deeeZG dd deeeZG dd deeeZdS )    N)Group
Permission)ContentType)TestCase)reverse)AdminURLFinder)Document)
CollectionCollectionViewRestrictionGroupCollectionPermission)WagtailTestUtils)AdminTemplateTestUtilsc                   @   s   e Zd Zdd ZdS )CollectionInstanceTestUtilsc                 C   s   t jt}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
jd	d| _| jjd
d| _| jjdd| _tjjdd| _| jj| | jddd| _| jj| j dS )zY
        Common setup for testing collection views with per-instance permissions
        Zadd_collection)content_typecodenameZchange_collectionZdelete_collectionZaccess_admin)r   Financename	MarketingDigital MarketingDirect Mail MarketingzMarketing GroupZ	marketingpasswordr   N)r   objectsZget_for_modelr	   r   getadd_permissionchange_permissiondelete_permissionget_first_root_noderoot_collection	add_childfinance_collectionmarketing_collectionmarketing_sub_collectionmarketing_sub_collection_2r   createmarketing_groupZpermissionsaddZcreate_usermarketing_usergroups)selfZcollection_content_typeZadmin_permission r+   r/var/www/dating/data/www/fatepal.com/env/lib/python3.8/site-packages/wagtail/admin/tests/test_collections_views.pysetUp   s6       
z!CollectionInstanceTestUtils.setUpN)__name__
__module____qualname__r-   r+   r+   r+   r,   r      s   r   c                   @   s8   e Zd Zdd Zi fddZdd Zdd Zd	d
 ZdS )#TestCollectionsIndexViewAsSuperuserc                 C   s   |    d S N)loginr*   r+   r+   r,   r-   7   s    z)TestCollectionsIndexViewAsSuperuser.setUpc                 C   s   | j td|S Nwagtailadmin_collections:indexclientr   r   r*   paramsr+   r+   r,   r   :   s    z'TestCollectionsIndexViewAsSuperuser.getc                 C   s   |   }| |jd | |d | |d t }|jdd| _|   }| |jd | |d | 	|d | |d | 
dddg|j d S )	N   zwagtailadmin/generic/index.htmlz!No collections have been created.Holiday snapsr    Collectionsurllabel)r   assertEqualstatus_codeassertTemplateUsedassertContainsr	   r   r    
collectionassertNotContainsassertBreadcrumbsItemsRenderedcontent)r*   responser   r+   r+   r,   test_simple=   s    
 z/TestCollectionsIndexViewAsSuperuser.test_simplec                 C   sZ   t  }|jdd |jdd |jdd |  }| dd |jd D dddg d S )NZMilkr   ZBreadZAvocadoc                 S   s   g | ]
}|j qS r+   r   .0rF   r+   r+   r,   
<listcomp>[   s     zETestCollectionsIndexViewAsSuperuser.test_ordering.<locals>.<listcomp>object_listr	   r   r    r   rB   context)r*   r   rJ   r+   r+   r,   test_orderingS   s    z1TestCollectionsIndexViewAsSuperuser.test_orderingc              	   C   s   t  }|jdd}|jdd |jdd |jdd}|jdd |jdd |  }| dd	 |jd
 D ddddddg d S )NZ	Vegetabler   ZSpinachZCucumberZAnimalZDogZCatc                 S   s   g | ]
}|j qS r+   r   rL   r+   r+   r,   rN   o   s     zLTestCollectionsIndexViewAsSuperuser.test_nested_ordering.<locals>.<listcomp>rO   rP   )r*   r   Z
vegetablesZanimalsrJ   r+   r+   r,   test_nested_ordering_   s    z8TestCollectionsIndexViewAsSuperuser.test_nested_orderingN)r.   r/   r0   r-   r   rK   rR   rS   r+   r+   r+   r,   r1   4   s
   r1   c                       sP   e Zd Z fddZi fddZdd Zdd Zd	d
 Zdd Zdd Z	  Z
S )TestCollectionsIndexViewc                    s   t    | j| jdd d S Nr   r   superr-   r3   r(   r4   	__class__r+   r,   r-   u   s    
zTestCollectionsIndexView.setUpc                 C   s   | j td|S r5   r7   r9   r+   r+   r,   r   y   s    zTestCollectionsIndexView.getc                 C   s,   |   }| |jd | |jd d d S N.  message6Sorry, you do not have permission to access this area.r   rB   rC   rQ   r*   rJ   r+   r+   r,   "test_marketing_user_no_permissions|   s    z;TestCollectionsIndexView.test_marketing_user_no_permissionsc                 C   sl   t jj| j| j| jd |  }| |jd | dd |j	d D dddg | 
|d	 | 
|d
 d S )NgrouprF   Z
permissionr;   c                 S   s   g | ]
}|j qS r+   r   rL   r+   r+   r,   rN      s     zWTestCollectionsIndexView.test_marketing_user_with_change_permission.<locals>.<listcomp>rO   r   r   r   r   Add a collection)r   r   r%   r&   r"   r   r   rB   rC   rQ   rG   r_   r+   r+   r,   *test_marketing_user_with_change_permission   s    zCTestCollectionsIndexView.test_marketing_user_with_change_permissionc                 C   sl   t jj| j| j| jd |  }| |jd | dd |j	d D dddg | 
|d	 | |d
 d S )Nra   r;   c                 S   s   g | ]
}|j qS r+   r   rL   r+   r+   r,   rN      s     zTTestCollectionsIndexView.test_marketing_user_with_add_permission.<locals>.<listcomp>rO   r   r   r   r   rc   )r   r   r%   r&   r"   r   r   rB   rC   rQ   rG   rE   r_   r+   r+   r,   'test_marketing_user_with_add_permission   s    z@TestCollectionsIndexView.test_marketing_user_with_add_permissionc                 C   sl   t jj| j| j| jd |  }| |jd | dd |j	d D dddg | 
|d	 | 
|d
 d S )Nra   r;   c                 S   s   g | ]
}|j qS r+   r   rL   r+   r+   r,   rN      s     zWTestCollectionsIndexView.test_marketing_user_with_delete_permission.<locals>.<listcomp>rO   r   r   r   r   rc   )r   r   r%   r&   r"   r   r   rB   rC   rQ   rG   r_   r+   r+   r,   *test_marketing_user_with_delete_permission   s    zCTestCollectionsIndexView.test_marketing_user_with_delete_permissionc                 C   sb   t jj| j| j| jd |  }| |jd | dd |j	d D dddd	g | 
|d
 d S )Nra   r;   c                 S   s   g | ]
}|j qS r+   r   rL   r+   r+   r,   rN      s     z\TestCollectionsIndexView.test_marketing_user_with_add_permission_on_root.<locals>.<listcomp>rO   r   r   r   r   rc   )r   r   r%   r&   r   r   r   rB   rC   rQ   rE   r_   r+   r+   r,   /test_marketing_user_with_add_permission_on_root   s    
zHTestCollectionsIndexView.test_marketing_user_with_add_permission_on_root)r.   r/   r0   r-   r   r`   rd   re   rf   rg   __classcell__r+   r+   rX   r,   rT   t   s   rT   c                   @   s<   e Zd Zdd Zi fddZi fddZdd Zd	d
 ZdS )TestAddCollectionAsSuperuserc                 C   s   |    t | _d S r2   )r3   r	   r   r   r4   r+   r+   r,   r-      s    z"TestAddCollectionAsSuperuser.setUpc                 C   s   | j td|S Nzwagtailadmin_collections:addr7   r9   r+   r+   r,   r      s    z TestAddCollectionAsSuperuser.getc                 C   s   | j td|S rj   r8   postr   r*   	post_datar+   r+   r,   rl      s    z!TestAddCollectionAsSuperuser.postc                 C   sH   |   }| |jd | || jj | ddddddg|j d S )Nr;   r>   /admin/collections/)rA   r@   zNew: Collectionr=   )r   rB   rC   rE   r   r   rH   rI   r_   r+   r+   r,   test_get   s    z%TestAddCollectionAsSuperuser.test_getc                 C   s^   |  d| jjd}| |td | tjjdd	 d | tjj
dd | j d S )Nr<   r   parentr6   r      )rl   r   idassertRedirectsr   rB   r	   r   filtercountr   
get_parentr_   r+   r+   r,   	test_post   s    z&TestAddCollectionAsSuperuser.test_postN)r.   r/   r0   r-   r   rl   rp   ry   r+   r+   r+   r,   ri      s
   ri   c                       sL   e Zd Z fddZi fddZi fddZdd Zd	d
 Zdd Z  Z	S )TestAddCollectionc                    s   t    | j| jdd d S rU   rV   r4   rX   r+   r,   r-      s    
zTestAddCollection.setUpc                 C   s   | j td|S rj   r7   r9   r+   r+   r,   r      s    zTestAddCollection.getc                 C   s   | j td|S rj   rk   rm   r+   r+   r,   rl      s    zTestAddCollection.postc                 C   s,   |   }| |jd | |jd d d S rZ   r^   r_   r+   r+   r,   r`      s    z4TestAddCollection.test_marketing_user_no_permissionsc                 C   sv   t jj| j| j| jd | d| jjd}| |t	d | 
tjjdd d | 
tjjdd | j d S )Nra   Affiliate Marketingrq   r6   r   rs   )r   r   r%   r&   r"   r   rl   rt   ru   r   rB   r	   rv   rw   r   rx   r_   r+   r+   r,   re     s&     z9TestAddCollection.test_marketing_user_with_add_permissionc                 C   sJ   t jj| j| j| jd | d| jjd}| 	|j
d jd dg d S )Nra   r{   rq   formrr   zGSelect a valid choice. That choice is not one of the available choices.)r   r   r%   r&   r"   r   rl   r   rt   rB   rQ   errorsr_   r+   r+   r,   6test_marketing_user_cannot_add_outside_their_hierarchy!  s    zHTestAddCollection.test_marketing_user_cannot_add_outside_their_hierarchy)
r.   r/   r0   r-   r   rl   r`   re   r~   rh   r+   r+   rX   r,   rz      s   rz   c                   @   sh   e Zd Zdd Zi dfddZi d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S )TestEditCollectionAsSuperuserc                 C   sX   |   | _t | _| jjdd| _| jjdd| _| jjdd| _| jjdd| _	d S )Nr<   r   zLevel 1Level 2zLevel 3)
r3   userr	   r   r   r    rF   l1l2l3r4   r+   r+   r,   r-   7  s    

z#TestEditCollectionAsSuperuser.setUpNc                 C   s    | j td|p| jjfd|S Nwagtailadmin_collections:editargsr8   r   r   rF   rt   r*   r:   collection_idr+   r+   r,   r   ?  s    z!TestEditCollectionAsSuperuser.getc                 C   s    | j td|p| jjfd|S r   r8   rl   r   rF   rt   r*   rn   r   r+   r+   r,   rl   H  s    z"TestEditCollectionAsSuperuser.postc                 C   sJ   |   }| |jd | |d | ddddt| jdg|j d S )Nr;   Delete collectionro   r>   r?   r=   )r   rB   rC   rE   rH   strrF   rI   r_   r+   r+   r,   rp   Q  s    z&TestEditCollectionAsSuperuser.test_getc                 C   s"   | j | jjd}| |jd d S Nr     r   r   rt   rB   rC   r_   r+   r+   r,    test_cannot_edit_root_collection]  s    z>TestEditCollectionAsSuperuser.test_cannot_edit_root_collectionc                 C   s.   d| j j }t| j}| || j | d S )Nz/admin/collections/%d/)r   pkr   r   rB   Zget_edit_url)r*   Zexpected_urlZ
url_finderr+   r+   r,   test_admin_url_findera  s    
z3TestEditCollectionAsSuperuser.test_admin_url_finderc                 C   s   | j dd}| |jd d S Ni r   r   r   rB   rC   r_   r+   r+   r,   test_get_nonexistent_collectionf  s    z=TestEditCollectionAsSuperuser.test_get_nonexistent_collectionc                 C   sB   |  d| jjd| jj | tjj| jjd j| jj d S )Nr   rq   r   )	rl   r   r   r   rB   r	   r   r   rx   r4   r+   r+   r,   test_move_collectionj  s
    z2TestEditCollectionAsSuperuser.test_move_collectionc                 C   s<   |  d| jjd| jj}| |jd d | |d d S )Nr   rq   r\   z0The collection could not be saved due to errors.zPlease select another parent)rl   r   r   r   rB   rQ   rE   r_   r+   r+   r,   0test_cannot_move_parent_collection_to_descendantq  s    zNTestEditCollectionAsSuperuser.test_cannot_move_parent_collection_to_descendantc                 C   sN   d| j jd}| || jj}| |td | tj	j
| jjdjd d S )NzSkiing photosrq   r6   rt   )r   rt   rl   rF   r   ru   r   rB   r	   r   r   r   )r*   datarJ   r+   r+   r,   test_rename_collectiony  s     z4TestEditCollectionAsSuperuser.test_rename_collection)r.   r/   r0   r-   r   rl   rp   r   r   r   r   r   r   r+   r+   r+   r,   r   6  s   		r   c                       s   e Zd Z fddZi fddZi 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dd Zdd Zdd Z  ZS )TestEditCollectionc                    sR   t    tjj| j| j| jd| _tjj| j| j| j	d| _
| j| jdd d S Nra   r   r   )rW   r-   r   r   r%   r&   r"   r   users_change_permissionr   users_add_permissionr3   r(   r4   rX   r+   r,   r-     s    
zTestEditCollection.setUpc                 C   s   | j td|fd|S r   r7   r*   r   r:   r+   r+   r,   r     s     zTestEditCollection.getc                 C   s   | j td|fd|S r   rk   r*   r   rn   r+   r+   r,   rl     s     zTestEditCollection.postc                 C   s>   | j   | j| jjd}| |jd | |jd d d S )Nr   r[   r\   r]   )r   deleter   r"   rt   rB   rC   rQ   r_   r+   r+   r,   (test_marketing_user_no_change_permission  s    
z;TestEditCollection.test_marketing_user_no_change_permissionc                 C   s>   | j   | | jji }| |jd | |jd d d S rZ   )r   r   rl   r"   rt   rB   rC   rQ   r_   r+   r+   r,   -test_marketing_user_no_change_permission_post  s    
z@TestEditCollection.test_marketing_user_no_change_permission_postc                 C   s   | j | jjd}| |jd |jd j}| t|d jj	d | t|d jj	d | 
| jjd| jjd	 | tjj | jjd
jd | tjj | jjd
 | j d S )Nr   r;   r|   r   Z	TextInputrr   ZSelectWithDisabledOptionsNew Collection Namerq   r   )r   r#   rt   rB   rC   rQ   fieldstypeZwidgetr.   rl   r   r$   r	   r   r   rx   )r*   rJ   Zform_fieldsr+   r+   r,   'test_marketing_user_can_move_collection  s,     z:TestEditCollection.test_marketing_user_can_move_collectionc                 C   sJ   | j   | j| jjd}| |jd | t|jd j	
 dg d S )Nr   r;   r|   r   )r   r   r   r#   rt   rB   rC   listrQ   r   keysr_   r+   r+   r,   ?test_marketing_user_cannot_move_collection_if_no_add_permission  s    
zRTestEditCollection.test_marketing_user_cannot_move_collection_if_no_add_permissionc                 C   sZ   | j   | | jjd| jjd tjj| jj	d}| 
|jd | 
| | j d S Nr   rq   r   )r   r   rl   r#   r   r$   r	   r   r   rt   rB   r   rx   r"   )r*   Zedited_collectionr+   r+   r,   Dtest_marketing_user_cannot_move_collection_if_no_add_permission_post  s    
zWTestEditCollection.test_marketing_user_cannot_move_collection_if_no_add_permission_postc                 C   s>   |  | jjd| jjd | tjj| jjd | j	 d S r   )
rl   r"   r   r$   rB   r	   r   r   rx   r   r4   r+   r+   r,   r     s    zCTestEditCollection.test_cannot_move_parent_collection_to_descendantc                 C   sd   t jj| j| j| jd | j| jjd}| 	|j
d | 	t|jd j dg | |d d S )Nra   r   r;   r|   r   r   )r   r   r%   r&   r!   r   r   r"   rt   rB   rC   r   rQ   r   r   rG   r_   r+   r+   r,   Ftest_marketing_user_cannot_move_collection_permissions_are_assigned_to  s    zYTestEditCollection.test_marketing_user_cannot_move_collection_permissions_are_assigned_toc                 C   s   | j   |   d S r2   )r   r   r   r4   r+   r+   r,   Otest_cannot_move_collection_permissions_are_assigned_to_with_minimal_permission  s    
zbTestEditCollection.test_cannot_move_collection_permissions_are_assigned_to_with_minimal_permissionc                 C   s   t jj| j| j| jd | | jjd| jjd | 	t
jj| jjd | j | | jj| jj| jjd | 	t
jj| jjd | j d S )Nra   z	Moved Subrq   r   )r   r   r%   r&   r!   r   rl   r#   rt   rB   r	   r   r   rx   r"   r   r   r4   r+   r+   r,   Ktest_marketing_user_cannot_move_collection_permissions_are_assigned_to_post  s.    z^TestEditCollection.test_marketing_user_cannot_move_collection_permissions_are_assigned_to_postc                 C   s   | j   |   d S r2   )r   r   r   r4   r+   r+   r,   Ttest_cannot_move_collection_permissions_are_assigned_to_with_minimal_permission_post"  s    
zgTestEditCollection.test_cannot_move_collection_permissions_are_assigned_to_with_minimal_permission_postc                 C   s   | j | jjd}| |d tjj| j| j| j	d | j | jjd}| |d tjj| j| j
| j	d | j | jjd}| |d d S )Nr   r   ra   )r   r#   rt   rG   r   r   r%   r&   r$   r   r"   rE   r_   r+   r+   r,   4test_page_shows_delete_link_only_if_delete_permitted*  s     zGTestEditCollection.test_page_shows_delete_link_only_if_delete_permitted)r.   r/   r0   r-   r   rl   r   r   r   r   r   r   r   r   r   r   r   rh   r+   r+   rX   r,   r     s   		 r   c                   @   sx   e Zd Zdd Zi dfddZi d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dd ZdS )TestDeleteCollectionAsSuperuserc                 C   s&   |    t | _| jjdd| _d S )Nr<   r   )r3   r	   r   r   r    rF   r4   r+   r+   r,   r-   H  s    
z%TestDeleteCollectionAsSuperuser.setUpNc                 C   s    | j td|p| jjfd|S Nzwagtailadmin_collections:deleter   r   r   r+   r+   r,   r   M  s    z#TestDeleteCollectionAsSuperuser.getc                 C   s    | j td|p| jjfd|S r   r   r   r+   r+   r,   rl   V  s    z$TestDeleteCollectionAsSuperuser.postc                 C   s2   |   }| |jd | |d | |j d S )Nr;   (wagtailadmin/generic/confirm_delete.html)r   rB   rC   rD   ZassertBreadcrumbsNotRenderedrI   r_   r+   r+   r,   rp   _  s    z(TestDeleteCollectionAsSuperuser.test_getc                 C   s"   | j | jjd}| |jd d S r   r   r_   r+   r+   r,   "test_cannot_delete_root_collectione  s    zBTestDeleteCollectionAsSuperuser.test_cannot_delete_root_collectionc                 C   s   | j dd}| |jd d S r   r   r_   r+   r+   r,   r   i  s    z?TestDeleteCollectionAsSuperuser.test_get_nonexistent_collectionc                 C   s8   t jjd| jd |  }| |jd | |d d S )NTest documenttitlerF   r;   .wagtailadmin/collections/delete_not_empty.html)r   r   r%   rF   r   rB   rC   rD   r_   r+   r+   r,   test_get_nonempty_collectionm  s     z<TestDeleteCollectionAsSuperuser.test_get_nonempty_collectionc                 C   s:   | j jtddd |  }| |jd | |d d S )NTest collectionr   instancer;   r   )rF   r    r	   r   rB   rC   rD   r_   r+   r+   r,   #test_get_collection_with_descendentv  s     zCTestDeleteCollectionAsSuperuser.test_get_collection_with_descendentc              	   C   sX   |   }| |td | |jd d | tj tjj	| j
jd W 5 Q R X d S )Nr6   r\   z#Collection 'Holiday snaps' deleted.r   )rl   ru   r   rB   rQ   assertRaisesr	   DoesNotExistr   r   rF   rt   r_   r+   r+   r,   ry     s    z)TestDeleteCollectionAsSuperuser.test_postc                 C   sD   t jjd| jd |  }| |jd | tjj	| jj
d d S )Nr   r     r   )r   r   r%   rF   rl   rB   rC   
assertTruer	   r   rt   r_   r+   r+   r,   test_post_nonempty_collection  s    z=TestDeleteCollectionAsSuperuser.test_post_nonempty_collectionc                 C   sF   | j jtddd |  }| |jd | tjj| j j	d d S )Nr   r   r   r   r   )
rF   r    r	   rl   rB   rC   r   r   r   rt   r_   r+   r+   r,   $test_post_collection_with_descendant  s    zDTestDeleteCollectionAsSuperuser.test_post_collection_with_descendantc                 C   sD   | j   | j| jjd}| |jd | tj	j
| jjd d S )Nr   r   r   )rF   r   rl   r   rt   rB   rC   r   r	   r   r   r_   r+   r+   r,   test_post_root_collection  s    
z9TestDeleteCollectionAsSuperuser.test_post_root_collection)r.   r/   r0   r-   r   rl   rp   r   r   r   r   ry   r   r   r   r+   r+   r+   r,   r   E  s   						r   c                       st   e Zd Z fddZi fddZi 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 )TestDeleteCollectionc                    s8   t    tjj| j| j| jd| _| j	| j
dd d S r   )rW   r-   r   r   r%   r&   r"   r   Zusers_delete_permissionr3   r(   r4   rX   r+   r,   r-     s    
zTestDeleteCollection.setUpc                 C   s   | j td|fd|S r   r7   r   r+   r+   r,   r     s     zTestDeleteCollection.getc                 C   s   | j td|fd|S r   rk   r   r+   r+   r,   rl     s     zTestDeleteCollection.postc                 C   s.   | j | jjd}| |jd | |d d S )Nr   r;   r   )r   r#   rt   rB   rC   rD   r_   r+   r+   r,   rp     s    zTestDeleteCollection.test_getc              	   C   sN   | j | jjd}| |td | tj tjj	| jjd W 5 Q R X d S )Nr   r6   r   )
rl   r#   rt   ru   r   r   r	   r   r   r   r_   r+   r+   r,   ry     s    zTestDeleteCollection.test_postc                 C   s    |  | jj}| |jd d S Nr   )r   r!   rt   rB   rC   r_   r+   r+   r,   +test_cannot_delete_someone_elses_collection  s    z@TestDeleteCollection.test_cannot_delete_someone_elses_collectionc                 C   s8   |  | jj}| |jd | tjj| j	jd d S Nr   r   )
rl   r!   rt   rB   rC   r   r	   r   r   r#   r_   r+   r+   r,   0test_cannot_delete_someone_elses_collection_post  s    zETestDeleteCollection.test_cannot_delete_someone_elses_collection_postc                 C   s    |  | jj}| |jd d S r   )r   r"   rt   rB   rC   r_   r+   r+   r,   ,test_cannot_delete_their_own_root_collection  s    zATestDeleteCollection.test_cannot_delete_their_own_root_collectionc                 C   s8   |  | jj}| |jd | tjj| jjd d S r   )	rl   r"   rt   rB   rC   r   r	   r   r   r_   r+   r+   r,   1test_cannot_delete_their_own_root_collection_post  s    zFTestDeleteCollection.test_cannot_delete_their_own_root_collection_postc                 C   s@   | j jtddd | | j j}| |jd | |d d S )NAnother collectionr   r   r;   r   )r#   r    r	   r   rt   rB   rC   rD   r_   r+   r+   r,   .test_cannot_delete_collection_with_descendants  s     zCTestDeleteCollection.test_cannot_delete_collection_with_descendantsc                 C   sL   | j jtddd | | j j}| |jd | tjj	| j jd d S )Nr   r   r   r   r   )
r#   r    r	   rl   rt   rB   rC   r   r   r   r_   r+   r+   r,   3test_cannot_delete_collection_with_descendants_post  s    zHTestDeleteCollection.test_cannot_delete_collection_with_descendants_post)r.   r/   r0   r-   r   rl   rp   ry   r   r   r   r   r   r   rh   r+   r+   rX   r,   r     s   
	r   c                       s0   e Zd Z fddZi fddZdd Z  ZS )TestSetCollectionPrivacyc                    s   t    |   d S r2   )rW   r-   r3   r4   rX   r+   r,   r-     s    
zTestSetCollectionPrivacy.setUpc                 C   s   | j td|fd|S )Nz$wagtailadmin_collections:set_privacyr   r7   r   r+   r+   r,   r     s    zTestSetCollectionPrivacy.getc                 C   s   t jj| jddd | | jj}| |jd | 	|d | 
|d | t|jd }| |d | |d	 |d
}td| jjfd}| |d| d S )Nr   Zpassword123)rF   Zrestriction_typer   r;   z5wagtailadmin/collection_privacy/ancestor_privacy.htmlz=This collection has been made private by a parent collection.htmlheaderZh1ar   r   href)r
   r   r%   r   r   r#   r   rB   rC   rD   rE   Zget_soupjsonloadsrI   ZassertIsNoneZ
select_oner   )r*   rJ   ZsouplinkZparent_edit_urlr+   r+   r,   test_get_private_child  s0     
z/TestSetCollectionPrivacy.test_get_private_child)r.   r/   r0   r-   r   r   rh   r+   r+   rX   r,   r     s   r   ) r   Zdjango.contrib.auth.modelsr   r   Z"django.contrib.contenttypes.modelsr   Zdjango.testr   Zdjango.urlsr   Zwagtail.admin.admin_url_finderr   Zwagtail.documents.modelsr   Zwagtail.modelsr	   r
   r   Zwagtail.test.utilsr   Z!wagtail.test.utils.template_testsr   r   r1   rT   ri   rz   r   r   r   r   r   r+   r+   r+   r,   <module>   s8   !
  @U*CP @
  fN