a
    Døg;Í  ã                   @   sh  d dl 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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mZ d dlmZ d dlmZ d dlmZm Z m!Z!m"Z"m#Z#m$Z$ d dl%m&Z& d dl'm(Z(m)Z)m*Z*m+Z+ d dl,m-Z-m.Z.m/Z/ d dl0m1Z1 ddl2mZm3Z3m4Z4m5Z5 G dd„ deƒZ6G dd„ deƒZ7G dd„ deƒZ8G dd„ de1eƒZ9G dd„ deƒZ:G dd„ deƒZ;G d d!„ d!eƒZ<ed"d#d$iid%G d&d'„ d'eƒƒZ=ed"d#d$iid%G d(d)„ d)eƒƒZ>G d*d+„ d+eƒZ?G d,d-„ d-eƒZ@G d.d/„ d/eƒZAG d0d1„ d1eƒZBed2gd3G d4d5„ d5e1eƒƒZCG d6d7„ d7eƒZDG d8d9„ d9eƒZEG d:d;„ d;eƒZFdS )<é    N©Úsettings)ÚGroupÚ
Permission)Úcaches)ÚFile)ÚStorageÚdefault_storageÚstorages)ÚSimpleUploadedFile)ÚPrefetch)ÚIntegrityError)ÚSimpleTestCaseÚTestCaseÚTransactionTestCaseÚoverride_settings)Úreverse)ÚImage)ÚFilterÚPictureÚ	RenditionÚResponsiveImageÚSourceImageIOErrorÚget_rendition_storage)ÚRect)Ú
CollectionÚGroupCollectionPermissionÚPageÚReferenceIndex)Ú	EventPageÚEventPageCarouselItemÚReimportedImageModel)ÚWagtailTestUtilsé   )r   Úget_test_image_fileÚget_test_image_file_svgÚget_test_image_filenamec                   @   s   e Zd ZdS )ÚCustomStorageN)Ú__name__Ú
__module__Ú__qualname__© r+   r+   ú_/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/images/tests/test_models.pyr'   (   s   r'   c                   @   s¨   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d„ Z
dd„ Zei ej¥dddii¥ddd„ ƒZdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%S )&Ú	TestImagec                 C   s   t jjdtddd| _d S )Nú
Test imageÚwhite©Úcolour©ÚtitleÚfile©r   ÚobjectsÚcreater$   Úimage©Úselfr+   r+   r,   ÚsetUp-   s    þzTestImage.setUpc                 C   s   |   tt¡ d S ©N)ÚassertEqualr!   r   r9   r+   r+   r,   Ú#test_get_image_model_at_import_time4   s    z-TestImage.test_get_image_model_at_import_timec                 C   s   |   | j ¡ ¡ d S r<   )ÚassertFalser8   Zis_portraitr9   r+   r+   r,   Útest_is_portrait7   s    zTestImage.test_is_portraitc                 C   s   |   | j ¡ ¡ d S r<   )Ú
assertTruer8   Zis_landscaper9   r+   r+   r,   Útest_is_landscape:   s    zTestImage.test_is_landscapec                 C   s    |   | j ¡ tddddƒ¡ d S )Nr   é€  éà  )r=   r8   Zget_rectr   r9   r+   r+   r,   Útest_get_rect=   s    zTestImage.test_get_rectc                 C   sP   |   | j ¡ ¡ d| j_d| j_d| j_d| j_|  | j ¡ tddddƒ¡ d S )	Néd   éÈ   é2   é   éK   é¾   é}   éÒ   )	ÚassertIsNoner8   Zget_focal_pointÚfocal_point_xÚfocal_point_yÚfocal_point_widthÚfocal_point_heightr=   r   r9   r+   r+   r,   Útest_get_focal_point@   s    zTestImage.test_get_focal_pointc                 C   sD   |   | j ¡ ¡ d| j_d| j_d| j_d| j_|  | j ¡ ¡ d S )NrF   rG   rH   rI   )r?   r8   Zhas_focal_pointrO   rP   rQ   rR   rA   r9   r+   r+   r,   Útest_has_focal_pointL   s    zTestImage.test_has_focal_pointc                 C   sÖ   |   | jj¡ |   | jj¡ |   | jj¡ |   | jj¡ | j tddddƒ¡ |  | jjd¡ |  | jjd¡ |  | jjd¡ |  | jjd¡ | j d ¡ |   | jj¡ |   | jj¡ |   | jj¡ |   | jj¡ d S )NrF   é–   rG   i^  éú   )	rN   r8   rO   rP   rQ   rR   Zset_focal_pointr   r=   r9   r+   r+   r,   Útest_set_focal_pointW   s    zTestImage.test_set_focal_pointc                 C   s   |   | j ¡ ¡ d S r<   )rA   r8   Úis_stored_locallyr9   r+   r+   r,   Útest_is_stored_locallyk   s    z TestImage.test_is_stored_locallyÚdefaultÚBACKENDz8wagtail.test.dummy_external_storage.DummyExternalStorage)ÚSTORAGESc                 C   s   |   | j ¡ ¡ d S r<   )r?   r8   rX   r9   r+   r+   r,   Ú,test_is_stored_locally_with_external_storagen   s    	z6TestImage.test_is_stored_locally_with_external_storagec                 C   s&   | j  ¡ }|  |t¡ |  |d¡ d S ©Nr   )r8   Úget_file_sizeÚassertIsInstanceÚintZassertGreater)r:   Ú	file_sizer+   r+   r,   Útest_get_file_sizey   s    
zTestImage.test_get_file_sizec                 C   sH   | j jjdd |  t¡ | j  ¡  W d   ƒ n1 s:0    Y  d S )NF)Úsave)r8   r4   ÚdeleteÚassertRaisesr   r_   r9   r+   r+   r,   Ú<test_get_file_size_on_missing_file_raises_sourceimageioerror~   s    zFTestImage.test_get_file_size_on_missing_file_raises_sourceimageioerrorc                 C   s   |   | j ¡ d¡ d S )NZ(4dd0211870e130b7e1690d2ec53c499a54a48fef)r=   r8   Zget_file_hashr9   r+   r+   r,   Útest_file_hashƒ   s    
ÿzTestImage.test_file_hashc                 C   s$   t jjdtƒ d}|  | ¡ ¡ dS )zw
        Feature detection should not be run on SVGs.

        https://github.com/wagtail/wagtail/issues/11172
        zTest SVGr2   N)r   r6   r7   r%   rN   Zget_suggested_focal_point©r:   r8   r+   r+   r,   Ú"test_get_suggested_focal_point_svgˆ   s
    þz,TestImage.test_get_suggested_focal_point_svgc                 C   s(   t jjddtƒ d}|  |j|j¡ d S )Nú
