o
    vh                     @   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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'ejj(e d#d$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)BytesIO)using_string_dtypez=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/html/hyperkenya/venv/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_responder1   r   r%   c                 C   s   | j dddS )NFpyarrow)r   engine)
to_parquetr   r   r   r   parquetpyarrow_reponder5   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_responder9   s   $r1   c                 C   s<   t  }| | | W  d    S 1 sw   Y  d S r   )r   	to_pickler   r   r   r   r   r   pickle_respnderL   s   
$r4   c                 C   s@   t  }| j|dd | W  d    S 1 sw   Y  d S )NF)write_index)r   to_statar   r3   r   r   r   stata_responderR   s   $r7   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-   zTODO(infer_string)reason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   )r8   	DataFrame__name__setunionkeysserve_contenturltmassert_frame_equaldictrequestsrK   pop)	responderread_method
httpserverr?   expecteddefault_headersextraexpected_headersresultrequest_headersheaderexpr   r   r   test_request_headersX   s*   (


rc   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_customrC   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importorskipr8   rL   raises
ValueErrorr(   )r'   rK   true_dfmsgr   r   r   ,test_to_parquet_to_disk_with_storage_options   s   	
"ro   )-__doc__	functoolsr   r   ior   ri   pandas._configr   pandas.util._test_decoratorsutil_test_decoratorstdpandasr8   pandas._testing_testingrS   mark
single_cpunetworkfilterwarnings
pytestmarkr   r   r   r!   r#   r%   r)   r1   r4   r7   parametrizeread_csv	read_jsonparamread_parquet
skip_if_no&skip_array_manager_not_yet_implementedxfailread_pickle
read_statarc   ro   r   r   r   r   <module>   s    	