o
    Ti                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
m  mZ d dlm  mZ d dlmZ ejdd Zejdd Zejdd	 Zejd
d Zejdd Zejdd Zejdd Zeje rpdndddd Zeje rdndddd Zejdd Zejdd Zejdd Z ejdd  Z!ejd!d" Z"d#d$d%d&d'd(d)d*d+d,ej#d-e$d.d/ej#d0e$d.d/gZ%eje%d1d d2d3d4 Z&eje%d2d5d6 Z'ejd7ej#d8e$d8d/gd2d9d: Z(dS );    N)is_ci_environmentis_platform_armis_platform_macis_platform_windowsread_csvc                   C   s   dd t j D S )Nc                 S   s   i | ]\}}||qS  r   ).0keyvaluer   r   X/var/www/html/evchargy.com/venv/lib/python3.10/site-packages/pandas/tests/io/conftest.py
<dictcomp>   s    z,compression_to_extension.<locals>.<dictcomp>)icomZextension_to_compressionitemsr   r   r   r   compression_to_extension   s   r   c                 C      | ddddS )zPath to the tips datasetiodatacsvtips.csvr   datapathr   r   r   	tips_file      r   c                 C   r   )zPath to a JSONL datasetr   parserr   items.jsonlr   r   r   r   r   
jsonl_file   r   r   c                 C   s   t | ddddddS )z#DataFrame with the salaries datasetr   r   r   zsalaries.csv	)sepr   r   r   r   r   salaries_table%   s   r   c                 C   r   )Nr   r   Zfeatherzfeather-0_3_1.featherr   r   r   r   r   feather_file+      r    c                 C   r   )Nr   r   xml	books.xmlr   r   r   r   r   xml_file0   r!   r$   c                 C   s:   t  rd}n| dkrdn| d} d|  d}dd|iiS )	Nzhttp://localhost:5000/master5gwzhttp://127.0.0.1:555/Zclient_kwargsendpoint_url)r   lstrip)	worker_idurlr   r   r   s3so5   s
   r-   functionsession)scopec                  c   s8    t j } | V  W d    d S 1 sw   Y  d S N)pytestZMonkeyPatchcontext)mpr   r   r   monkeysession?   s   "r5   c              	   c   sR   t d t d |dd |dd t r/t s#t s#t r*t d dS dV  dS t d	}t jd
dd t d | dkrFdn| d} d|  }d| d}t	j
td| t	jt	jd9}d}|dkrz||}|jrxW nW n	 ty   Y nw |d8 }td |dksm|V  |  W d   dS 1 sw   Y  dS )z
    Fixture for mocking S3 interaction.

    Sets up moto server in separate process locally
    Return url for motoserver/moto CI service
    Zs3fsboto3ZAWS_ACCESS_KEY_IDZ
foobar_keyZAWS_SECRET_ACCESS_KEYZfoobar_secretzOS3 tests do not have a corresponding service in Windows, macOS or ARM platformszhttp://localhost:5000requestsZmotoz1.3.14)Z
minversionZflaskr%   r&   r'   Z555zhttp://127.0.0.1:r(   zmoto_server s3 -p )stdoutstderr   r   g?N)r2   ZimportorskipZsetenvr   r   r   r   skipr*   
subprocessPopenshlexsplitDEVNULLgetok	Exceptiontimesleep	terminate)r+   r5   r7   Zendpoint_portZendpoint_uriproctimeoutrr   r   r   s3_baseE   sN   









"rJ   c                 C   s   dd l }|jd| d}|S )Nr   s3)r)   )r6   resource)rJ   r6   rK   r   r   r   s3_resource   s   rM   c                 c   s:    |  dt  }|  |V  |j  |  d S )Nzpandas-test-ZBucketuuiduuid4createobjectsdeleterM   Zbucketr   r   r   s3_public_bucket   s   
rU   c           	   	   C      d|fd|fd|d fd|d fd|fd|fd	|fg}|D ] \}}t |d
}| j||d W d   n1 s8w   Y  q| S zw
    The following datasets
    are loaded.

    - tips.csv
    - tips.csv.gz
    - tips.csv.bz2
    - items.jsonl
    z
tips#1.csvr   ztips.csv.gz.gzztips.csv.bz2.bz2r   zsimple_dataset.featherr#   rb)KeyZBodyNopenZ
put_object)	rU   r   r   r    r$   test_s3_filess3_key	file_namefr   r   r   s3_public_bucket_with_data      

	rb   c                 c   s>    |  dt  }|jdd |V  |j  |  d S )Nzcant_get_it-private)ZACLrN   rT   r   r   r   s3_private_bucket   s   
re   c           	   	   C   rV   rW   r\   )	re   r   r   r    r$   r^   r_   r`   ra   r   r   r   s3_private_bucket_with_data   rc   rf   )z.no_compressN) N)rX   gzip)z.GZrh   )rY   bz2)z.BZ2ri   )z.zipzip)z.ZIPrj   )z.xzxz)z.XZrk   )z.zstzstdZ	zstandard)Zmarks)z.ZSTrl      )paramsc                 C      | j S r1   paramrequestr   r   r   compression_format   s   rt   c                 C   s
   | j d S )Nr   rp   rr   r   r   r   compression_ext   s   
ru   pythonZpyarrowc                 C   ro   )zb
    Parametrized fixture for pd.options.mode.string_storage.

    * 'python'
    * 'pyarrow'
    rp   rr   r   r   r   string_storage   s   rw   ))r>   r<   rD   rO   r2   Zpandas.compatr   r   r   r   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandas.io.commonr   commonr   Zpandas.io.parsersr   Zfixturer   r   r   r   r    r$   r-   r5   rJ   rM   rU   rb   re   rf   rq   Z
skip_if_noZ_compression_formats_paramsrt   ru   rw   r   r   r   r   <module>   sx    






	

=