Test ImagezThis is a test description)r3   Údescriptionr4   )r   r6   r7   r$   r=   Údefault_alt_textrl   ri   r+   r+   r,   Útest_default_with_description”   s    ýz'TestImage.test_default_with_descriptionc                 C   s&   t jjdtƒ d}|  |j|j¡ d S )Nrk   r2   )r   r6   r7   r$   r=   rm   r3   ri   r+   r+   r,   Ú test_default_without_description   s
    þz*TestImage.test_default_without_descriptionN)r(   r)   r*   r;   r>   r@   rB   rE   rS   rT   rW   rY   r   r   r\   r]   rc   rg   rh   rj   rn   ro   r+   r+   r+   r,   r-   ,   s2   ÿÿþÿ
	r-   c                   @   s2   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚTestImageQuerySetztest_empty.jsonc                 C   s4   t jjdtƒ d}t j d¡}|  t|ƒ|g¡ d S )Nr.   r2   ÚTest)r   r6   r7   r$   Úsearchr=   Úlist©r:   r8   Úresultsr+   r+   r,   Útest_search_method©   s    þz$TestImageQuerySet.test_search_methodc                 C   sz   t jjdtƒ d}t jjdtƒ d}t jjddd}|  t|ƒ|g¡ t jjddd}t|dd	„ d
}|  |||g¡ d S )NúAAA Test imager2   úZZZ Test imagezaaa testÚand)ÚoperatorÚorc                 S   s   | j S r<   ©r3   )Úimgr+   r+   r,   Ú<lambda>Â   ó    z2TestImageQuerySet.test_operators.<locals>.<lambda>)Úkey)r   r6   r7   r$   rr   r=   rs   Úsorted)r:   Ú	aaa_imageÚ	zzz_imageru   Zsorted_resultsr+   r+   r,   Útest_operators´   s    þþz TestImageQuerySet.test_operatorsc                 C   s|   t jjdtƒ d}t jjdtƒ d}t j d¡jddd}|  t|ƒ||g¡ t j d¡jddd}|  t|ƒ||g¡ d S )	Nrw   r2   rx   r3   rq   F)Zorder_by_relevancez-title)r   r6   r7   r$   Zorder_byrr   r=   rs   )r:   r‚   rƒ   ru   r+   r+   r,   Útest_custom_orderingÅ   s     þþÿÿz&TestImageQuerySet.test_custom_orderingc                 C   s†   t ddƒD ]*}tjjd| tƒ d}|j ddd¡ q
|  d¡2 d	d
„ t ¡ D ƒ}|  	d|d ¡ W d   ƒ n1 sx0    Y  d S )Nr   é
   zTest image %dr2   ZaardvarkZ	artichokeZ	armadilloé   c                 S   s$   i | ]}|j d d„ |j ¡ D ƒ“qS )c                 S   s   g | ]
}|j ‘qS r+   ©Úname)Ú.0Útagr+   r+   r,   Ú
<listcomp>â   r   zUTestImageQuerySet.test_search_indexing_prefetches_tags.<locals>.<dictcomp>.<listcomp>)r3   ÚtagsÚall©rŠ   r8   r+   r+   r,   Ú
<dictcomp>á   s   ÿzJTestImageQuerySet.test_search_indexing_prefetches_tags.<locals>.<dictcomp>zTest image 0)
Úranger   r6   r7   r$   r   ÚaddÚassertNumQueriesZget_indexed_objectsZassertIn)r:   Úir8   ru   r+   r+   r,   Ú$test_search_indexing_prefetches_tagsØ   s    þþz6TestImageQuerySet.test_search_indexing_prefetches_tagsN)r(   r)   r*   Úfixturesrv   r„   r…   r•   r+   r+   r+   r,   rp   ¦   s
   rp   c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚTestImagePermissionsc                 C   s¸   | j dddd| _| j dddd| _| j dddd| _| jj tjjd	d
¡ | j	dddd| _
tjjdd
}tjj|t ¡ tjjddd | jj |¡ tjjd| jtƒ d| _d S )NÚuserzuser@email.comÚpassword)ÚusernameÚemailr™   Úownerzowner@email.comÚeditorzeditor@email.comZEditorsrˆ   Úadministratorzadministrator@email.comzImage addersÚ	add_image)Úcodename)ÚgroupZ
collectionZ
permissionr.   )r3   Zuploaded_by_userr4   )Zcreate_userr˜   rœ   r   Úgroupsr’   r   r6   ÚgetZcreate_superuserrž   r7   r   r   Zget_first_root_noder   r   r$   r8   )r:   Zimage_adders_groupr+   r+   r,   r;   é   s6    ÿÿÿýýýzTestImagePermissions.setUpc                 C   s   |   | j | j¡¡ d S r<   )rA   r8   Úis_editable_by_userrž   r9   r+   r+   r,   Útest_administrator_can_edit  s    z0TestImagePermissions.test_administrator_can_editc                 C   s   |   | j | j¡¡ d S r<   )rA   r8   r¤   r   r9   r+   r+   r,   Útest_editor_can_edit  s    z)TestImagePermissions.test_editor_can_editc                 C   s   |   | j | j¡¡ d S r<   )rA   r8   r¤   rœ   r9   r+   r+   r,   Útest_owner_can_edit  s    z(TestImagePermissions.test_owner_can_editc                 C   s   |   | j | j¡¡ d S r<   )r?   r8   r¤   r˜   r9   r+   r+   r,   Útest_user_cant_edit  s    z(TestImagePermissions.test_user_cant_editN)r(   r)   r*   r;   r¥   r¦   r§   r¨   r+   r+   r+   r,   r—   è   s
   "r—   c                   @   sL   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d„ Z
