o
    gA                     @   s   d dl Z d dlmZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
Z
d dlmZ d dlmZ d dlmZ d dlmZ d	Zd
ZG dd de jZG dd de jZdS )    N)datedatetime	timedelta)Decimal)Optional)UUID)tzutc)	BaseModel)utils+kOOlRy2QlMY9jHZQv0bKz0FZyazBUoY8Arj0lFVNjs4
random_keyc                   @   sD   e Z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 )	TestUtilsc                 C   sj   t  }t jt d}| t| | t| t|}| t| t|}| || d S )N)tz)	r   nowr   
assertTruer
   is_naiveassertFalseguess_timezoneassertEqual)selfr   utcnowfixedshouldnt_be_edited r   N/var/www/visachat/venv/lib/python3.10/site-packages/posthog/test/test_utils.pytest_timezone_utils   s   

zTestUtils.test_timezone_utilsc              
   C   s   t dtdt dddddd d	}tdtd	d
g dd}t| }|	|  |
 }t| | |
 | | ttdd d S )Nz0.142857wooi    g       @T)	decimalunicoder   longintegerfloatboolstrnonezThis should show up   )microseconds)r         )	exceptionr   list 12345678123456781234567812345678z$12345678-1234-5678-1234-567812345678)r   sixur   r   	Exceptionr   dictitemsupdatekeysr
   cleanr   r   )r   simplecomplicatedcombinedpre_clean_keysr   r   r   
test_clean   s(   
zTestUtils.test_cleanc                 C   s,   t dddt d}| |t| d S )Ni  r   )	birthdateregistration)r   r   r   r   r
   r4   )r   dict_with_datesr   r   r   test_clean_with_dates=   s   
zTestUtils.test_clean_with_datesc                 C   s&   t jrtd}ntd}t| d S )N
   )r-   PY3bytes	bytearrayr
   r4   )r   itemr   r   r   
test_bytesD   s   
zTestUtils.test_bytesc                 C   sD   t dd dd}| |d d d|v r | |d d  d S d S )Nc                 S   s   | S Nr   )xr   r   r   <lambda>M       z)TestUtils.test_clean_fn.<locals>.<lambda>   )fnnumberrJ   rI   )r
   r4   r   )r   cleanedr   r   r   test_clean_fnL   s
   zTestUtils.test_clean_fnc                 C   s(   |  dtd |  dtd d S )Nzhttp://posthog.iozhttp://posthog.io/)r   r
   remove_trailing_slash)r   r   r   r   test_remove_slashS   s   zTestUtils.test_remove_slashc              
      s   G dd dt  G dd dt}G  fdddt }| t ddd	ddd d
 | t|ddd	ddd	 | t| dddd
dddddd
i G dd d}| td| ii  d S )Nc                   @   s.   e Zd ZU eed< eed< dZee ed< dS )z.TestUtils.test_clean_pydantic.<locals>.ModelV2foobarNbaz)__name__
__module____qualname__r$   __annotations__intrQ   r   r   r   r   r   ModelV2X   s   
 rW   c                   @   s   e Zd ZU eed< eed< dS )z.TestUtils.test_clean_pydantic.<locals>.ModelV1rO   rP   N)rR   rS   rT   rV   rU   r$   r   r   r   r   ModelV1]   s   
 rX   c                       s   e Zd ZU  ed< dS )z2TestUtils.test_clean_pydantic.<locals>.NestedModelrO   N)rR   rS   rT   rU   r   rW   r   r   NestedModela   s   
 rZ   1r(   )rO   rP   )rO   rP   rQ   r   23)rO   rO   c                   @      e Zd Zdd ZdS )z,TestUtils.test_clean_pydantic.<locals>.Dummyc                 S   s   d S rD   r   )r   required_paramr   r   r   
model_dumpk   s   z7TestUtils.test_clean_pydantic.<locals>.Dummy.model_dumpN)rR   rS   rT   r`   r   r   r   r   Dummyj       ra   test)r	   BaseModelV1r   r
   r4   )r   rX   rZ   ra   r   rY   r   test_clean_pydanticW   s   " &zTestUtils.test_clean_pydanticN)
rR   rS   rT   r   r9   r=   rC   rL   rN   re   r   r   r   r   r      s    r   c                   @   r^   )TestSizeLimitedDictc                 C   s   d}t |dd }tdD ]H}|||< | || | | t||| d  || dkrV| ||d  | ||d  | ||d  | ||d	  qd S )
Nr>   c                 S   s   dS )Nr   )_r   r   r   rF   u   rG   z<TestSizeLimitedDict.test_size_limited_dict.<locals>.<lambda>d   r   r   r)      	   )r
   SizeLimitedDictranger   lenassertIsNoneget)r   sizevaluesir   r   r   test_size_limited_dicts   s   z*TestSizeLimitedDict.test_size_limited_dictN)rR   rS   rT   rt   r   r   r   r   rf   r   rb   rf   )unittestr   r   r   r   r   typingr   uuidr   r-   dateutil.tzr   pydanticr	   pydantic.v1rd   posthogr
   TEST_API_KEYFAKE_TEST_API_KEYTestCaser   rf   r   r   r   r   <module>   s    `