o
    Eh                     @   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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"d+e#d)d*gZ$eje$d,d d-d.d/ Z%eje$d-d0d1 Z&dS )2    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   8lib/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dataZ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   Zxml	books.xmlr   r   r   r   r   xml_file0   r    r"   c              	   c   sN   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 d
 t d | dkrDdn| d} d|  }d| d}t	j
td| t	jt	jd9}d}|dkrz||}|jrvW nW n	 ty   Y nw |d8 }td |dksk|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_secretzJS3 tests do not have a corresponding service on Windows or macOS platformszhttp://localhost:5000requestsZmotoZflaskZmaster5ZgwZ555zhttp://127.0.0.1:/zmoto_server s3 -p )stdoutstderr   r   g?N)pytestZimportorskipZsetenvr   r   r   r   skiplstrip
subprocessPopenshlexsplitZDEVNULLgetok	ExceptiontimesleepZ	terminate)Z	worker_idZmonkeypatchr$   Zendpoint_portZendpoint_uriprocZtimeoutrr   r   r   s3_base5   sN   










"r8   c                 C   s   dd| iiS )NZclient_kwargsendpoint_urlr   )r8   r   r   r   s3sos   s   r:   c                 C   s   dd l }|jd| d}|S )Nr   s3)r9   )r#   Zresource)r8   r#   r;   r   r   r   s3_resourcex   s   r<   c                 c   s:    |  dt  }|  |V  |j  |  d S )Nzpandas-test-ZBucketuuidZuuid4ZcreateZobjectsdeleter<   Zbucketr   r   r   s3_public_bucket   s   
rA   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)ZKeyZBodyNopenZ
put_object)	rA   r   r   r   r"   test_s3_filess3_key	file_namefr   r   r   s3_public_bucket_with_data      

	rM   c                 c   s>    |  dt  }|jdd |V  |j  |  d S )Nzcant_get_it-Zprivate)ZACLr=   r@   r   r   r   s3_private_bucket   s   
rO   c           	   	   C   rB   rC   rG   )	rO   r   r   r   r"   rI   rJ   rK   rL   r   r   r   s3_private_bucket_with_data   rN   rP   )z.no_compressN) N)rD   gzip)z.GZrR   )rE   bz2)z.BZ2rS   )z.zipzip)z.ZIPrT   )z.xzxz)z.XZrU   )z.zstzstdZ	zstandard)Zmarks)z.ZSTrV      )paramsc                 C   s   | j S )NparamZrequestr   r   r   compression_format   s   r\   c                 C   s
   | j d S )Nr   rY   r[   r   r   r   compression_ext   s   
r]   )'r/   r-   r4   r>   r*   Zpandas.compatr   r   r   r   Zpandas.util._test_decoratorsutilZ_test_decoratorsZtdZpandas.io.commonr   commonr   Zpandas.io.parsersr   Zfixturer   r   r   r   r   r"   r8   r:   r<   rA   rM   rO   rP   rZ   Z
skip_if_noZ_compression_formats_paramsr\   r]   r   r   r   r   <module>   sh    






=







