a
    j=ic=                     @   sB  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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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#d&d' ZdS )(    N)is_ci_environmentis_platform_armis_platform_macis_platform_windowsread_csvc                 C   s   | ddddS )zPath to the tips datasetiodatacsvtips.csv datapathr   r   i/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/pandas/tests/io/conftest.py	tips_file   s    r   c                 C   s   | ddddS )zPath to a JSONL datasetr   parserr	   items.jsonlr   r   r   r   r   
jsonl_file   s    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   s   | ddddS )Nr   r	   Zfeatherzfeather-0_3_1.featherr   r   r   r   r   feather_file'   s    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/client_kwargsendpoint_url)r   lstrip)	worker_idurlr   r   r   s3so,   s
    r!   session)scopec              
   c   s|  t d t d t H tjdd tjdd t rht sTt	 sTt
 r`t d ndV  nt d	}t jd
dd t d | dkrdn| d} d|  }d| d}tjtd| tjtjdp}d}|dkr*z||}|jrW q*W n ty   Y n0 |d8 }td q|V  |  W d   n1 sN0    Y  W d   n1 sn0    Y  dS )z
    Fixture for mocking S3 interaction.

    Sets up moto server in separate process locally
    Return url for motoserver/moto CI service
    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   皙?N)pytestZimportorskiptmZ!ensure_safe_environment_variablesosenviron
setdefaultr   r   r   r   skipr   
subprocessPopenshlexsplitDEVNULLgetok	Exceptiontimesleep	terminate)r   r&   Zendpoint_portZendpoint_uriproctimeoutrr   r   r   s3_base6   sF    







r?   c                 #   s  ddl }ddl}d|fd|fd|d fd|d fd	|fd
|fg fdd}d}|jd| d}|jd| d z j|d W n ty   Y n0 z jddd W n ty   Y n0 d}	  d s|	dkrtd |	d8 }	q|| |d |j	
  |V  |j	d| id}
z|
j|dd W n ty:   Y n0 z|
jddd W n tyb   Y n0 d}	  d r|	dkrtd |	d8 }	qhdS )a0  
    Sets up S3 bucket with contents

    The primary bucket name is "pandas-test". The following datasets
    are loaded.

    - tips.csv
    - tips.csv.gz
    - tips.csv.bz2
    - items.jsonl

    A private bucket "cant_get_it" is also created. The boto3 s3 resource
    is yielded by the fixture.
    r   Nz
tips#1.csvr   ztips.csv.gz.gzztips.csv.bz2.bz2r   zsimple_dataset.featherc              	      sL   D ]B\}}t |d } j| ||d W d    q1 s<0    Y  qd S )Nrb)BucketKeyZBody)openZ
put_object)Zbucket_nameZs3_key	file_namefcliZtest_s3_filesr   r   add_tips_files   s    z#s3_resource.<locals>.add_tips_fileszpandas-tests3)r   )rC   Zcant_get_itprivate)rC   ZACL   ZBucketsr*   r   )r   T)	recursive)r%   r$   resourceclientZcreate_bucketr8   Zlist_bucketsr9   r:   ZS3FileSystemZclear_instance_cacherm)r?   r   r   r   r%   r$   rJ   Zbucketconnr=   rK   r   rH   r   s3_resourcev   sT    

	



rS   )z.no_compressN) N)r@   gzip)z.GZrU   )rA   bz2)z.BZ2rV   )z.zipzip)z.ZIPrW   )z.xzxz)z.XZrX   )z.zstzstdZ	zstandard)Zmarks)z.ZSTrY      )paramsc                 C   s   | j S )Nparamrequestr   r   r   compression_format   s    r`   c                 C   s
   | j d S )Nr   r\   r^   r   r   r   compression_ext   s    ra   ) r-   r3   r1   r9   r+   Zpandas.compatr   r   r   r   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandas._testingZ_testingr,   Zpandas.io.parsersr   Zfixturer   r   r   r   r!   r?   rS   r]   Z
skip_if_noZ_compression_formats_paramsr`   ra   r   r   r   r   <module>   sN   




	

?
I

