o
    QDiU                     @   s(  d dl Z d dlZd dlZd dlmZmZmZmZ ejj	ejj
e jdk dddd Zejj	ejj
e jdk dddd	 Zejjejj	d
d Zejjejj	dd Zejjejdddgdd Zejj	ejj
e jdk dddd Zejjejj	dd Zdd Zdd Zdd ZdS )    N)FrictionlessExceptionPackageResourcesystem)   
   zpytest-vcr bug in Python3.8/9)reasonc                  C      d} t ddd}t|g| d}tt}|jdd W d    n1 s%w   Y  |jj}t|dks6J |D ]	}d	|j	v sAJ q8d S )
Ndata/profiles/camtrap.jsontabledata/table.csvnamepath	resourcesprofileTvalidate   required
r   r   pytestraisesr   to_descriptorvaluereasonslenmessager   resourcepackageexcinfor   error r$   c/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/package/__spec__/test_profile.py#test_package_profiles_invalid_local   s   r&   c                  C      d} t ddd}tt}t| g| d W d    n1 s"w   Y  |jj}t|dks3J |D ]	}d|j	v s>J q5d S Nr
   r   r   r   r   r   r   
r   r   r   r   r   r   r   r   r   r   r   r    r"   r   r#   r$   r$   r%   3test_package_profiles_invalid_local_from_descriptor      r+   c                  C   r	   )
NNhttps://raw.githubusercontent.com/tdwg/camtrap-dp/main/camtrap-dp-profile.jsonr   r   r   r   Tr   r   r   r   r   r$   r$   r%   ,test_package_external_profile_invalid_remote'   s   r.   c                  C   r'   )Nr-   r   r   r   r   r   r   r)   r*   r$   r$   r%   <test_package_external_profile_invalid_remote_from_descriptor8   s   r/   r   zdata-packagetabular-data-packagec                 C   s:   dddg| d}t |}| }|dd u sJ d S )Nr   r   r   r   r   )r   from_descriptorr   getr   
descriptorr!   r$   r$   r%   test_package_profile_typeG   s   

r5   c                  C   r'   r(   r)   r*   r$   r$   r%   2test_package_profiles_from_descriptor_standards_v1V   r,   r6   c                  C   sl   d} dddg| gd}t |}tjdd | }|d | ks$J W d    d S 1 s/w   Y  d S )	Nzdata/profiles/empty.jsonr   r   r   )r   profilesv1)	standardsr   )r   r1   r   use_contextr   r3   r$   r$   r%   0test_package_profiles_to_descriptor_standards_v1c   s   

"r;   c                  C   s8   t d} t| }|jdksJ |djdksJ d S )Nz
    profile: tabular-data-package
    resources:
      -
        name: some-table
        profile: tabular-data-resource
        path: some-file.csv
        format: csv
        mediatype: text/csv
        encoding: utf-8
        schema: schema.json
    r0   z
some-tableztabular-data-resource)yaml	safe_loadr   r   get_resource)r4   r!   r$   r$   r%   )test_package_preserver_profile_issue_1480t   s   r?   c                  C   4   t d} t| }|ddgddggksJ d S )Nz
    profile: tabular-data-package
    resources:
      -
        name: some-table
        path: some-file.csv
        format: csv
        mediatype: text/csv
        encoding: utf-8
        schema: schema.json
    typenotezpackage-errorzWprofile "tabular-data-package" requires all the resources to be "tabular-data-resource"r<   r=   r   validate_descriptorflattenr4   reportr$   r$   r%   4test_package_profile_tabular_requirements_issue_1484      
rH   c                  C   r@   )Nz
    profile: tabular-data-package
    resources:
      -
        name: some-table
        profile: tabular-data-resource
        path: some-file.csv
        format: csv
        mediatype: text/csv
        encoding: utf-8
    rA   rB   zresource-errorz?profile "tabular-data-resource" requires "schema" to be presentrC   rF   r$   r$   r%   ;test_package_profile_tabular_requirements_schema_issue_1484   rI   rJ   )sysr   r<   frictionlessr   r   r   r   markvcrskipifversion_infor&   r+   skipr.   r/   parametrizer5   r6   r;   r?   rH   rJ   r$   r$   r$   r%   <module>   s8    