
    iz-                         d Z ddlmZmZmZ ddlZddlmZmZ ddlm	Z	m
Z
mZmZmZmZmZ ddlmZmZ  G d d          Z G d	 d
          ZdS )zDTests for consolidated attribute functions in icalendar.attr module.    )datedatetime	timedeltaN)EventTodo)get_duration_propertyget_end_property&get_start_end_duration_with_validationget_start_propertyset_duration_with_lockingset_end_with_lockingset_start_with_locking)IncompleteComponentInvalidCalendarc                   Z    e Zd 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dZddZdS )TestConsolidatedSettersz7Test consolidated setter functions from icalendar.attr.returnNc           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t          dddd
d          dd           |j        t          dddd
d          k    sJ |j        t          dddd	d          k    sJ |j        t          d          k    sJ dS )z1Test set_start_with_locking for Event components.UID
test-eventDTSTART        r   DTEND   
   end   hoursN)r   addr   r   startr   durationr   selfevents     o/var/www/prod/INCONGRUES/venv/lib/python3.11/site-packages/icalendar/tests/test_consolidation_attr_functions.py!test_set_start_with_locking_eventz9TestConsolidatedSetters.test_set_start_with_locking_event   s    		%&&&		)XdAq"a88999		'8D!QA66777 	uhtQ2q&A&A5'RRR{htQ2q999999yHT1aQ777777~!3!3!3333333    c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t          dddd
d          dd           |j        t          dddd
d          k    sJ |j        t          dddd	d          k    sJ |j        t          d          k    sJ dS )z0Test set_start_with_locking for Todo components.r   	test-todor   r   r   r   r   DUEr   r   r   r   r    N)r   r"   r   r   r#   r   r$   r   r&   todos     r(    test_set_start_with_locking_todoz8TestConsolidatedSetters.test_set_start_with_locking_todo%   s    vv$$$HT1aQ77888q!R33444 	tXdAq"a%@%@%OOOzXdAq"a888888x8D!QA666666}	 2 2 2222222r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t          dddd
d          dd           |j        t          ddddd          k    sJ |j        t          dddd
d          k    sJ |j        t          d          k    sJ dS )z/Test set_end_with_locking for Event components.r   r   r   r   r   r   r   r   r      r#   r   r    N)r   r"   r   r   r#   r   r$   r   r%   s     r(   test_set_end_with_locking_eventz7TestConsolidatedSetters.test_set_end_with_locking_event3   s    		%&&&		)XdAq"a88999		'8D!QA66777 	UHT1aQ$?$?'RRR{htQ2q999999yHT1aQ777777~!3!3!3333333r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t          dddd
d          dd           |j        t          ddddd          k    sJ |j        t          dddd
d          k    sJ |j        t          d          k    sJ dS )z.Test set_end_with_locking for Todo components.r   r,   r   r   r   r   r   r-   r   r2   r#   r   r    N)r   r"   r   r   r#   r   r$   r   r.   s     r(   test_set_end_with_locking_todoz6TestConsolidatedSetters.test_set_end_with_locking_todoA   s    vv$$$HT1aQ77888q!R33444 	T8D!QA#>#>OOOzXdAq"a888888x8D!QA666666}	 2 2 2222222r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t	          d
          dd           |j        t          ddddd          k    sJ |j        t          ddddd          k    sJ |j        t	          d
          k    sJ dS )z4Test set_duration_with_locking for Event components.r   r   r   r   r   r   r   r   r      r    r#      N)r   r"   r   r   r   r#   r   r$   r%   s     r(   $test_set_duration_with_locking_eventz<TestConsolidatedSetters.test_set_duration_with_locking_eventO   s    		%&&&		)XdAq"a88999		'8D!QA66777 	"%);););WgNNN{htQ2q999999yHT1aQ777777~!3!3!3333333r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t	          d
          dd           |j        t          ddddd          k    sJ |j        t          ddddd          k    sJ |j        t	          d
          k    sJ dS )z3Test set_duration_with_locking for Todo components.r   r,   r   r   r   r   r   r-   r   r7   r    r#   r8   N)r   r"   r   r   r   r#   r   r$   r.   s     r(   #test_set_duration_with_locking_todoz;TestConsolidatedSetters.test_set_duration_with_locking_todo]   s    vv$$$HT1aQ77888q!R33444 	"$	(:(:(:GUKKKzXdAq"a888888x8D!QA666666}	 2 2 2222222r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          d	
                     t	          |t          ddddd          dd           |j        t          ddddd          k    sJ |j        t          d	
          k    sJ |j        t          ddddd          k    sJ dS )z(Test auto-detection of property locking.r   r   r   r   r   r   r   DURATION   r    r   Nr   )r   r"   r   r   r   r#   r$   r   r%   s     r(   !test_auto_detect_property_lockingz9TestConsolidatedSetters.test_auto_detect_property_lockingk   s    		%&&&		)XdAq"a88999		*ia000111 	T1aQ''		
 	
 	
 {htQ2q999999~!3!3!33333yHT1aQ77777777r*   c                 N   t                      }|                    dd           t          j        t          d          5  t          |t          ddddd          d	d
           ddd           n# 1 swxY w Y   t          j        t          d          5  t          |t          ddddd          d	d
           ddd           n# 1 swxY w Y   t          j        t          d          5  t          |t          d          d	d
           ddd           dS # 1 swxY w Y   dS )z.Test error handling in consolidated functions.r   r   zlocked must bematchr   r   r   r   invalidr   Nr    )
