U
    k&p[  ã                   @   sN   d dl Z d dlmZ G dd„ de jƒZG dd„ de jƒZG dd„ de jƒZdS )	é    N)ÚPluginManagerc                   @   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 )ÚPluginManagerInitialStateTestsc                 C   s   t ƒ | _d S ©N)r   Úpm©Úself© r   ú8/usr/lib/python3/dist-packages/cliapp/pluginmgr_tests.pyÚsetUp   s    z$PluginManagerInitialStateTests.setUpc                 C   s   |   | jjg ¡ d S r   )ÚassertEqualr   Ú	locationsr   r   r   r	   Útest_locations_is_empty_list   s    z;PluginManagerInitialStateTests.test_locations_is_empty_listc                 C   s   |   | jjg ¡ d S r   )r   r   Úpluginsr   r   r   r	   Útest_plugins_is_empty_list   s    z9PluginManagerInitialStateTests.test_plugins_is_empty_listc                 C   s   |   | jjd¡ d S )Nz0.0.0)r   r   Úapplication_versionr   r   r   r	   Ú"test_application_version_is_zeroes"   s    zAPluginManagerInitialStateTests.test_application_version_is_zeroesc                 C   s   |   | jjg ¡ d S r   )r   r   Úplugin_filesr   r   r   r	   Útest_plugin_files_is_empty%   s    z9PluginManagerInitialStateTests.test_plugin_files_is_emptyc                 C   s   |   | jjg ¡ d S r   )r   r   Úplugin_argumentsr   r   r   r	   Útest_plugin_arguments_is_empty(   s    z=PluginManagerInitialStateTests.test_plugin_arguments_is_emptyc                 C   s   |   | jji ¡ d S r   )r   r   Úplugin_keyword_argumentsr   r   r   r	   Ú&test_plugin_keyword_arguments_is_empty+   s    zEPluginManagerInitialStateTests.test_plugin_keyword_arguments_is_emptyN)
Ú__name__Ú
__module__Ú__qualname__r
   r   r   r   r   r   r   r   r   r   r	   r      s   r   c                   @   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 )ÚPluginManagerTestsc                 C   s>   t ƒ | _ddg| j_d| j_ddi| j_tdddd	gƒ| _d S )
Nztest-pluginsz	not-exist)ÚfooargÚbarÚbarargztest-plugins/hello_plugin.pyz test-plugins/aaa_hello_plugin.pyztest-plugins/oldhello_plugin.pyz#test-plugins/wrongversion_plugin.py)r   r   r   r   r   ÚsortedÚfilesr   r   r   r	   r
   1   s    ýzPluginManagerTests.setUpc                 C   s   |   | j ¡ | j¡ d S r   )r   r   Zfind_plugin_filesr    r   r   r   r	   Ú!test_finds_the_right_plugin_files<   s    z4PluginManagerTests.test_finds_the_right_plugin_filesc                 C   s   |   | jj| j¡ d S r   )r   r   r   r    r   r   r   r	   Ú/test_plugin_files_attribute_implicitly_searches?   s    zBPluginManagerTests.test_plugin_files_attribute_implicitly_searchesc                 C   s0   | j  ¡ }|  t|ƒd¡ |  |d jd¡ d S ©Né   r   ÚHello)r   Zload_pluginsr   ÚlenÚname)r   r   r   r   r	   Útest_loads_hello_pluginB   s    
z*PluginManagerTests.test_loads_hello_pluginc                 C   s.   |   t| jjƒd¡ |   | jjd jd¡ d S r#   )r   r&   r   r   r'   r   r   r   r	   Ú*test_plugins_attribute_implicitly_searchesG   s    z=PluginManagerTests.test_plugins_attribute_implicitly_searchesc                 C   s*   | j d }|  |jd¡ |  |jd¡ d S )Nr%   r   r   )r   r   Zfoor   )r   Zpluginr   r   r	   Ú(test_initializes_hello_with_correct_argsK   s    
z;PluginManagerTests.test_initializes_hello_with_correct_argsc                 C   s   |   t| jjd¡ d S )NZHithere)ZassertRaisesÚKeyErrorr   Ú__getitem__r   r   r   r	   Ú'test_raises_keyerror_for_unknown_pluginP   s    z:PluginManagerTests.test_raises_keyerror_for_unknown_pluginN)
r   r   r   r
   r!   r"   r(   r)   r*   r-   r   r   r   r	   r   /   s   r   c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )Ú.PluginManagerCompatibleApplicationVersionTestsc                 C   s   t ƒ | _d| j_d S ©Nz1.2.3)r   r   r   r   r   r   r	   r
   V   s    z4PluginManagerCompatibleApplicationVersionTests.setUpc                 C   s   |   | j d¡¡ d S )NÚ0©ZassertFalser   Úcompatible_versionr   r   r   r	   Útest_rejects_zeroZ   s    z@PluginManagerCompatibleApplicationVersionTests.test_rejects_zeroc                 C   s   |   | j d¡¡ d S )NÚ2r1   r   r   r   r	   Útest_rejects_two]   s    z?PluginManagerCompatibleApplicationVersionTests.test_rejects_twoc                 C   s   |   | j d¡¡ d S )Nz1.2.4r1   r   r   r   r	   Útest_rejects_one_two_four`   s    zHPluginManagerCompatibleApplicationVersionTests.test_rejects_one_two_fourc                 C   s   |   | j d¡¡ d S )NÚ1©Z
assertTruer   r2   r   r   r   r	   Útest_accepts_onec   s    z?PluginManagerCompatibleApplicationVersionTests.test_accepts_onec                 C   s   |   | j d¡¡ d S r/   r8   r   r   r   r	   Útest_accepts_one_two_threef   s    zIPluginManagerCompatibleApplicationVersionTests.test_accepts_one_two_threeN)	r   r   r   r
   r3   r5   r6   r9   r:   r   r   r   r	   r.   T   s   r.   )ZunittestZcliappr   ZTestCaser   r   r.   r   r   r   r	   Ú<module>   s   %