dS )ÚTestFiltersc                 C   s   |   t d¡dg¡ d S )Nú	width-100©r=   r   Zexpand_specr9   r+   r+   r,   Útest_expand_spec_single  s    z#TestFilters.test_expand_spec_singlec                 C   s   |   t d¡dg¡ d S )Nzwidth-100 jpegquality-20úwidth-100|jpegquality-20r«   r9   r+   r+   r,   Útest_expand_spec_flat  s    ÿz!TestFilters.test_expand_spec_flatc                 C   s   |   t d¡dg¡ d S )Nr­   r«   r9   r+   r+   r,   Útest_expand_spec_pipe!  s    ÿz!TestFilters.test_expand_spec_pipec                 C   s   |   t ddg¡dg¡ d S )Nrª   zjpegquality-20r­   r«   r9   r+   r+   r,   Útest_expand_spec_list&  s    þz!TestFilters.test_expand_spec_listc                 C   s   |   t d¡ddg¡ d S )Nzwidth-{100,200}rª   z	width-200r«   r9   r+   r+   r,   Útest_expand_spec_braced,  s    ÿz#TestFilters.test_expand_spec_bracedc                 C   s   |   t d¡ddg¡ d S )Nzwidth-{100,200} jpegquality-40úwidth-100|jpegquality-40úwidth-200|jpegquality-40r«   r9   r+   r+   r,   Útest_expand_spec_mixed1  s    þz"TestFilters.test_expand_spec_mixedc                 C   s   |   t d¡ddg¡ d S )Nzwidth-{100,200}|jpegquality-40r²   r³   r«   r9   r+   r+   r,   Útest_expand_spec_mixed_pipe7  s    þz'TestFilters.test_expand_spec_mixed_pipec                 C   s   |   t d¡g d¢¡ d S )Nz-width-{100,200} jpegquality-{40,80} grayscale)z"width-100|jpegquality-40|grayscalez"width-100|jpegquality-80|grayscalez"width-200|jpegquality-40|grayscalez"width-200|jpegquality-80|grayscaler«   r9   r+   r+   r,   Ú test_expand_spec_multiple_braces=  s    þz,TestFilters.test_expand_spec_multiple_bracesN)r(   r)   r*   r¬   r®   r¯   r°   r±   r´   rµ   r¶   r+   r+   r+   r,   r©     s   r©   c                   @   sT   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d„ Z
dd„ ZdS )ÚTestResponsiveImagec                 C   s&   t jjdtƒ d| _| j d¡| _d S ©Nr.   r2   úwidth-10©r   r6   r7   r$   r8   Úget_renditionÚrendition_10r9   r+   r+   r,   r;   J  s
    þzTestResponsiveImage.setUpc                 C   s(   t i ƒ}|  |jg ¡ |  |jd ¡ d S r<   )r   r=   Ú
renditionsÚattrs©r:   r}   r+   r+   r,   Útest_construct_emptyR  s    z(TestResponsiveImage.test_construct_emptyc                 C   s(   d| j i}t|ƒ}|  |j| j g¡ d S )NÚa)r¼   r   r=   r½   ©r:   r½   r}   r+   r+   r,   Útest_construct_with_renditionsW  s    
z2TestResponsiveImage.test_construct_with_renditionsc                 C   s>   |   ti ƒ¡ |   ti ddiƒ¡ d| ji}|  t|ƒ¡ d S )NÚsizesÚ100vwrÁ   )r?   r   r¼   rA   ©r:   r½   r+   r+   r,   Útest_evaluate_value\  s    
z'TestResponsiveImage.test_evaluate_valuec                 C   sp   d| j i}t|ƒ}t|ƒ}td| j d¡iƒ}t|ddiƒ}|  ||¡ |  |d¡ |  ||¡ |  ||¡ d S )NrÁ   zwidth-15rÄ   rÅ   i90  )r¼   r   r8   r»   ÚassertNotEqualr=   )r:   r½   Zvalue1Zvalue2Zvalue3Zvalue4r+   r+   r,   Útest_compare_valuec  s    
z&TestResponsiveImage.test_compare_valuec                 C   s^   | j | j d¡dœ}t| jdƒt| jdƒg}|  t t| ¡ ƒ¡|d › d|d › d¡ d S )Núwidth-90©r¹   rÊ   r¹   r   ú 10w, r#   z 90w)	r¼   r8   r»   r&   r=   r   Úget_width_srcsetrs   Úvalues)r:   r½   Ú	filenamesr+   r+   r,   Útest_get_width_srcsetn  s    
þ

þþz)TestResponsiveImage.test_get_width_srcsetc                 C   s0   d| j i}|  t t| ¡ ƒ¡t| jdƒ¡ d S ©Nr¹   )r¼   r=   r   rÍ   rs   rÎ   r&   r8   rÆ   r+   r+   r,   Ú&test_get_width_srcset_single_rendition|  s
    

þz:TestResponsiveImage.test_get_width_srcset_single_renditionc              
   C   sh   | j | j d¡dœ}t|ƒ}t| jdƒt| jdƒg}|  | ¡ d|d › d|d › d|d › d	¡ d S )
NrÊ   rË   r¹   zT
                <img
                    alt="Test image"
                    src="r   z"
                    srcset="rÌ   r#   zb 90w"
                    width="10"
                    height="7"
                >
            )r¼   r8   r»   r   r&   ÚassertHTMLEqualÚ__html__©r:   r½   r}   rÏ   r+   r+   r,   Útest_renderƒ  s"    
þ

þýýüþzTestResponsiveImage.test_renderc                 C   s(   t d| jiƒ}|  | ¡ | j ¡ ¡ d S rÑ   )r   r¼   rÓ   rÔ   Úimg_tagr¿   r+   r+   r,   Ú(test_render_single_image_same_as_img_tagš  s    z<TestResponsiveImage.test_render_single_image_same_as_img_tagN)r(   r)   r*   r;   rÀ   rÃ   rÇ   rÉ   rÐ   rÒ   rÖ   rØ   r+   r+   r+   r,   r·   I  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 )ÚTestPicturec                 C   s&   t jjdtƒ d| _| j d¡| _d S r¸   rº   r9   r+   r+   r,   r;      s
    þzTestPicture.setUpc                 C   s6   | j | j dœ}t|ƒ}|  |j| j g| j gdœ¡ d S )N)úformat-jpegúformat-webp©ÚjpegÚwebp©r¼   r   r=   ÚformatsrÂ   r+   r+   r,   Útest_formats¨  s    þÿzTestPicture.test_formatsc                 C   s$   d| j i}t|ƒ}|  |ji ¡ d S )NrÚ   rß   rÂ   r+   r+   r,   Útest_single_format²  s    
zTestPicture.test_single_formatc                 C   s>   | j | j | j dœ}t|ƒ}|  |j| j g| j | j gdœ¡ d S )N)rÚ   rÛ   zformat-webp-losslessrÜ   rß   rÂ   r+   r+   r,   Útest_mixed_format·  s    ý
þþzTestPicture.test_mixed_formatc           	      C   s¢   d| j i}d| j i}d| j i}d| j i}d| j i}i |¥|¥|¥|¥|¥i |¥|¥|¥|¥i |¥|¥|¥i |¥|¥dœ}| ¡ D ]\}}|  t|ƒ ¡ |¡ q€d S )Nzformat-avifrÛ   rÚ   z
format-pngz
format-gif)ÚgifÚpngrÝ   rÞ   )r¼   Úitemsr=   r   Zget_fallback_format)	r:   ZavifrÞ   rÝ   rå   rä   Z	fallbacksÚfmtr½   r+   r+   r,   Útest_fallback_formatÆ  s    





