o
    ;Die                     @   s   d dl mZmZmZ d dlZd dlmZ d dlmZ d dl	m
Z
mZmZmZm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dd Zdd Zdd Zd d! Zd"d# Zd$d% ZdS )&    )absolute_importprint_functiondivisionN)FieldSelectionError)ieq)
duplicatesunique	conflictsdistinctisuniquec                  C   s:   d} t | d}d}t|| t | dd}d}t|| d S )N)foobarbazA      B23.4Dxyzg      "@r   37.8Tr   r   *   ENr      皙(@r   )r   r   r   r   r   r"   r   r   key)r   r   r   r   r   tableresultexpectation r-   W/var/www/Datamplify/venv/lib/python3.10/site-packages/petl/test/transform/test_dedup.pytest_duplicates   s   
	
r/   c                  C   s   g } t | }g }t|| dS )zmRemoving the duplicates from an empty table without specifying which
    columns shouldn't be a problem.
    Nr(   )r*   actualexpectr-   r-   r.   "test_duplicates_headerless_no_keys'   s   r2   c                  C   sD   g } t t t| dD ]}qW d    d S 1 sw   Y  d S )Nr   )pytestraisesr   r   )r*   ir-   r-   r.   #test_duplicates_headerless_explicit1   s   "r6   c                  C   "   d} d}t | dd}t|| d S N)r%   r   r&   r(   r*   r1   r0   r-   r-   r.   test_duplicates_empty8      r:   c                  C      d} t | }d}t|| d S )Nr   r   r   r   r"   )r   r   r   r(   r)   r-   r-   r.   test_duplicates_wholerow?      r>   c                  C   sN   d} t | d}d}t|| t|| t | dd}d}t|| t|| d S )N)	r   r   r   r   r   r   r    r"   F   gffffff@r   )r   r   r    r@   r%   r&   )r   r   r   r"   r   r    r@   r   r   r)   r-   r-   r.   test_uniqueN   s   




rD   c                  C   r7   r8   rC   r9   r-   r-   r.   test_unique_emptyo   r;   rE   c                  C   r<   )Nr=   )r   r   r"   rC   r)   r-   r-   r.   test_unique_wholerowv   r?   rF   c                  C   s   d} t | dd d}d}t|| t|| t | dd dd}d}t|| t|| t | dd dd}d	}t|| t|| t | dd d
d}d}t| tt| t|| t|| t | dd dd}d}t|| t|| d S )N)r   r   )r   r   Nr   r   g"@)r   Nr   Tr    r   r   r$   r   r   Nr   )missing)r   r   rI   rG   rH   r   )rJ   exclude)r   r   rI   )r   r   )r   r   )rJ   include)r	   r   printlistr)   r-   r-   r.   test_conflicts   s.   	








rO   c                  C   r7   r8   )r	   r   r9   r-   r-   r.   test_conflicts_empty   r;   rP   c                  C   r<   )N)r   r   r   r   r"   NNNr   rQ   r   r   r"   r
   r   r*   r+   r1   r-   r-   r.   test_distinct   s   rU   c                  C   "   d} t | dd}d}t|| d S )N)r   rQ   r   r   r   r"   count)rW   )r   r   r   rW   )NNNr   )r   r   r   r   )r   r   r   r   )r   r#   r$   r   rS   rT   r-   r-   r.   test_distinct_count      rY   c                  C   rV   )N)r   rQ   r   r   r   r   5r"   r   r&   rR   rS   rT   r-   r-   r.   test_key_distinct   rZ   r]   c                  C   rV   )N)abx1rb   r   )yrc   NNr`   r&   )r^   rf   ra   rd   rS   )tblr+   r1   r-   r-   r.   test_key_distinct_2   s   rh   c                  C   s$   d} t | ddd}d}t|| d S )N)r   r   r   r[   r"   rQ   r   rW   )r'   rW   rX   rS   rT   r-   r-   r.   test_key_distinct_count  s   ri   c                  C   s$   d} t | dr	J t | dsJ d S )N)r%   )r_   r   )r`   )r`   r   )c   Tr   r   )r   )r*   r-   r-   r.   test_isunique  s   rl   )
__future__r   r   r   r3   petl.errorsr   petl.test.helpersr   petl.transform.dedupr   r   r	   r
   r   r/   r2   r6   r:   r>   rD   rE   rF   rO   rP   rU   rY   r]   rh   ri   rl   r-   r-   r-   r.   <module>   s*    
!3