a
    ©ˆc€	  ã                   @   sV   d Z ddlZddlmZmZmZ ddlmZmZ G dd„ deƒZ	G dd„ dej
ƒZdS )	ú% Tests for the 'Service' trait type. é    N)ÚApplicationÚPluginÚService)Ú	HasTraitsÚInstancec                   @   s   e Zd ZdZdZdS )ÚTestApplicationz, The type of application used in the tests. ÚtestN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úid© r   r   ú^/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/envisage/tests/test_service.pyr      s   r   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚServiceTestCaser   c                    sº   G dd„ dt ƒ‰ G ‡ fdd„dtƒ}G ‡ fdd„dtƒ}|ƒ }|ƒ }t||gd�}| ¡  |  |j|j¡ | ¡  |  d|j¡ |  t¡� t	|d	d
ƒ W d  ƒ n1 s¬0    Y  dS )z service trait typec                   @   s   e Zd ZdS )z4ServiceTestCase.test_service_trait_type.<locals>.FooN©r
   r   r   r   r   r   r   ÚFoo    s   r   c                       s   e Zd ZdZe” ddd�ZdS )z8ServiceTestCase.test_service_trait_type.<locals>.PluginAÚAr   T)ÚserviceN)r
   r   r   r   r   Úfoor   ©r   r   r   ÚPluginA#   s   r   c                       s   e Zd ZdZe” ƒZdS )z8ServiceTestCase.test_service_trait_type.<locals>.PluginBÚBN)r
   r   r   r   r   r   r   r   r   r   ÚPluginB'   s   r   )ZpluginsNr   Zbogus)
r   r   r   ÚstartÚassertEqualr   ÚstopÚassertRaisesÚSystemErrorÚsetattr)Úselfr   r   ÚaÚbZapplicationr   r   r   Útest_service_trait_type   s    z'ServiceTestCase.test_service_trait_typec                    sb   G dd„ dt ƒ‰ G ‡ fdd„dt ƒ}|ƒ }|  t¡� t|dƒ W d  ƒ n1 sT0    Y  dS )z- service trait type with no service registry c                   @   s   e Zd ZdS )zMServiceTestCase.test_service_trait_type_with_no_service_registry.<locals>.FooNr   r   r   r   r   r   A   s   r   c                       s   e Zd Ze” ƒZdS )zMServiceTestCase.test_service_trait_type_with_no_service_registry.<locals>.BarN)r
   r   r   r   r   r   r   r   r   ÚBarD   s   r%   r   N)r   r   Ú
ValueErrorÚgetattr)r!   r%   r#   r   r   r   Ú0test_service_trait_type_with_no_service_registry>   s
    z@ServiceTestCase.test_service_trait_type_with_no_service_registryc                 C   sL   G dd„ dt ƒ}d}t|ƒ}|  | |¡t|ƒ¡ |  | |¡t|ƒ¡ dS )z/ test the string representation of the service c                   @   s   e Zd ZdS )z<ServiceTestCase.test_service_str_representation.<locals>.FooNr   r   r   r   r   r   P   s   r   zService(protocol={!r})N)r   r   r   ÚformatÚstrÚrepr)r!   r   Zservice_reprr   r   r   r   Útest_service_str_representationM   s
    z/ServiceTestCase.test_service_str_representationN)r
   r   r   r   r$   r(   r,   r   r   r   r   r      s   !r   )r   ZunittestZenvisage.apir   r   r   Z
traits.apir   r   r   ZTestCaser   r   r   r   r   Ú<module>
   s
   