üz TestPicture.test_fallback_formatc                 C   s°   | j  d¡| j  d¡| j  d¡| j  d¡dœ}t|ddiƒ}t| j dƒt| j d	ƒt| j d
ƒt| j dƒg}|  | ¡ d|d › d|d › d|d › d|d › d|d › d¡ d S )Núformat-jpeg|width-10úformat-jpeg|width-90úformat-webp|width-10úformat-webp|width-90)ré   rê   rë   rì   rÄ   rÅ   zformat-jpeg.width-10zformat-jpeg.width-90zformat-webp.width-10zformat-webp.width-90z?
                <picture>
                    <source srcset="r‡   rÌ   é   z¬ 90w" sizes="100vw" type="image/webp">
                    <img
                        alt="Test image"
                        sizes="100vw"
                        src="r   z""
                        srcset="r#   z‰ 90w"
                        width="10"
                        height="7"
                    >
                </picture>
            )r8   r»   r   r&   rÓ   rÔ   rÕ   r+   r+   r,   Útest_render_multi_format_sizesÕ  s2    



ü



üþþúúùþz*TestPicture.test_render_multi_format_sizesc                 C   s0   t d| jiƒ}|  | ¡ d| j ¡ › d¡ d S )Nr¹   z	<picture>z
</picture>)r   r¼   rÓ   rÔ   r×   r¿   r+   r+   r,   rØ   ô  s    ÿz4TestPicture.test_render_single_image_same_as_img_tagN)
r(   r)   r*   r;   rá   râ   rã   rè   rî   rØ   r+   r+   r+   r,   rÙ   Ÿ  s   
rÙ   rZ   r[   ú+django.core.cache.backends.dummy.DummyCache©ZCACHESc                   @   sd  e Zd 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d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdJeeedœd d!„Zd"d#„ Zed$d%d&iid'd(d)„ ƒZd*d+„ Zd,d-„ Zd.d/„ Zed$d%d&iid'd0d1„ ƒZd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zeƒ d:d;„ ƒZ ed<d=d>d?„ ƒZ!ee"ƒ d=d@dA„ ƒZ#ed%dBid%dCid%d<idDœdEdFdGdH„ ƒZ$dIS )KÚTestRenditions)ú	height-66rª   ú	width-400c                 C   s   t jjdtƒ d| _d S ©Nr.   r2   r5   r9   r+   r+   r,   r;     s    þzTestRenditions.setUpc                 C   s   |   t ¡ t¡ d S r<   )ÚassertIsr   Zget_rendition_modelr   r9   r+   r+   r,   Útest_get_rendition_model  s    z'TestRenditions.test_get_rendition_modelc                 C   s:   | j  d¡}|  |jd¡ |  |jd¡ |  |jd¡ d S )Nró   i  i,  )r8   r»   r=   ÚwidthÚheightÚfilter_spec©r:   Ú	renditionr+   r+   r,   Útest_minification  s    z TestRenditions.test_minificationc                 C   s,   | j  d¡}|  |jd¡ |  |jd¡ d S )Númax-100x100rF   rJ   ©r8   r»   r=   r÷   rø   rú   r+   r+   r,   Útest_resize_to_max  s    z!TestRenditions.test_resize_to_maxc                 C   s,   | j  d¡}|  |jd¡ |  |jd¡ d S )Nzmin-120x120é    éx   rþ   rú   r+   r+   r,   Útest_resize_to_min  s    z!TestRenditions.test_resize_to_minc                 C   s,   | j  d¡}|  |jd¡ |  |jd¡ d S )NÚoriginalrC   rD   rþ   rú   r+   r+   r,   Útest_resize_to_original$  s    z&TestRenditions.test_resize_to_originalc                 C   s(   | j  d¡}| j  d¡}|  ||¡ d S ©Nró   )r8   r»   r=   ©r:   Zfirst_renditionÚsecond_renditionr+   r+   r,   Ú
test_cache+  s    zTestRenditions.test_cachec                 C   s,   | j  d¡}| j  tdƒ¡}|  ||¡ d S r  )r8   r»   r   r=   r  r+   r+   r,   Útest_get_with_filter_instance3  s    z,TestRenditions.test_get_with_filter_instancec                 C   s’   |   d¡ | j d¡}W d   ƒ n1 s,0    Y  tj d¡j| jjd}|   d¡ | d¡}W d   ƒ n1 sx0    Y  |  ||¡ d S )Né   rª   r½   ©Úpkr   )	r“   r8   r»   r   r6   Úprefetch_relatedr£   r  r=   ©r:   Úoriginal_renditionr8   r  r+   r+   r,   Útest_prefetched_rendition_found;  s    *(z.TestRenditions.test_prefetched_rendition_foundc                 C   s’   |   d¡ | j d¡}W d   ƒ n1 s,0    Y  tj d¡j| jjd}|   d¡ | d¡}W d   ƒ n1 sx0    Y  |  ||¡ d S )Nr
  rª   r  r   )	r“   r8   r»   r   r6   Úprefetch_renditionsr£   r  r=   r  r+   r+   r,   Útest_prefetch_renditions_foundJ  s    *(z-TestRenditions.test_prefetch_renditions_foundc                 C   sÒ   |   d¡ | j d¡}W d   ƒ n1 s,0    Y  tj d¡j| jjd}|   d¡ | d¡}W d   ƒ n1 sx0    Y  |  ||¡ |   d¡ | d¡}W d   ƒ n1 s¸0    Y  |  	||¡ d S )Nr
  rª   r½   r  é   rò   r   )
r“   r8   r»   r   r6   r  r£   r  rÈ   rõ   ©r:   r  r8   r  Zthird_renditionr+   r+   r,   Ú#test_prefetched_rendition_not_foundV  s    *((z2TestRenditions.test_prefetched_rendition_not_foundc                 C   sÒ   |   d¡ | j d¡}W d   ƒ n1 s,0    Y  tj d¡j| jjd}|   d¡ | d¡}W d   ƒ n1 sx0    Y  |  ||¡ |   d¡ | d¡}W d   ƒ n1 s¸0    Y  |  	||¡ d S )Nr
  rª   r  r  rò   r   )
