U
    fR                     @   s   d dl Z d dlZd dlmZ G dd deZG dd deZG dd deZG d	d
 d
eZG dd deZ	G dd deZ
dS )    N)helpersc                   @   s   e Zd Zdd Zdd ZdS )FromKeyedIterableTestCasec                 C   sh   t jddt jddt jddt jddg}|d |d g|d g|d gd	}t|d
|ksdtd S )N   )keyredbluer            )r   r   r   r   mockZMockr   Zfrom_keyed_iterableAssertionError)selfiterableexpected_dict r   </tmp/pip-unpacked-wheel-2893xuzv/tests/dicts/helpers_test.py
test_basic   s    



z$FromKeyedIterableTestCase.test_basicc                 C   sl   t jdddt jdddt jdddt jdddg}dd }|d	 g|d
 gd}t|d||kshtd S )Nr   F)r   keepTr   r   c                 S   s   | j S )N)r   )er   r   r   <lambda>        z<FromKeyedIterableTestCase.test_filter_func.<locals>.<lambda>r   r
   )r   r   r   r   )r   r   filter_funcr   r   r   r   test_filter_func   s    z*FromKeyedIterableTestCase.test_filter_funcN)__name__
__module____qualname__r   r   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd Zdd ZdS )SubtractByKeyTestCasec                 C   s8   d d d d}d d d}d d d}t |||ks4td S )N)r   r	   r
   r      r	   r
   r   Zsubtract_by_keyr   r   dict_adict_br   r   r   r   test+   s    zSubtractByKeyTestCase.testc                 C   sH   i }d d d}t ||i ks"td d d}i }t |||ksDtd S )Nr   r!   r   r#   r$   r   r   r   
test_empty>   s    

z SubtractByKeyTestCase.test_emptyN)r   r   r   r%   r'   r   r   r   r   r   *   s   r   c                   @   s.   e Zd Zeddd Zdd Zdd ZdS )	SubtractTestCasez#utils.dicts.helpers.subtract_by_keyc                 C   s0   t j|_td d d|jks t|d d  d S )NF)r   sentinelZreturn_valuer   subtractr   Zassert_called_once_with)r   Z	sbk_patchr   r   r   test_not_strictK   s    z SubtractTestCase.test_not_strictc                 C   s@   d dd dd}d dd d}ddd d}t ||d|ks<td S )NZGreenZYellowr   r	   r
      ZBlue)r   r-   r   )r	   r-   r
   Tr   r*   r   r"   r   r   r   r%   Q   s    zSubtractTestCase.testc                 C   sP   i }d d d}i }t ||di ks(td d d}i }t ||d|ksLtd S )Nr   Tr.   r&   r   r   r   r'   g   s    

zSubtractTestCase.test_emptyN)r   r   r   r   patchr+   r%   r'   r   r   r   r   r(   J   s   
r(   c                   @   s*   e Zd Zejdd Zdd Zdd ZdS )WinnowByKeysTestCasec                 C   s   d ddt dS NTFr,   intr   r   r   r   dctv   s
    zWinnowByKeysTestCase.dctc                 C   s>   t j|ddgd}|jd tdks&t|jdddks:td S )Nr   r-   )keysr   r-   TFr    r   Zwinnow_by_keysZhasr3   r   Zhas_notr   r5   resultr   r   r   r%      s    zWinnowByKeysTestCase.testc                 C   s>   t j|dd d}|jdtdks&t|jd ddks:td S )Nc                 S   s   | d dkS )Nr	   r   r   )kr   r   r   r      r   z7WinnowByKeysTestCase.test_filter_func.<locals>.<lambda>)r   T)r	   r-   Fr   r
   r8   r9   r   r   r   r      s    z%WinnowByKeysTestCase.test_filter_funcN)r   r   r   pytestfixturer5   r%   r   r   r   r   r   r0   u   s   
r0   c                   @   s8   e Zd Zejdd Zejdd Zdd Zdd Zd	S )
IntersectionTestCasec                 C   s   d ddt dS r1   r2   r4   r   r   r   r#      s
    zIntersectionTestCase.dict_ac                 C   s   d dt ddS )NFT)r   r
   r-   r   )boolr4   r   r   r   r$      s
    zIntersectionTestCase.dict_bc                 C   s   t ||d ddkstd S )NFr<   )r   intersectionr   r&   r   r   r   r%      s    zIntersectionTestCase.testc                 C   s"   t ||dd dtdkstd S )NF)r   r
   r-   )r   rA   r3   r   r&   r   r   r   r+      s    z$IntersectionTestCase.test_not_strictN)	r   r   r   r=   r>   r#   r$   r%   r+   r   r   r   r   r?      s   

r?   c                   @   s   e Zd Zdd ZdS )SetDefaultsTestCasec                 C   s<   d dd}dt dd}t||}|d dt ddks8td S )NFr7   TRED)r	   r
   r-   r,   )r3   r   Zsetdefaultsr   )r   targetdefaultsr:   r   r   r   r%      s    zSetDefaultsTestCase.testN)r   r   r   r%   r   r   r   r   rB      s   rB   )r   r=   Zutils.dictsr   objectr   r   r(   r0   r?   rB   r   r   r   r   <module>   s   # +