
    i
                     8    d Z ddlZddlmZ  G d d          ZdS )z&Tests for Component.register() method.    N)	Componentc                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	TestComponentRegisterz!Test Component.register() method.c                      G d dt                     }t          j        |           t          j        d          }||u sJ  |            }|j        dk    sJ |                                dk    sJ dS )z'Register a custom component and use it.c                       e Zd ZdZd ZdS )JTestComponentRegister.test_register_custom_component.<locals>.XMyComponentX-MY-COMPONENTc                     dS )Ncustom_value selfs    b/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/tests/test_component_register.pycustom_methodzXTestComponentRegister.test_register_custom_component.<locals>.XMyComponent.custom_method   s    %~    N)__name__
__module____qualname__namer   r   r   r   XMyComponentr      s(        #D& & & & &r   r   r	   r   N)r   registerget_component_classr   r   )r   r   	retrievedcomps       r   test_register_custom_componentz4TestComponentRegister.test_register_custom_component   s    	& 	& 	& 	& 	&9 	& 	& 	& 	<((( 12BCC	L(((( y{{y,,,,,!!##~555555r   c                      G d dt                     }t          j        t          d          5  t          j        |           ddd           dS # 1 swxY w Y   dS )z?Registering component without name attribute raises ValueError.c                       e Zd ZdS )WTestComponentRegister.test_register_component_without_name_raises.<locals>.BadComponentN)r   r   r   r   r   r   BadComponentr   "   s        Dr   r   must have a 'name' attributematchNr   pytestraises
ValueErrorr   r   r   s     r   +test_register_component_without_name_raiseszATestComponentRegister.test_register_component_without_name_raises   s    	 	 	 	 	9 	 	 	 ]:-KLLL 	- 	-|,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-   AAAc                      G d dt                     }t          j        t          d          5  t          j        |           ddd           dS # 1 swxY w Y   dS )z7Registering component with None name raises ValueError.c                       e Zd ZdZdS )YTestComponentRegister.test_register_component_with_none_name_raises.<locals>.BadComponentNr   r   r   r   r   r   r   r   r,   +   s        DDDr   r   r    r!   Nr#   r'   s     r   -test_register_component_with_none_name_raiseszCTestComponentRegister.test_register_component_with_none_name_raises(   s    	 	 	 	 	9 	 	 	 ]:-KLLL 	- 	-|,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-r)   c                 
    G d dt                     } G d dt                     }t          j        |           t          j        t          d          5  t          j        |           ddd           dS # 1 swxY w Y   dS )z8Registering same component name twice raises ValueError.c                       e Zd ZdZdS )STestComponentRegister.test_register_duplicate_component_raises.<locals>.XComponent1X-DUPLICATENr-   r   r   r   XComponent1r1   4            DDDr   r3   c                       e Zd ZdZdS )STestComponentRegister.test_register_duplicate_component_raises.<locals>.XComponent2r2   Nr-   r   r   r   XComponent2r6   7   r4   r   r7   zalready registeredr!   N)r   r   r$   r%   r&   )r   r3   r7   s      r   (test_register_duplicate_component_raisesz>TestComponentRegister.test_register_duplicate_component_raises1   s    	! 	! 	! 	! 	!) 	! 	! 	!	! 	! 	! 	! 	!) 	! 	! 	! 	;''']:-ABBB 	, 	,{+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   A88A<?A<c                 |     G d dt                     }t          j        |           t          j        |           dS )z?Registering the exact same class twice is allowed (idempotent).c                       e Zd ZdZdS )PTestComponentRegister.test_register_same_class_twice_allowed.<locals>.XComponentzX-IDEMPOTENTNr-   r   r   r   
XComponentr;   B   s        !DDDr   r<   N)r   r   )r   r<   s     r   &test_register_same_class_twice_allowedz<TestComponentRegister.test_register_same_class_twice_allowed?   sV    	" 	" 	" 	" 	" 	" 	" 	" 	:&&&:&&&&&r   c                     G d dt                     }t          j        |           d}t          j        |          }t          ||          sJ |j        dk    sJ t          |                                          dk    sJ dS )z3Parsing uses the registered custom component class.c                       e Zd ZdZd ZdS )KTestComponentRegister.test_parse_uses_registered_component.<locals>.XVendorX-VENDORc                 ,    |                      d          S )NzX-VENDOR-ID)getr   s    r   get_vendor_idzYTestComponentRegister.test_parse_uses_registered_component.<locals>.XVendor.get_vendor_idN   s    xx...r   N)r   r   r   r   rD   r   r   r   XVendorr@   K   s(        D/ / / / /r   rE   s9   BEGIN:X-VENDOR
UID:123
X-VENDOR-ID:vendor-1
END:X-VENDOR
rA   zvendor-1N)r   r   	from_ical
isinstancer   strrD   )r   rE   	ical_datar   s       r   $test_parse_uses_registered_componentz:TestComponentRegister.test_parse_uses_registered_componentH   s    	/ 	/ 	/ 	/ 	/i 	/ 	/ 	/ 	7###	
 "9--$(((((yJ&&&&4%%''((J666666r   N)
r   r   r   __doc__r   r(   r.   r8   r=   rJ   r   r   r   r   r      st        ++6 6 6(- - -- - -, , ,' ' '7 7 7 7 7r   r   )rK   r$   	icalendarr   r   r   r   r   <module>rM      sb    , ,       T7 T7 T7 T7 T7 T7 T7 T7 T7 T7r   