r“   r8   r»   r   r6   r  r£   r  rÈ   rõ   r  r+   r+   r,   Ú"test_prefetch_renditions_not_foundr  s    *((z1TestRenditions.test_prefetch_renditions_not_foundc                 C   sD   t | j d¡ ¡ ƒ}t | j tdƒ¡ ¡ ƒ}|  |d |d ¡ d S )Nró   r   )rs   r8   Úget_renditionsrÎ   r   r=   )r:   ÚfirstÚsecondr+   r+   r,   Ú(test_get_renditions_with_filter_instanceƒ  s    z7TestRenditions.test_get_renditions_with_filter_instancec                 C   s8   | j  d¡ g d¢}t| j j|Ž  ¡ ƒ}|  ||¡ d S )Núwidth-40)zwidth-30r  zwidth-50)r8   r»   rs   r  Úkeysr=   )r:   ÚspecsZrenditions_keysr+   r+   r,   Útest_get_renditions_key_order‹  s    z,TestRenditions.test_get_renditions_key_orderF)Údb_queries_expectedÚprefetch_restrictedÚprefetch_allc                 C   st   t j ¡ }|r| d¡}n|r*|j| jŽ }|j| jjd}|  	|¡ |j
| jŽ  W d   ƒ n1 sf0    Y  d S )Nr½   ©Úid)r   r6   rŽ   r  r  ÚSPECSr£   r8   r#  r“   r  )r:   r  r   r!  Úquerysetr8   r+   r+   r,   Ú _test_get_renditions_performance’  s    
z/TestRenditions._test_get_renditions_performancec                 C   s4   |   d¡ |   d¡ | j ddd | j ddd d S )Nrí   r#   r   T©r!  )r   ©r&  r9   r+   r+   r,   Ú?test_get_renditions_performance_with_rendition_caching_disabled¢  s    

zNTestRenditions.test_get_renditions_performance_with_rendition_caching_disabledr½   r[   z-django.core.cache.backends.locmem.LocMemCacherð   c                 C   s&   |   d¡ |   d¡ | j ddd d S )Nrí   r   Tr'  r(  r9   r+   r+   r,   Ú>test_get_renditions_performance_with_rendition_caching_enabledµ  s    

zMTestRenditions.test_get_renditions_performance_with_rendition_caching_enabledc                 C   sÂ  dd„ | j D ƒ}|  d¡ | jj|Ž }W d   ƒ n1 s<0    Y  | ¡ D ]\}}|  |j|j¡ qN|  dd„ | ¡ D ƒdd„ |D ƒ¡ |  d¡ | jj|Ž }W d   ƒ n1 s¸0    Y  | ¡ D ]\}}|  |j|j¡ qÊ|  dd„ | ¡ D ƒd	d„ |D ƒ¡ |  d¡ | jj|Ž }W d   ƒ n1 s60    Y  |  ||¡ | jj	j
| j d
 d ¡  |  d¡ | jj|Ž }W d   ƒ n1 s”0    Y  |  ||¡ |  | ¡ | ¡ ¡ d S )Nc                 S   s   g | ]}t |ƒ‘qS r+   )r   )rŠ   Úspecr+   r+   r,   rŒ   Ï  r   z9TestRenditions.test_create_renditions.<locals>.<listcomp>r‡   c                 S   s   h | ]
}|j ’qS r+   ©r+  ©rŠ   Úfilterr+   r+   r,   Ú	<setcomp>Û  r   z8TestRenditions.test_create_renditions.<locals>.<setcomp>c                 S   s   h | ]
}|j ’qS r+   r,  r-  r+   r+   r,   r/  Ü  r   r#   c                 S   s   h | ]
}|j ’qS r+   r,  r-  r+   r+   r,   r/  ê  r   c                 S   s   h | ]
}|j ’qS r+   r,  r-  r+   r+   r,   r/  ë  r   r   )rù   )r$  r“   r8   Zcreate_renditionsræ   r=   r+  rù   r  r½   r.  re   rÈ   )r:   Zfilter_listÚresultr.  rû   Zsecond_resultZthird_resultr+   r+   r,   Útest_create_renditionsÎ  s2    *þ*þ,,z%TestRenditions.test_create_renditionsc                 C   s   | j  d¡}|  |jd¡ d S )Nró   r.   )r8   r»   r=   Zaltrú   r+   r+   r,   Útest_alt_attributeÿ  s    z!TestRenditions.test_alt_attributec                 C   s:   | j  d¡}|j}|jj d¡d }|  |d|› ¡ d S )Nr  ú/r#   zhttp://testserver/media/images/)r8   r»   Úfull_urlr4   r‰   Úsplitr=   )r:   Zren_imgr4  Zimg_namer+   r+   r,   Útest_full_url  s    zTestRenditions.test_full_urlc                 C   sz  t j}| j d¡}| ¡ }|  | |¡|¡ d|_| ||¡ |  	d¡ | j d¡}W d   ƒ n1 sj0    Y  |  |jd¡ t
j d¡j| jjd}|  	d¡ | d¡}W d   ƒ n1 sÄ0    Y  |  t|dƒ¡ |  |j| j¡ tdd| j_| j ¡  | jj ¡  ¡  | j d¡}|  t|dƒ¡ td	d| j_| j ¡  | jj ¡  ¡  | j d¡}|  t|dƒ¡ d S )
Nz	width-500r  r   r½   r  Ú_markZgreenr0   r/   )r   Úcache_backendr8   r»   Zget_cache_keyr=   r£   r7  Úsetr“   r   r6   r  r  r?   Úhasattrrõ   r$   r4   rd   r½   rŽ   re   )r:   Úcacherû   Zrendition_cache_keyZnew_renditionZfresh_imageZprefetched_renditionr+   r+   r,   Útest_renditions_cache	  s0    *(

z$TestRenditions.test_renditions_cachec                 C   sN   t ddiddidœd" |  tjtd ¡ W d   ƒ n1 s@0    Y  d S )Nr[   rï   )rZ   r½   rð   r½   ©r   r=   r   r8  r   r9   r+   r+   r,   Ú$test_prefers_rendition_cache_backend;  s    ÿÿüÿ
z3TestRenditions.test_prefers_rendition_cache_backendc                 C   sH   t dddiid" |  tjtd ¡ W d   ƒ n1 s:0    Y  d S )NrZ   r[   rï   rð   r=  r9   r+   r+   r,   Ú0test_uses_default_cache_when_no_renditions_cacheH  s    ÿÿÿz?TestRenditions.test_uses_default_cache_when_no_renditions_cachec                 C   s¨   d| j _d| j _d| j _d| j _| j  ¡  | j  d¡}|  |j 	¡ t
dddd	ƒ¡ |  |jjjd¡ |  |jjjd¡ |  |jjd
¡ |  |jjd¡ |  |jd¡ d S )NrF   rG   rH   rI   ú	width-320é%   é_   é?   éi   é   r†   zbackground-position: 15% 41%;)r8   rO   rP   rQ   rR   rd   r»   r=   Zfocal_pointÚroundr   ZcentroidÚxÚyr÷   rø   Úbackground_position_stylerú   r+   r+   r,   Útest_focal_pointR  s    
ÿzTestRenditions.test_focal_pointc                 C   s   | j  d¡}|  |jd¡ d S )Nr@  zbackground-position: 50% 50%;)r8   r»   r=   rI  rú   r+   r+   r,   Ú&test_background_position_style_defaultf  s    ÿz5TestRenditions.test_background_position_style_defaultc                 C   s&   t `|  tt dƒ¡ |  tƒ t¡ d S )NÚWAGTAILIMAGES_RENDITION_STORAGE)r   rL  r?   r:  r=   r   r	   r9   r+   r+   r,   Ú%test_rendition_storage_setting_absentn  s    z4TestRenditions.test_rendition_storage_setting_absentz.wagtail.images.tests.test_models.CustomStorage)rL  c                 C   s   |   tƒ t¡ d S r<   )r`   r   r'   r9   r+   r+   r,   Ú0test_rendition_storage_setting_given_dotted_patht  s    z?TestRenditions.test_rendition_storage_setting_given_dotted_pathc                 C   s   |   tƒ tj¡ d S r<   )r=   r   r   rL  r9   r+   r+   r,   Ú5test_rendition_storage_setting_given_storage_instancez  s    ÿzDTestRenditions.test_rendition_storage_setting_given_storage_instancez+django.core.files.storage.FileSystemStoragez5django.contrib.staticfiles.storage.StaticFilesStorage)rZ   ZstaticfilesÚcustom_storagerP  )r\   rL  c                 C   s   |   tƒ ttj ¡ d S r<   )r=   r   r
   r   rL  r9   r+   r+   r,   Ú2test_rendition_storage_setting_given_storage_alias€  s    ÿzATestRenditions.test_rendition_storage_setting_given_storage_aliasN)FF)%r(   r)   r*   r$  r;   rö   rü   rÿ   r  r  r  r	  r  r  r  r  r  r  ra   Úboolr&  r)  r   r*  r1  r2  r6  r<  r>  r?  rJ  rK  rM  rN  r'   rO  rQ  r+   r+   r+   r,   rñ   û  s~   
  üüÿÿÿ
