Ë
    T]jH  ã                   ój   — 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
  G d„ de
j                  «      Zy)	é    )ÚSimpleUploadedFile)ÚDjangoTemplates)ÚClearableFileInput)Úwidgets)Úutilsc                   óX   ‡ — e Zd Zˆ fd„Zˆ fd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zˆ xZS )ÚImageClearableFileInputc                 óT   •— t         ‰| �  «        t        j                  «       | _        y ©N)ÚsuperÚsetUpÚtestÚTemporaryStorageÚstorage©ÚselfÚ	__class__s    €úY/var/www/zogu/zoguvenv/lib/python3.12/site-packages/easy_thumbnails/tests/test_widgets.pyr   zImageClearableFileInput.setUp   s   ø€ Ü‰‰ŒÜ×,Ñ,Ó.ˆ�ó    c                 óV   •— | j                   j                  «        t        ‰| �  «        y r   )r   Údelete_temporary_storager   ÚtearDownr   s    €r   r   z ImageClearableFileInput.tearDown   s   ø€ Ø�‰×-Ñ-Ô/Ü‰ÑÕr   c                 óh   — t        j                  «       }| j                  |j                  ddi«       y)zT
        If thumbnail options are not passed, default options will be used.
        Úsize)éP   r   N©r   r	   ÚassertEqualÚthumbnail_options)r   Úwidgets     r   Útest_options_defaultz,ImageClearableFileInput.test_options_default   s-   € ô ×0Ñ0Ó2ˆØ×Ñ˜×1Ñ1°F¸HÐ3EÕFr   c                 ó‚   — dddœ}t        j                  |¬«      }d|d<   | j                  |j                  dddœ«       y)z�
        A dictionary can be passed as the thumbnail options. The dictionary is
        copied so it isn't just a mutable reference of the original.
        )i,  éd   T)r   Úcrop©r   Fr#   Nr   )r   Úoptionsr   s      r   Útest_options_customz+ImageClearableFileInput.test_options_custom   sH   € ð
 &¨tÑ4ˆÜ×0Ñ0À7ÔKˆð  ˆ�‰Ø×ÑØ×$Ñ$¨zÀ4Ñ&Hõ	Jr   c                 ót  — | j                  | j                  d«      }t        j                  «       }| j                  j	                  |«      5 }| j                  |_        | j                  |_        |j                  d|«      }ddd«       | j                  |«       | j                  d|«       y# 1 sw Y   Œ.xY w)zX
        The output contains a link to both the source image and the thumbnail.
        útest.jpgÚphotoNú.80x80_©Úcreate_imager   r   r	   ÚopenÚthumbnail_storageÚrenderÚassertIn©r   Úsource_filenamer   Úsource_fileÚhtmls        r   Útest_renderz#ImageClearableFileInput.test_render'   s—   € ð ×+Ñ+¨D¯L©L¸*ÓEˆÜ×0Ñ0Ó2ˆà�\‰\×Ñ˜Ó/ð 	7°;Ø"&§,¡,ˆKÔØ,0¯L©LˆKÔ)Ø—=‘= ¨+Ó6ˆD÷	7ð
 	�‰�o tÔ,Ø�‰�i Õ&÷	7ð 	7ús   Á5B.Â.B7c                 ó„  — | j                  | j                  d«      }ddddœ}t        j                  |¬«      }| j                  j	                  |«      5 }| j                  |_        | j                  |_        |j                  d|«      }ddd«       | j                  |«       | j                  d	|«       y# 1 sw Y   Œ.xY w)