r   r"   pytestraises
ValueErrorr   r   r   r   r   r%   s     r(   *test_error_handling_consolidated_functionszBTestConsolidatedSetters.test_error_handling_consolidated_functions~   s   		%&&& ]:-=>>> 	 	"q!R++	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]:-=>>> 	 	 q!R++	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ]:-=>>> 	 	%"""	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s6    $A00A47A4$CC
C
,!DD!Dc           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t                      }|                    dd
           |                    dt          ddddd                     |                    dt          dddd	d                     t          |t          ddddd          dd           |                    t          ddddd          d           |j        |j        k    sJ |j        |j        k    sJ |j        |j        k    sJ dS )z=Test that consolidated functions maintain identical behavior.r   ztest-event-1r   r   r   r   r   r   r   ztest-event-2r   r   )lockedN)r   r"   r   r   	set_startr#   r   r$   )r&   event1event2s      r(   7test_consolidated_functions_maintain_identical_behaviorzOTestConsolidatedSetters.test_consolidated_functions_maintain_identical_behavior   sp    

5.)))

9htQ2q99:::

7HT1aQ77888

5.)))

9htQ2q99:::

7HT1aQ77888 	T1aQ''		
 	
 	
 	$1b!44UCCC |v|++++zVZ''''&/111111r*   r   N)__name__
__module____qualname____doc__r)   r0   r3   r5   r9   r;   r?   rG   rM    r*   r(   r   r      s        AA4 4 4 43 3 3 34 4 4 43 3 3 34 4 4 43 3 3 38 8 8 8&   <2 2 2 2 2 2r*   r   c                   Z    e Zd 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dZddZdS )TestConsolidatedPropertyGettersz,Test consolidated property getter functions.r   Nc           
      .   t                      }|                    dd           |                    dt          ddddd                     |                    dt          d	                     t	          |          }|t          d	          k    sJ d
S )z;Test get_duration_property when DURATION is explicitly set.r   ztest-durationr   r   r   r   r   r=   r    N)r   r"   r   r   r   r&   r'   r$   s      r(   ,test_get_duration_property_with_duration_setzLTestConsolidatedPropertyGetters.test_get_duration_property_with_duration_set   s    		%)))		)XdAq"a88999		*ia000111(//91---------r*   c           
      4   t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |          }|t	          d
          k    sJ dS )z:Test get_duration_property when calculated from start/end.r   ztest-calculatedr   r   r   r   r   r   r8   r7   r    N)r   r"   r   r   r   rW   s      r(   %test_get_duration_property_calculatedzETestConsolidatedPropertyGetters.test_get_duration_property_calculated   s    		%*+++		)XdAq"a88999		'8D!QA66777(//91---------r*   c           
          t                      }|                    dd           |                    dt          ddddd                     t          |          }|t          ddddd          k    sJ dS )	z%Test get_start_property success case.r   
test-startr   r   r   r   r   N)r   r"   r   r   )r&   r'   r#   s      r(   test_get_start_property_successz?TestConsolidatedPropertyGetters.test_get_start_property_success   sw    		%&&&		)XdAq"a88999"5))q!R33333333r*   c                     t                      }|                    dd           t          j        t          d          5  t          |           ddd           dS # 1 swxY w Y   dS )z0Test get_start_property when DTSTART is missing.r   r\   zNo DTSTART givenrA   N)r   r"   rD   rE   r   r   r%   s     r(   test_get_start_property_missingz?TestConsolidatedPropertyGetters.test_get_start_property_missing   s    		%&&&].6HIII 	& 	&u%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s    AA!$A!c           
      <   t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |d          }|t          dddd	d          k    sJ d
S )z(Test get_end_property when DTEND is set.r   ztest-endr   r   r   r   r   r   r8   N)r   r"   r   r	   r&   r'   r   s      r(    test_get_end_property_with_dtendz@TestConsolidatedPropertyGetters.test_get_end_property_with_dtend   s    		%$$$		)XdAq"a88999		'8D!QA66777ug..htQ2q11111111r*   c           
      6   t                      }|                    dd           |                    dt          ddddd                     |                    dt          d	
                     t	          |d          }|t          ddddd          k    sJ dS )z+Test get_end_property when DURATION is set.r   ztest-duration-endr   r   r   r   r   r=   r7   r    r   r8   N)r   r"   r   r   r	   ra   s      r(   #test_get_end_property_with_durationzCTestConsolidatedPropertyGetters.test_get_end_property_with_duration   s    		%,---		)XdAq"a88999		*ia000111ug..htQ2q11111111r*   c           
         t                      }|                    dd           |                    dt          ddd                     t          |d          }|t          ddd          k    sJ t                      }|                    dd           |                    dt	          dddd	d
                     t          |d          }|t	          dddd	d
          k    sJ dS )z'Test get_end_property default behavior.r   ztest-defaultr   r   r   r   r>   ztest-default-2r   r   N)r   r"   r   r	   r   )r&   r'   r   rL   end2s        r(   &test_get_end_property_default_behaviorzFTestConsolidatedPropertyGetters.test_get_end_property_default_behavior   s    		%(((		)T$1--...ug..d4A&&&&&&

5*+++

9htQ2q99:::00xaB22222222r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     t          |ddd
          \  }}}|t          ddddd          k    sJ |t          dddd	d          k    sJ |J dS )z9Test get_start_end_duration_with_validation success case.r   ztest-validationr   r   r   r   r   r   r8   VEVENTN)r   r"   r   r
   )r&   r'   r#   r   r$   s        r(   .test_get_start_end_duration_validation_successzNTestConsolidatedPropertyGetters.test_get_start_end_duration_validation_success  s    		%*+++		)XdAq"a88999		'8D!QA66777E	 
  
sH q!R333333htQ2q111111r*   c           
         t                      }|                    dd           |                    dt          ddddd                     |                    dt          dddd	d                     |                    d
t          d                     t	          j        t          d          5  t          |ddd           ddd           n# 1 swxY w Y   t                      }|                    dd           |                    dt          ddd                     |                    d
t          d                     t	          j        t          d          5  t          |ddd           ddd           n# 1 swxY w Y   t                      }|                    dd           |                    dt          ddd                     |                    dt          dddd	d                     t	          j        t          d          5  t          |ddd           ddd           dS # 1 swxY w Y   dS )z8Test get_start_end_duration_with_validation error cases.r   z	test-bothr   r   r   r   r   r   r8   r=   r>   r    zOnly one of DTEND and DURATIONrA   ri   Nztest-date-durationzDURATION must be of daysztest-type-mismatchzmust be of the same type)	r   r"   r   r   rD   rE   r   r
   r   )r&   r'   rL   event3s       r(   -test_get_start_end_duration_validation_errorszMTestConsolidatedPropertyGetters.test_get_start_end_duration_validation_errors  s    		%%%%		)XdAq"a88999		'8D!QA66777		*ia000111]?2RSSS 	 	2	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 

5.///

9d4A..///

:yq111222]?2LMMM 	 	2	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 

5.///

9d4A..///

7HT1aQ77888]?2LMMM 	 	2	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s6   2CCC$FF
FH99H= H=rN   )rO   rP   rQ   rR   rX   rZ   r]   r_   rb   rd   rg   rj   rm   rS   r*   r(   rU   rU      s        66. . . .. . . .4 4 4 4& & & &2 2 2 22 2 2 23 3 3 3        "+ + + + + +r*   rU   )rR   r   r   r   rD   	icalendarr   r   icalendar.attrr   r	   r
   r   r   r   r   icalendar.errorr   r   r   rU   rS   r*   r(   <module>rq      s,   J J . . . . . . . . . .  ! ! ! ! ! ! ! !                  A @ @ @ @ @ @ @a2 a2 a2 a2 a2 a2 a2 a2HH H H H H H H H H Hr*   