1ÿÿÿ
+

ÿ


ÿÿÿùôrñ   c                   @   s"   e Zd ZdgZdd„ Zdd„ ZdS )ÚTestPrefetchRenditionsú	test.jsonc                 C   s˜   g | _ g | _tj ¡ d d… }t|ƒD ]H\}}tjjdtƒ d |_	}|j
dgd | j  |¡ | j |j¡ q&dd„ | j D ƒ| _dd„ | j D ƒ| _d S )	Nrí   zTest image {i}r2   Ú
feed_image)Zupdate_fieldsc                 S   s   g | ]}|  d ¡‘qS ©rý   ©r»   r   r+   r+   r,   rŒ   ©  s   z0TestPrefetchRenditions.setUp.<locals>.<listcomp>c                 S   s   g | ]}|  d ¡‘qS ©zmin-300x600rW  r   r+   r+   r,   rŒ   ¬  s   )ÚimagesÚevent_pages_pksr   r6   rŽ   Ú	enumerater   r7   r$   rU  rd   Úappendr  Úsmall_renditionsÚlarge_renditions)r:   Zevent_pagesr”   Úpager8   r+   r+   r,   r;   š  s"    þÿÿzTestPrefetchRenditions.setUpc                 C   sè   t dtj d¡d}|  d¡* ttj |¡j| j	dƒ}W d   ƒ n1 sN0    Y  |  d¡ dd„ |D ƒ}W d   ƒ n1 s†0    Y  |  
| j|¡ |  d¡ d	d„ |D ƒ}W d   ƒ n1 sÌ0    Y  |  
| j|¡ d S )
NrU  rý   )r%  rí   )Zpk__inr   c                 S   s   g | ]}|j  d ¡‘qS rV  ©rU  r»   ©rŠ   r_  r+   r+   r,   rŒ   ¿  s   zZTestPrefetchRenditions.test_prefetch_renditions_on_non_image_querysets.<locals>.<listcomp>c                 S   s   g | ]}|j  d ¡‘qS rX  r`  ra  r+   r+   r,   rŒ   Ç  s   )r   r   r6   r  r“   rs   r   r  r.  rZ  ZassertListEqualr]  r^  )r:   Z$prefetch_images_and_small_renditionsZpagesr]  r^  r+   r+   r,   Ú/test_prefetch_renditions_on_non_image_querysets°  s*    ÿÿþÿ"ÿ$ÿ$zFTestPrefetchRenditions.test_prefetch_renditions_on_non_image_querysetsN)r(   r)   r*   r–   r;   rb  r+   r+   r+   r,   rS  ”  s   rS  c                   @   s*   e Zd ZdgZdd„ Zdd„ Zdd„ ZdS )	ÚTestUsageCountrT  c                 C   s   t jjdtƒ d| _d S rô   r5   r9   r+   r+   r,   r;   Ñ  s    þzTestUsageCount.setUpc                 C   s   |   | j ¡  ¡ d¡ d S r^   )r=   r8   Ú	get_usageÚcountr9   r+   r+   r,   Útest_unused_image_usage_count×  s    z,TestUsageCount.test_unused_image_usage_countc                 C   sp   | j dd: tjjdd}tƒ }||_| j|_| ¡  W d   ƒ n1 sL0    Y  |  | j 	¡  
¡ d¡ d S )NT©Úexecuter  r"  r#   )ÚcaptureOnCommitCallbacksr   r6   r£   r    r_  r8   rd   r=   rd  re  ©r:   r_  Zevent_page_carousel_itemr+   r+   r,   Ú$test_used_image_document_usage_countÚ  s    &z3TestUsageCount.test_used_image_document_usage_countN)r(   r)   r*   r–   r;   rf  rk  r+   r+   r+   r,   rc  Î  s   rc  c                   @   s*   e Zd ZdgZdd„ Zdd„ Zdd„ ZdS )	ÚTestGetUsagerT  c                 C   s   t jjdtƒ d| _d S rô   r5   r9   r+   r+   r,   r;   ç  s    þzTestGetUsage.setUpc                 C   s   |   t| j ¡ ƒg ¡ d S r<   )r=   rs   r8   rd  r9   r+   r+   r,   Útest_unused_image_get_usageí  s    z(TestGetUsage.test_unused_image_get_usagec                 C   sÂ   | j dd: tjjdd}tƒ }||_| j|_| ¡  W d   ƒ n1 sL0    Y  |  | j 	¡ d t
¡ |  | j 	¡ d d t¡ |  | j 	¡ d d t¡ |  | j 	¡ d d d t¡ d S )NTrg  r  r"  r   r#   )ri  r   r6   r£   r    r_  r8   rd   r`   rd  Útupler   rs   r   rj  r+   r+   r,   Ú"test_used_image_document_get_usageð  s    &z/TestGetUsage.test_used_image_document_get_usageN)r(   r)   r*   r–   r;   rm  ro  r+   r+   r+   r,   rl  ä  s   rl  c                   @   sB   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S )ÚTestGetWillowImagerT  c                 C   s   t jjdtƒ d| _d S rô   r5   r9   r+   r+   r,   r;     s    þzTestGetWillowImage.setUpc                 C   s:   | j  ¡ }|  |t¡ W d   ƒ n1 s,0    Y  d S r<   )r8   Úget_willow_imager`   ÚWillowImage)r:   Úwillow_imager+   r+   r,   Ú!test_willow_image_object_returned  s    z4TestGetWillowImage.test_willow_image_object_returnedc              	   C   sl   t jjdd}|  t¡@ | ¡  |  ¡  W d   ƒ n1 s@0    Y  W d   ƒ n1 s^0    Y  d S )Nr#   r"  )r   r6   r£   rf   r   rq  Zfail)r:   Z	bad_imager+   r+   r,   Útest_with_missing_image  s    
z*TestGetWillowImage.test_with_missing_imagec                 C   sN   | j  ¡   |  | j jj¡ W d   ƒ n1 s00    Y  |  | j jj¡ d S r<   )r8   rq  r?   r4   ÚclosedrA   r9   r+   r+   r,   Útest_closes_image  s    .z$TestGetWillowImage.test_closes_imagec                 C   sn   zF| j  ¡ ( |  | j jj¡ tdƒ‚W d   ƒ n1 s:0    Y  W n tyX   Y n0 |  | j jj¡ d S )NzSomething went wrong!)r8   rq  r?   r4   rv  Ú
ValueErrorrA   r9   r+   r+   r,   Útest_closes_image_on_exception  s    *z1TestGetWillowImage.test_closes_image_on_exceptionc                 C   sX   | j j d¡ | j  ¡  W d   ƒ n1 s.0    Y  |  | j jj¡ | j j ¡  d S )NÚrb)r8   r4   Úopenrq  r?   rv  Úcloser9   r+   r+   r,   Útest_doesnt_close_open_image'  s
    z/TestGetWillowImage.test_doesnt_close_open_imageN)