zV
        The thumbnail is generated using the options provided to the widget.
        r(   )r"   iô  éZ   T)r   Úqualityr#   r$   r)   Nz.100x500_q90_crop.jpgr+   )r   r2   r%   r   r3   r4   s         r   Ú test_render_custom_thumb_optionsz8ImageClearableFileInput.test_render_custom_thumb_options6   s¦   € ð ×+Ñ+¨D¯L©L¸*ÓEˆØ%°"¸dÑCˆÜ×0Ñ0À7ÔKˆà�\‰\×Ñ˜Ó/ð 	7°;Ø"&§,¡,ˆKÔØ,0¯L©LˆKÔ)Ø—=‘= ¨+Ó6ˆD÷	7ð
 	�‰�o tÔ,Ø�‰Ð-¨tÕ4÷	7ð 	7ús   Á5B6Â6B?c                 ó¦  — | j                  | j                  d«      }t        j                  «       }d|_        | j                  j                  |«      5 }| j                  |_        | j                  |_        |j                  d|«      }ddd«       | j                  |«       | j                  d|«       | j                  d|«       y# 1 sw Y   Œ@xY w)z…
        The template used to render the thumbnail and the standard
        ``ClearableFileInput`` output can be customized.
        r(   z<%(template)s<br /><a href="%(source_url)s">%(thumb)s</a> FOOr)   Nr*   ÚFOO)	r,   r   r   r	   Útemplate_with_thumbnailr-   r.   r/   r0   r1   s        r   Útest_custom_templatez,ImageClearableFileInput.test_custom_templateF   s´   € ð
 ×+Ñ+¨D¯L©L¸*ÓEˆÜ×0Ñ0Ó2ˆð9ð 	Ô&ð
 �\‰\×Ñ˜Ó/ð 	7°;Ø"&§,¡,ˆKÔØ,0¯L©LˆKÔ)Ø—=‘= ¨+Ó6ˆD÷	7ð
 	�‰�o tÔ,Ø�‰�i Ô&Ø�‰�e˜TÕ"÷	7ð 	7ús   Á5CÃCc                 óÄ  — | j                  | j                  d«      }t        j                  «       } G d„ dt        «      }| j                  j                  |«      5 }| j                  |_        | j                  |_        |j                  d| |«       ¬«      }ddd«       | j                  |«       | j                  d|«       | j                  d|«       y# 1 sw Y   Œ@xY w)	zŠ
        The form renderer used to render the thumbnail and the standard
        ``ClearableFileInput`` output can be customized.
        r(   c                   ó    ‡ — e Zd Zdˆ fd„	Zˆ xZS )úDImageClearableFileInput.test_custom_renderer.<locals>.CustomRendererc                 ó0   •— t         ‰| �  |||«      }|dz   S )Nz FOOBAR)r   r/   )r   Útemplate_nameÚcontextÚrequestÚoutputr   s        €r   r/   zKImageClearableFileInput.test_custom_renderer.<locals>.CustomRenderer.renderc   s    ø€ Ü™™¨°wÀÓH�Ø 	Ñ)Ð)r   r   )Ú__name__Ú
__module__Ú__qualname__r/   Ú__classcell__©r   s   @r   ÚCustomRendererr@   b   s   ø„ ÷*ñ *r   rK   r)   )ÚrendererNr*   ÚFOOBAR)	r,   r   r   r	   r   r-   r.   r/   r0   )r   r2   r   rK   r3   r4   s         r   Útest_custom_rendererz,ImageClearableFileInput.test_custom_renderer[   s¾   € ð
 ×+Ñ+¨D¯L©L¸*ÓEˆÜ×0Ñ0Ó2ˆô	*œ_ô 	*ð
 �\‰\×Ñ˜Ó/ð 	R°;Ø"&§,¡,ˆKÔØ,0¯L©LˆKÔ)Ø—=‘= ¨+ÁÓ@P�=ÓQˆD÷	Rð
 	�‰�o tÔ,Ø�‰�i Ô&Ø�‰�h Õ%÷	Rð 	Rús   Á<CÃCc                 ó¬   — t        j                  «       }t        «       }|j                  dd«      }|j                  dd«      }| j	                  ||«       y)z8
        If value not passed, use super widget.
        r)   N)r   r	   r   r/   r   )r   r   Úbase_widgetr4   Ú	base_htmls        r   Útest_render_without_valuez1ImageClearableFileInput.test_render_without_valuep   sL   € ô ×0Ñ0Ó2ˆÜ(Ó*ˆØ�}‰}˜W dÓ+ˆØ×&Ñ& w°Ó5ˆ	Ø×Ñ˜ DÕ)r   c                 ó,  — t        j                  «       }t        «       }d}| j                  d|«      }t	        ||j                  «       «      }|j                  d|«      }|j                  d|«      }| j                  ||«       | j                  ||«       y)a  
        The widget treats UploadedFile as no input.

        Rationale:
        When widget is used in ModelForm and the form (submitted with upload)
        is not valid, widget should discard the value (just like standard
        Django ClearableFileInput does).
        r(   Nr)   )	r   r	   r   r,   r   Úgetvaluer/   r   ÚassertNotIn)r   r   rP   Ú	file_nameÚimageÚupload_filer4   rQ   s           r   Útest_render_uploadedz,ImageClearableFileInput.test_render_uploadedz   s†   € ô ×0Ñ0Ó2ˆÜ(Ó*ˆØˆ	à×!Ñ! $¨	Ó2ˆÜ(¨°E·N±NÓ4DÓEˆØ�}‰}˜W kÓ2ˆØ×&Ñ& w°Ó<ˆ	Ø×Ñ˜ DÔ)Ø×Ñ˜ DÕ)r   )rF   rG   rH   r   r   r    r&   r5   r9   r=   rN   rR   rY   rI   rJ   s   @r   r	   r	   	   s7   ø„ ô/ôòGòJò'ò5ò #ò*&ò**ö*r   r	   N)Údjango.core.files.uploadedfiler   Údjango.forms.renderersr   Údjango.forms.widgetsr   Úeasy_thumbnailsr   Úeasy_thumbnails.testsr   r   ÚBaseTestr	   © r   r   ú<module>ra      s&   ðÝ =Ý 2Ý 3å #Ý /ôC*˜dŸm™mõ C*r   