o
    ~¨Êhh	  ã                   @   sº   d dl mZmZ 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 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„ deƒZedd�G dd„ de
ƒƒZdS )é    )Úwith_statementÚunicode_literalsN)ÚContentFile)Úget_storage_class)ÚTestCase)Úoverride_settings)Ú
LazyObject)Ústorage)Úsettings)Úcss_tag)Úrenderc                   @   s   e Zd Zdd„ ZdS )ÚGzipStoragec                 C   s   t dƒƒ | _d S )Nz,compressor.storage.GzipCompressorFileStorage)r   Ú_wrapped©Úself© r   úP/var/www/html/env/lib/python3.10/site-packages/compressor/tests/test_storages.pyÚ_setup   s   zGzipStorage._setupN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s    r   T)ÚCOMPRESS_ENABLEDc                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚStorageTestCasec                 C   s   t j| _tƒ t _d S ©N)r	   Údefault_storager   r   r   r   r   ÚsetUp   s   zStorageTestCase.setUpc                 C   s   | j t_ d S r   )r   r	   r   r   r   r   ÚtearDown   s   zStorageTestCase.tearDownc                 C   sR   t j dtdƒ¡ |  tj tj t	j
d¡¡¡ |  tj tj t	j
d¡¡¡ d S )Nztest.txtz	yeah yeahztest.txt.gz)r	   r   Úsaver   Ú
assertTrueÚosÚpathÚexistsÚjoinr
   ÚCOMPRESS_ROOTr   r   r   r   Útest_gzip_storage   s   "z!StorageTestCase.test_gzip_storagec                 C   s,   d}dt ji}tdƒ}|  |t||ƒ¡ d S )Na2  {% load compress %}{% compress css %}
        <link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css">
        <style type="text/css">p { border:5px solid white;}</style>
        <link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
        {% endcompress %}
        Ú
STATIC_URLz"/static/CACHE/css/aca9bcd16bee.css)r
   ÚCOMPRESS_URLr   ÚassertEqualr   )r   ÚtemplateÚcontextÚoutr   r   r   Útest_css_tag_with_storage$   s   
z)StorageTestCase.test_css_tag_with_storagec                    s^   t j‰ ‡ fdd„}z!|t _| j dtdƒ¡ | j d¡ |  | j d¡¡ W ˆ t _d S ˆ t _w )Nc                    s   ˆ | ƒ t tjdƒ‚)z=Patched os.remove to raise ENOENT (No such file or directory)úFake ENOENT)ÚOSErrorÚerrnoÚENOENT)r    ©Úoriginal_remover   r   Úrace_remove3   s   zAStorageTestCase.test_race_condition_handling.<locals>.race_removez	race.filer,   )r   Úremover   r   r   ÚdeleteÚassertFalser!   )r   r2   r   r0   r   Útest_race_condition_handling/   s   z,StorageTestCase.test_race_condition_handlingN)r   r   r   r   r   r$   r+   r6   r   r   r   r   r      s    r   )Ú
__future__r   r   r.   r   Údjango.core.files.baser   Údjango.core.files.storager   Údjango.testr   Údjango.test.utilsr   Údjango.utils.functionalr   Ú
compressorr	   Úcompressor.confr
   Úcompressor.tests.test_baser   Ú"compressor.tests.test_templatetagsr   r   r   r   r   r   r   Ú<module>   s    