r(   r)   r*   r–   r;   rt  ru  rw  ry  r}  r+   r+   r+   r,   rp  þ  s   
rp  c                   @   s   e Zd ZdZdd„ ZdS )ÚTestIssue573z 
    This tests for a bug which causes filename limit on Renditions to be reached
    when the Image has a long original filename and a big focal point key
    c                 C   s*   t jjdtdƒddddd}| d¡ d S )Nr.   zYthisisaverylongfilename-cdefghijklmnopqrstuvwxyzab-supercalifragilisticexpialidocious.pngiè  )r3   r4   rO   rP   rQ   rR   zfill-800x600)r   r6   r7   r$   r»   ri   r+   r+   r,   Útest_issue_5739  s    ÿøzTestIssue573.test_issue_573N)r(   r)   r*   Ú__doc__r  r+   r+   r+   r,   r~  3  s   r~  Úelasticsearch)Z _WAGTAILSEARCH_FORCE_AUTO_UPDATEc                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestIssue613c                 C   s4   ddl m} ddlm} d|jvr,t d¡‚|dƒS )Nr   r   )Úget_search_backendr  zNo elasticsearch backend active)Údjango.confr   Zwagtail.search.backendsrƒ  ZWAGTAILSEARCH_BACKENDSÚunittestZSkipTest)r:   r   rƒ  r+   r+   r,   Úget_elasticsearch_backendM  s
    

z&TestIssue613.get_elasticsearch_backendc                 C   s   |   ¡ | _|  ¡  d S r<   )r†  Úsearch_backendÚloginr9   r+   r+   r,   r;   W  s    
zTestIssue613.setUpc                 K   sŠ   dt dtƒ j ¡ ƒdœ}| |¡ | j tdƒ|¡}|  |tdƒ¡ t	j
jdd}|  | ¡ d¡ | ¡ }|  |jd¡ |  |jd	¡ |S )
Nr.   ztest.pngr2   zwagtailimages:addúwagtailimages:indexr|   r#   rC   rD   )r   r$   r4   ÚgetvalueÚupdateÚclientÚpostr   ÚassertRedirectsr   r6   r.  r=   re  r  r÷   rø   )r:   ÚparamsÚ	post_dataÚresponserY  r8   r+   r+   r,   rŸ   [  s    ÿþ
zTestIssue613.add_imagec                 K   sv   t jjdtƒ d| _ddi}| |¡ | j td| jj	fd|¡}|  
|tdƒ¡ t jj| jj	d}|  |jd¡ |S )	Nr.   r2   r3   ZEditedzwagtailimages:edit)Úargsr‰  r"  )r   r6   r7   r$   r8   r‹  rŒ  r  r   r#  rŽ  r£   r=   r3   )r:   r  r  r‘  r8   r+   r+   r,   Ú
edit_images  s    þÿ
ÿzTestIssue613.edit_imagec                 C   sb   | j  ¡  | j  t¡ | jdd}| j  ¡  | j  dt¡}|  t|ƒd¡ |  |d j	|j	¡ d S ©NZhello)r   r#   r   )
r‡  Úreset_indexÚadd_typer   rŸ   Úrefresh_indexrr   r=   Úlenr#  rt   r+   r+   r,   Útest_issue_613_on_add‹  s    

