o
    .j                     @   s(  d Z 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
 ddlmZ ddlmZ dd	lmZ dd
lmZ eje
eeegddd Zdd ZdedefddZdedefddZdedefddZejdeddddddedddddfeddddddedddddfedddd dd!edddd dfeddddedddfgejd"eeegd#d$ Zejd%d&e gd'd( Zejd%d)ee gd*d+ Zd,d- Zd.d/ Zejd0d1gdd2d3 Z ejd4ed5dd6d7d8d9ed5dd6gd:d; Z!d<d= Z"d>d? Z#d@dA Z$dBdC Z%dS )Dz%Test common properties of components.    )datedatetime	timedeltaN	vDDDTypes)	Component)Event)FreeBusy)Journal)Todo)InvalidCalendar)paramsc                 C   s   |   S )za component to testparamrequest r   X/home/thesage/.local/lib/python3.10/site-packages/icalendar/tests/attr/test_component.pydtstamp_comp   s   r   c                 C   s   | j du sJ dS )zWe have None as a value.NDTSTAMP)r   r   r   r   test_no_dtstamp   s   r   	componentvaluec                 C   s
   || _ dS )zUse the setter.Nr   r   r   r   r   r   set_dtstamp_attribute   s   
r   c                 C   s   t || d< dS )zUse setitem.r   Nr   r   r   r   r   set_dtstamp_item       r   c                 C   s   |  d| dS )zUse add.r   N)addr   r   r   r   set_dtstamp_add%   r   r   )r   timezoneexpectedi  
            zEurope/Berlin      UTCset_dtstampc           	      C   s^   |du r|n| ||}|| | ||}| dj}||ks&|tks&J || jks-J dS )zSet and get the DTSTAMP value.Nr   )localizelocalize_utcgetdtr   r   )	r   r   r    r!   tzpr)   dtstampin_utc	get_valuer   r   r   test_set_value_and_get_it*   s   

r2   invalid_valueasdasdc                 C   sN   t t}| |_W d   n1 sw   Y  |jjd d|  ks%J dS )!Check handling of invalid values.Nr   z%DTSTAMP takes a datetime in UTC, not )pytestraises	TypeErrorr   r   argsr3   r   er   r   r   test_set_invalid_valueB   s   r<   ashdkjasjkdkdc                 C   s^   | |d< t t}|j W d   n1 sw   Y  |jjd dt| d|  ks-J dS )r5   r   Nr   z'DTSTAMP must be a datetime in UTC, not r-   )r6   r7   r   r   r   r9   getattrr:   r   r   r   test_get_invalid_valueJ   s   
r?   c                 C   s<   t ddd| _t ddd| _|tddd| jksJ dS )zSet the value twice.  r%      N)r   r   r+   r   r   r.   r   r   r   test_set_twiceV   s    rC   c                 C   s.   t ddd| _|tddd| jksJ dS )z9Check we can set LAST_MODIFIED in the same way as DTSTAMPr@   r%   rA   N)r   LAST_MODIFIEDr+   r   rB   r   r   r   test_last_modified]   s    rE   last_modifiedcreatedc                 C   s   | j S )z2These parameters default to the DTSTAMP attribute.r   r   r   r   r   attr_depending_on_dtstampc   s   rH   r-                  c                 C   s"   | |_ t||}||j ksJ dS )zIn the case of an iCalendar object that doesn't specify a "METHOD"
    property, "DTSTAMP" property is equivalent to the "LAST-MODIFIED"
    property.N)stampr>   )r-   r.   crH   r   r   r   r   &test_last_modified_defaults_to_dtstampi   s   
rP   c              
   C   s,   t | |tdddddd | jdu sJ dS z4Setting last modified does not override the dtstamp.rI   r"   rJ   rK   rL   rM   N)setattrr   r   rO   rH   r   r   r   test_set_last_modifiedu   s   rT   c              
   C   sH   t ddd| _t| |t dddddd | j|t dddks"J dS rQ   )r   r   rR   r+   )rO   r.   rH   r   r   r   test_set_last_modified_2{   s    rU   c                 C   s    t | | t| |du sJ dS )zDelete the absent value.N)delattrr>   rS   r   r   r   test_delete_last_modified_1   s   
rW   c              
   C   s:   t | |tdddddd t| | t| |du sJ dS )zDelete the present value.rI   r"   rJ   rK   rL   rM   N)rR   r   rV   r>   rS   r   r   r   test_delete_last_modified_2   s   
rX   )&__doc__r   r   r   r6   	icalendarr   icalendar.cal.componentr   icalendar.cal.eventr   icalendar.cal.free_busyr	   icalendar.cal.journalr
   icalendar.cal.todor   icalendar.errorr   fixturer   r   r   r   r   markparametrizer2   r<   r?   rC   rE   rH   rP   rT   rU   rW   rX   r   r   r   r   <module>   sX    
   	




	