o
    _~#g                     @   s  d Z ddlmZ ddlZddlmZ ddlZddlm  m	Z
 ddlZddlmZ ejjejjejdg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ejdeej feej!fedd fej"eeej#dde
$ddej"eeej#d de
$d e
$d!e
j%gdeej&feej'feej feej!fg	ejd"dd#d$id$d%d&gd'd( Z(ejd)dd gd*d+ Z)dS ),z9
Tests for the pandas custom headers in http(s) requests
    )partialN)BytesIOz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc              	   C   sj   t  (}tj|dd}||  W d    n1 sw   Y  | W  d    S 1 s.w   Y  d S )Nw)fileobjmode)r   gzipGzipFilewritegetvalue)response_bytesbiozipper r   /var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/site-packages/pandas/tests/io/test_http_headers.py
gzip_bytes   s   $r   c                 C      | j dddS NF)indexutf-8)to_csvencodedfr   r   r   csv_responder      r   c                 C      t t| S N)r   r   r   r   r   r   gz_csv_responder#      r   c                 C   s   |   dS )Nr   )to_jsonr   r   r   r   r   json_responder'      r    c                 C   r   r   )r   r    r   r   r   r   gz_json_responder+   r   r"   c                 C   r   r   )to_htmlr   r   r   r   r   html_responder/   r   r$   c                 C   s   | j dddS )NFpyarrow)r   engine)
to_parquetr   r   r   r   parquetpyarrow_reponder3   r!   r(   c                 C   sR   dd l }| jdddd d |dd}| W  d    S 1 s"w   Y  d S )Nr   z'memory://fastparquet_user_agent.parquetFfastparquet)r   r&   compressionrb)fsspecr'   openread)r   r,   fr   r   r   parquetfastparquet_responder7   s   $r0   c                 C   s<   t  }| | | W  d    S 1 sw   Y  d S r   )r   	to_pickler
   r   r   r   r   r   pickle_respnderJ   s   
$r3   c                 C   s@   t  }| j|dd | W  d    S 1 sw   Y  d S )NF)write_index)r   to_statar
   r2   r   r   r   stata_responderP   s   $r6   zresponder, read_methodc                  O   s   t j| i |d S )Nr   )pd	read_html)argskwargsr   r   r   <lambda>]   s    r;   r%   )r&   )marksr)   r,   storage_options
User-Agentfoobarr>   Authc                 C   s   t ddgi}g d}d| jv r!ddi}|d u r|}n||O }nd }t||r-| ng }|j| ||d ||j|d}t	|| t
|jd	 j}	|D ]}
|	|
}|re|
|v re|||
 kseJ qP|	rjJ d S )
Nab)zAccept-EncodingHost
Connectionr>   gzzContent-Encodingr   )contentheaders)r=   r   )r7   	DataFrame__name__setunionkeysserve_contenturltmassert_frame_equaldictrequestsrI   pop)	responderread_method
httpserverr=   expecteddefault_headersextraexpected_headersresultrequest_headersheaderexpr   r   r   test_request_headersV   s*   '


ra   r&   c                 C   sl   ddd}t |  tddgi}d}t jt|d |jd|| d	 W d    d S 1 s/w   Y  d S )
Ncustomother_customrA   column_namecolumn_valuezxstorage_options passed with file object or non-fsspec file path|storage_options passed with buffer, or non-supported URL)matchz/tmp/junk.parquet)r=   r&   )pytestimportorskipr7   rJ   raises
ValueErrorr'   )r&   rI   true_dfmsgr   r   r   ,test_to_parquet_to_disk_with_storage_options   s   	
"rm   )*__doc__	functoolsr   r   ior   rg   pandas.util._test_decoratorsutil_test_decoratorstdpandasr7   pandas._testing_testingrQ   mark
single_cpunetworkfilterwarnings
pytestmarkr   r   r   r    r"   r$   r(   r0   r3   r6   parametrizeread_csv	read_jsonparamread_parquet
skip_if_no&skip_array_manager_not_yet_implementedread_pickle
read_statara   rm   r   r   r   r   <module>   s    	