z"TestIssue613.test_issue_613_on_addc                 C   sb   | j  ¡  | j  t¡ | jdd}| j  ¡  | j  dt¡}|  t|ƒd¡ |  |d j	|j	¡ d S r”  )
r‡  r•  r–  r   r“  r—  rr   r=   r˜  r#  rt   r+   r+   r,   Útest_issue_613_on_edit›  s    

z#TestIssue613.test_issue_613_on_editN)	r(   r)   r*   r†  r;   rŸ   r“  r™  rš  r+   r+   r+   r,   r‚  K  s   
r‚  c                   @   s   e Zd Zdd„ ZdS )ÚTestIssue312c              	   C   s\   t jjdtƒ d}| d¡}| d¡}|  ||¡ | jttjj|j	|j
|j|j|jd d S )Nr.   r2   zfill-100x100)r8   rù   r÷   rø   Úfocal_point_key)r   r6   r7   r$   r»   r=   rf   r   r   r8   rù   r÷   rø   rœ  )r:   r8   Zrend1Zrend2r+   r+   r,   Útest_duplicate_renditions­  s     þ

ùz&TestIssue312.test_duplicate_renditionsN)r(   r)   r*   r  r+   r+   r+   r,   r›  ¬  s   r›  c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTestFilenameReductionzi
    This tests for a bug which results in filenames without extensions
    causing an infinite loop
    c                 C   s0   t jjdtdƒd}| ¡  |  d|jj¡ d S )Nr.   z^thisisaverylongfilename-defghijklmnopqrstuvwxyzabc-supercalifragilisticexpialidocioussuperlongr2   z^original_images/thisisaverylongfilename-defghijklmnopqrstuvwxyzabc-supercalifragilisticexpiali©r   r6   r7   r$   rd   r=   r4   r‰   ri   r+   r+   r,   Útest_filename_reduction_no_extË  s    ÿþþz4TestFilenameReduction.test_filename_reduction_no_extc                 C   s0   t jjdtdƒd}| ¡  |  d|jj¡ d S )Nr.   zbthisisaverylongfilename-efghijklmnopqrstuvwxyzabcd-supercalifragilisticexpialidocioussuperlong.pngr2   z^original_images/thisisaverylongfilename-efghijklmnopqrstuvwxyzabcd-supercalifragilisticexp.pngrŸ  ri   r+   r+   r,   Útest_filename_reduction_extÜ  s    ÿþþz1TestFilenameReduction.test_filename_reduction_extN)r(   r)   r*   r€  r   r¡  r+   r+   r+   r,   rž  Å  s   rž  c                   @   sX   e Zd 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d„ Zdd„ ZdS )ÚTestRenditionOrientationaÎ  
    This tests for a bug where images with exif orientations which
    required rotation for display were cropped and sized based on the
    unrotated image dimensions.

    For example images with specified dimensions of 640x450 but an exif orientation of 6
    should appear as a 450x640 portrait, but instead were still cropped to 640x450.

    Actual image files are used so that exif orientation data will exist for the rotation to function correctly.
    c                 C   sî   ddl m} | ¡ }| |¡}W d  ƒ n1 s40    Y  |  | ¡ d¡ |j d¡ d¡}| j	|d ddd	 | j	|d
 ddd	 | j	|d ddd	 |j d¡ d¡}| j	|d ddd	 | j	|d
 ddd	 | j	|d ddd	 dS )z–
        Check that the image has the correct colored pixels in the right places
        so that we know the image did not physically rotate.
        r   )ÚPillowImageN)éX  éÂ  ZRGB)é›   i  éÙ   rE  )Údeltar#   é&   r‡   é.   )iy  i²  éU   é]   éA   )
Zwillow.plugins.pillowr£  rq  r{  r=   Úget_sizer8   ÚconvertZgetpixelZassertAlmostEqual)r:   rû   r£  rs  r8   r1   r+   r+   r,   Ú-assert_orientation_landscape_image_is_correctø  s    
(zFTestRenditionOrientation.assert_orientation_landscape_image_is_correctc                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S )Nz0wagtail/images/tests/image_files/landscape_1.jpgrz  r.   r2   r¤  r¥  r  ©
r{  r   r6   r7   r   r=   r÷   rø   r»   r°  ©r:   Úfr8   rû   r+   r+   r,   Útest_jpeg_with_orientation_1  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_1c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S )Nz0wagtail/images/tests/image_files/landscape_2.jpgrz  r.   r2   r¤  r¥  r  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_2  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_2c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S )Nz0wagtail/images/tests/image_files/landscape_3.jpgrz  r.   r2   r¤  r¥  r  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_3-  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_3c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S )Nz0wagtail/images/tests/image_files/landscape_4.jpgrz  r.   r2   r¤  r¥  r  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_4;  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_4c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S ©Nz0wagtail/images/tests/image_files/landscape_6.jpgrz  r.   r2   r¥  r¤  r  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_5L  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_5c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S r¸  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_6Z  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_6c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S )Nz0wagtail/images/tests/image_files/landscape_7.jpgrz  r.   r2   r¥  r¤  r  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_7h  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_7c                 C   sŽ   t ddƒ$}tjjdt|ƒd}W d   ƒ n1 s40    Y  |  |jd¡ |  |jd¡ | d¡}|  |jd¡ |  |jd¡ |  	|¡ d S )Nz0wagtail/images/tests/image_files/landscape_8.jpgrz  r.   r2   r¥  r¤  r  r±  r²  r+   r+   r,   Útest_jpeg_with_orientation_8v  s    2
z5TestRenditionOrientation.test_jpeg_with_orientation_8N)r(   r)   r*   r€  r°  r´  rµ  r¶  r·  r¹  rº  r»  r¼  r+   r+   r+   r,   r¢  ì  s   r¢  )Gr…  r„  r   Zdjango.contrib.auth.modelsr   r   Zdjango.core.cacher   Zdjango.core.filesr   Zdjango.core.files.storager   r	   r
   Zdjango.core.files.uploadedfiler   Zdjango.db.modelsr   Zdjango.db.utilsr   Zdjango.testr   r   r   r   Zdjango.urlsr   Zwillow.imager   rr  Zwagtail.images.modelsr   r   r   r   r   r   Zwagtail.images.rectr   Zwagtail.modelsr   r   r   r   Zwagtail.test.testapp.modelsr   r    r!   Zwagtail.test.utilsr"   Úutilsr$   r%   r&   r'   r-   rp   r—   r©   r·   rÙ   rñ   rS  rc  rl  rp  r~  r‚  r›  rž  r¢  r+   r+   r+   r,   Ú<module>   sX    zB01V\
ÿ   
ÿ75
`'