o
    a"<f+                     @   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	 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G dd deZe	ddG dd deZdS )    N)ContentFile)get_storage_class)TestCase)override_settings)
LazyObject)storage)settings)css_tag)renderc                   @      e Zd Zdd ZdS )GzipStoragec                 C      t d | _d S )Nz,compressor.storage.GzipCompressorFileStorager   _wrappedself r   U/var/www/html/kck/venv/lib/python3.10/site-packages/compressor/tests/test_storages.py_setup      zGzipStorage._setupN__name__
__module____qualname__r   r   r   r   r   r          r   c                   @   r   )BrotliStoragec                 C   r   )Nz.compressor.storage.BrotliCompressorFileStorager   r   r   r   r   r      r   zBrotliStorage._setupNr   r   r   r   r   r      r   r   T)COMPRESS_ENABLEDc                   @   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 )StorageTestCasec                 C   s   t j| _t t _t t _d S N)r   default_storager   r   brotli_storager   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 )Ntest.txt	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                    s   d dd tdD  }d tjdt| | tj	
tj	 tjd | tj	
tj	 tjd d}t }ttj	 tjdd	t fd
ddD ]	}|||7 }qSW d    n1 sgw   Y  | || d S )N,c                 S   s   g | ]}t |qS r   )str).0ir   r   r   
<listcomp>*   s    z7StorageTestCase.test_brotli_storage.<locals>.<listcomp>i  i   r#   ztest.txt.br    rbc                      s
     S r   )readr   
chunk_sizefr   r   <lambda>2   s   
 z5StorageTestCase.test_brotli_storage.<locals>.<lambda>)r*   rangeencoder   r    r%   r   r&   r'   r(   r)   r   r+   brotliDecompressoropeniterprocessassertEqual)r   payloaddecompressed_databr_decompressordatar   r5   r   test_brotli_storage)   s   z#StorageTestCase.test_brotli_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/output.e701f86c6430.css)r   COMPRESS_URLr	   r@   r
   )r   templatecontextoutr   r   r   test_css_tag_with_storage6   s   
z)StorageTestCase.test_css_tag_with_storagec                 C   s@   | j dtd}| j dtd}| || | d| d S )Nr#   r$   _)r   r%   r   r@   assertNotIn)r   	filename1	filename2r   r   r   (test_duplicate_save_overwrites_same_fileA   s   z8StorageTestCase.test_duplicate_save_overwrites_same_filec              	   C   sR   t jdtd | tjtjt	j
dd | | jtjdd d S )Nr#   r$   CACHE)r    default_offline_manifest_storager%   r   r&   r'   r(   r)   r*   r   r+   r   r   r   r   r   test_offline_manifest_storageG   s     z-StorageTestCase.test_offline_manifest_storageN)
r   r   r   r!   r"   r,   rE   rK   rP   rS   r   r   r   r   r      s    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   r   <module>   s    