%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/launchpadlib/tests/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/launchpadlib/tests/__pycache__/test_launchpad.cpython-312.pyc

�

���cI����dZeZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
	ddlmZddlZddlmZddlmZmZddlmZddlZddlmZdd	lmZdd
lmZmZmZmZmZm Z m!Z!ddlm"Z"dZ#Gd
�de
jH�Z%Gd�de
jH�Z&Gd�de
jH�Z'Gd�de
jH�Z(Gd�de
jH�Z)Gd�de
jH�Z*Gd�de
jH�Z+Gd�de+�Z,Gd�de+�Z-Gd�d e
jH�Z.Gd!�d"e
jH�Z/y#e
$r
ddlmZY��$wxYw)#zTests for the Launchpad class.�)�contextmanagerN)�patch)�ServiceRoot)�AccessToken�Credentials)�uris)�	Launchpad)�UnencryptedFileCredentialStore)�assert_keyring_not_imported�BadSaveKeyring�fake_keyring�FauxSocketModule�InMemoryKeyring�NoNetworkAuthorizationEngine�NoNetworkLaunchpad)�KeyringCredentialStore�http://api.example.com/c��eZdZdZd�Zy)�TestResourceTypeClassesz<launchpadlib must know about restfulclient's resource types.c��tjj�D](\}}|jtj||��*y�N)r�RESOURCE_TYPE_CLASSES�items�assertEqualr	)�self�name�clss   �C/usr/lib/python3/dist-packages/launchpadlib/tests/test_launchpad.py�test_resource_typesz+TestResourceTypeClasses.test_resource_typesBsC��%�:�:�@�@�B�	I�I�D�#����Y�<�<�T�B�C�H�	I�N)�__name__�
__module__�__qualname__�__doc__r�r rrr?s��F�Ir rc�\�eZdZdZd�Zed��Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zy
)�TestNameLookupsz0Test the utility functions in the 'uris' module.c�(�tgd��|_y)N)�
production�	qastaging�staging�dogfood�dev�test_dev�edge)�sorted�aliases�rs r�setUpzTestNameLookups.setUpLs���
�

��r c#�ZK�tjd��5}tjd�d��|jt	|�d�|\}|jt
|jt��|jdt|��ddd�y#1swYyxYw�w)NT��record�always�zno longer exists)�warnings�catch_warnings�simplefilterr�len�
assertTrue�
issubclass�category�DeprecationWarning�assertIn�str)r�caught�warnings   r�edge_deprecation_errorz&TestNameLookups.edge_deprecation_errorYs������
$�
$�D�
1�	<�V��!�!�(�+�����S��[�!�,��J�W��O�O�J�w�'7�'7�9K�L�M��M�M�,�c�'�l�;�	<�	<�	<�s�B+�A=B�	B+�B(�$B+c��|jttjj	��|j
�|jttjj	��|j
�yr)rr0r�
service_roots�keysr1�	web_rootsr2s r�test_short_namesz TestNameLookups.test_short_namesfsP������� 2� 2� 7� 7� 9�:�D�L�L�I�������� 3� 3� 5�6����Er c��|j�5|jtjd�tjd��ddd�y#1swYyxYw�Nr/r)�rErr�lookup_service_rootr2s r�$test_edge_service_root_is_productionz4TestNameLookups.test_edge_service_root_is_productionksO���
(�
(�
*�	�����(�(��0��(�(��6�
�	�	�	���9A�Ac��|j�5|jtjd�tjd��ddd�y#1swYyxYwrL�rErr�lookup_web_rootr2s r� test_edge_web_root_is_productionz0TestNameLookups.test_edge_web_root_is_productiontsO���
(�
(�
*�	�����$�$�V�,��$�$�\�2�
�	�	�	�rPc���|j�5|jtjtj�tjd��ddd�y#1swYyxYw�Nr)�rErrrN�EDGE_SERVICE_ROOTr2s r�-test_edge_service_root_url_becomes_productionz=TestNameLookups.test_edge_service_root_url_becomes_production}�S��
�
(�
(�
*�	�����(�(��)?�)?�@��(�(��6�
�	�	�	���AA!�!A*c���|j�5|jtjtj�tjd��ddd�y#1swYyxYwrV)rErrrS�
EDGE_WEB_ROOTr2s r�)test_edge_web_root_url_becomes_productionz9TestNameLookups.test_edge_web_root_url_becomes_production�sS��
�
(�
(�
*�	�����$�$�T�%7�%7�8��$�$�\�2�
�	�	�	�r[c���|j�5|jtjtj�tjd��ddd�y#1swYyxYwrVrWr2s r�/test_top_level_edge_constant_becomes_productionz?TestNameLookups.test_top_level_edge_constant_becomes_production�rZr[c��|j�5|jtjd�tjd��ddd�y#1swYyxYw)Nzhttps://api.edge.launchpad.net/r)rMr2s r�5test_edge_server_equivalent_string_becomes_productionzETestNameLookups.test_edge_server_equivalent_string_becomes_production�sN��
�
(�
(�
*�	�����(�(�)J�K��(�(��6�
�	�	�	�rPc��|j�5|jtjd�tjd��ddd�y#1swYyxYw)Nzhttps://edge.launchpad.net/r)rRr2s r�9test_edge_web_server_equivalent_string_becomes_productionzITestNameLookups.test_edge_web_server_equivalent_string_becomes_production�sN��
�
(�
(�
*�	�����$�$�%B�C��$�$�\�2�
�	�	�	�rPc���|j�5|jD]8}|jtj|�tj
|��:	ddd�|j�5|jD]8}|jtj|�tj|��:	ddd�d}|jtj|�|�|jtj|�|�d}|jttj|�|jttj|�y#1swY��xYw#1swY��xYw)z=Ensure that short service names turn into long service names.Nzhttp://some-other-server.comz	not-a-url)
rEr1rrrNrGrSrI�assertRaises�
ValueError)r�alias�
other_root�	not_a_urls    r�test_lookupszTestNameLookups.test_lookups�s2��
�
(�
(�
*�	����
��� � ��,�,�U�3�T�5G�5G��5N��
�	��
(�
(�
*�	����
��� � ��(�(��/�����1F��
�	�4�
�����1�1�*�=�z�J�����-�-�j�9�:�F� �	����*�d�&>�&>�	�J����*�d�&:�&:�I�F�+	�	��	�	�s�AE�2AE)�E&�)E2N)r!r"r#r$r3rrErJrOrTrYr^r`rbrdrkr%r rr'r'IsM��:�
��
<��
<�F�
�������Gr r'c��eZdZdZd�Zy)�"TestServiceNameWithEmbeddedVersiona3Reject service roots that include the version at the end of the URL.

    If the service root is "http://api.launchpad.net/beta/" and the
    version is "beta", the launchpadlib constructor will raise an
    exception.

    This happens with scripts that were written against old versions
    of launchpadlib. The alternative is to try to silently fix it (the
    fix will eventually break as new versions of the web service are
    released) or to go ahead and make a request to
    http://api.launchpad.net/beta/beta/, and cause an unhelpful 404
    error.
    c	���d}tjd|z}	tddd||��td��#t$r3}|jt
|�jd��Yd}~nd}~wwxYw|dz
}|jttddd||��tj}tjd|zdz}|jttddd|��y)Nzversion-foor+)�service_root�versionz*Expected a ValueError that was not thrown!zoIt looks like you're using a service root that incorporates the name of the web service version ("version-foo")�/�ro)rrGr	�AssertionErrorrgr=rB�
startswithrfr�DEFAULT_VERSION)rrp�root�e�default_versions     r�'test_service_name_with_embedded_versionzJTestServiceNameWithEmbeddedVersion.test_service_name_with_embedded_version�s��� ���!�!�)�,�w�6��	O��d�D�$�T�7�K�!�!M�N�N���	��O�O��A��!�!�&��
�
��	��	
��������������	�	
�-�<�<���!�!�)�,��>��D������	�4��t�$�	�	
s�5�	A1�)A,�,A1N)r!r"r#r$ryr%r rrmrm�s���&
r rmc�(�eZdZdZd�Zd�Zd�Zd�Zy)�#TestRequestTokenAuthorizationEnginez4Tests for the RequestTokenAuthorizationEngine class.c�B�|jttt�yr�rfrgr�SERVICE_ROOTr2s r�test_app_must_be_identifiedz?TestRequestTokenAuthorizationEngine.test_app_must_be_identified�s������4�l�	
r c�&�ttd��y�Nr��application_name�rr~r2s r�$test_application_name_identifies_appzHTestRequestTokenAuthorizationEngine.test_application_name_identifies_app�s��$�\�F�Kr c�&�ttd��y�Nr��
consumer_namer�r2s r�!test_consumer_name_identifies_appzETestRequestTokenAuthorizationEngine.test_consumer_name_identifies_apps��$�\��Hr c��|jtttdd��|jtttdd��y)N�name1�name2)r�r�rr}r2s r�#test_conflicting_app_identificationzGTestRequestTokenAuthorizationEngine.test_conflicting_app_identificationsH������(��$�!�	�	
�	
����(��#� �	�	
r N)r!r"r#r$rr�r�r�r%r rr{r{�s��>�
�
L�I�
r r{c��eZdZdZd�Zd�Zy)�%TestLaunchpadLoginWithCredentialsFilez9Tests for Launchpad.login_with() with a credentials file.c�<�tj�\}}tjd|��}t	j
|�}|j
|jj|jjj�tj|�y)N�
not important)r��credentials_file)�tempfile�mkstempr�
login_withr�load_from_pathr�consumer�key�credentials�os�remove)r�ignore�filename�	launchpadr�s     r�
test_filenamez3TestLaunchpadLoginWithCredentialsFile.test_filenames{��#�+�+�-����&�1�1�,�x�
�	�"�0�0��:������ � �$�$�i�&;�&;�&D�&D�&H�&H�	
�	�	�	�(�r c��tj�\}}t�}|jtt
jd||��tj|�y)Nr�)r�r��credential_store)	r�r�rrfrgrr�r�r�)rr�r��stores    r�+test_cannot_specify_both_filename_and_storezQTestLaunchpadLoginWithCredentialsFile.test_cannot_specify_both_filename_and_store)sS��#�+�+�-����&�(�������)�)�,�%�"�	�	
�	�	�	�(�r N)r!r"r#r$r�r�r%r rr�r�s��C��
r r�c��eZdZd�Zy)�4TestLaunchpadLoginWithCredentialsFileFromEnvVariablec���tj�\}}|tjd<t	j
d��}|j
|jt�|j|jj|�tjd�tjd=|jtjjd��tj|�y)N�LP_CREDENTIALS_FILEr�r�)r�r�r��environrr��assertIsInstancer�r
rr��unsetenv�assertIsNone�getr�)rr�r�r�s    rr�zBTestLaunchpadLoginWithCredentialsFileFromEnvVariable.test_filename:s���#�+�+�-����,4��
�
�(�)�&�1�1�,�
�	�	
����&�&�(F�	
�	
����3�3�<�<�h�G�
���)�*��J�J�,�-����"�*�*�.�.�)>�?�@�
�	�	�(�r N)r!r"r#r�r%r rr�r�6s��r r�c��eZdZdZd�Zd�Zy)�KeyringTestz*Base class for tests that use the keyring.c�R�t�t�tj_yr)rr�launchpadlibr��keyringr2s rr3zKeyringTest.setUpRs��#�%�,;�+<�� � �(r c�$�tj`yr)r�r�r�r2s r�tearDownzKeyringTest.tearDownYs���$�$�,r N)r!r"r#r$r3r�r%r rr�r�Os��4�=�-r r�c���eZdZdZ�fd�Z�fd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z�xZS)�TestLaunchpadLoginWithz!Tests for Launchpad.login_with().c�\��tt|��tj�|_yr)�superr�r3r��mkdtemp�temp_dir�r�	__class__s �rr3zTestLaunchpadLoginWith.setUpas!���
�$�d�1�3� �(�(�*��
r c�h��tt|��tj|j
�yr)r�r�r��shutil�rmtreer�r�s �rr�zTestLaunchpadLoginWith.tearDownes!���
�$�d�4�6��
�
�d�m�m�$r c��tjj|jd�}t	j
dt|��|jtjj|��tjj|d�}|jtjj|��|jtjjtjj|d���tjj|d�}|jtjj|��y)Nr�r��ro�launchpadlib_dir�api.example.com�cacher�)
r��path�joinr�rr�r~r=�isdir�assertFalse)rr��service_path�credentials_paths    r�test_dirs_createdz(TestLaunchpadLoginWith.test_dirs_createdis����7�7�<�<��
�
�~�F���%�%��%�-�	
�	
������
�
�&6�7�8��w�w�|�|�$4�6G�H��������
�
�l�3�4�	
������
�
�b�g�g�l�l�<��&I�J�K��7�7�<�<��m�D����������'7�8�9r c��tjj|jd�}tj|�tj
|d�|j
tjj|��tj|�}tj|j�}|j|tjtjztjz�tj dt"|��tj|�}tj|j�}|j%|tjtjztjz�y)Nr�i�r�r�)r�r�r�r��mkdir�chmodr=r��stat�S_IMODE�st_mode�assertNotEqual�S_IWRITE�S_IREAD�S_IEXECrr�r~r�rr��statinfo�modes    r�'test_dirs_created_are_changed_to_securez>TestLaunchpadLoginWith.test_dirs_created_are_changed_to_secure�s����7�7�<�<��
�
�~�F��
���!�"�
���!�5�)�������
�
�&6�7�8��7�7�+�,���|�|�H�,�,�-�����D�$�-�-�$�,�,�">����"M�N��%�%��%�-�	
��7�7�+�,���|�|�H�,�,�-������t�}�}�t�|�|�;�d�l�l�J�Kr c���tjj|jd�}t	j
dt|��|jtjj|��tj|�}tj|j�}|j|tjtjztjz�y)Nr�r�r�)r�r�r�r�rr�r~r=r�r�r�r�rr�r�r�r�s    r�test_dirs_created_are_securez3TestLaunchpadLoginWith.test_dirs_created_are_secure�s����7�7�<�<��
�
�~�F���%�%��%�-�	
�
	
������
�
�&6�7�8��7�7�+�,���|�|�H�,�,�-������t�}�}�t�|�|�;�d�l�l�J�Kr c�H�tjj|jd�}t	j
dt|d��}|j|jdd�t	j
dt|d��}|j|jdd�y)Nr�r��foo)ror�rprp�bar)	r�r�r�r�rr�r~r�passed_in_args�rr�r�s   r�test_version_is_propagatedz1TestLaunchpadLoginWith.test_version_is_propagated�s����7�7�<�<��
�
�~�F��&�1�1��%�-��	
�	�	
����1�1�)�<�e�D�'�1�1��%�-��	
�	�	
����1�1�)�<�e�Dr c��tjj|jd�}t	j
dt|��}|j|jjjd�t	j
dt|��}|j|jjjd�y)Nr�zvery importantr�)r�r�r�r�rr�r~rr�r�r�r�s   r�#test_application_name_is_propagatedz:TestLaunchpadLoginWith.test_application_name_is_propagated�s���
�7�7�<�<��
�
�~�F��&�1�1��%�-�
�	�
	
����!�!�*�*�;�;�=M�	
�'�1�1��%�-�
�	�
	
����!�!�*�*�;�;�=M�	
r c��ttd�}tj|��|j	|j
d�|j	|jd�y)N�application name��authorization_enginer8)rr~rr�r�request_tokens_obtained�access_tokens_obtained�r�engines  r�'test_authorization_engine_is_propagatedz>TestLaunchpadLoginWith.test_authorization_engine_is_propagated�sK��.�l�<N�O���%�%�6�B�����7�7��;�����6�6��:r c�L�|jttj�yr)rfrgrr�r2s r�)test_login_with_must_identify_applicationz@TestLaunchpadLoginWith.test_login_with_must_identify_application�s��	
���*�&8�&C�&C�Dr c�0�tjd��yr��rr�r2s rr�z;TestLaunchpadLoginWith.test_application_name_identifies_app�s��	�%�%�v�>r c�0�tjd��yr�r�r2s rr�z8TestLaunchpadLoginWith.test_consumer_name_identifies_app�s��	�%�%�F�;r c�r�ttd�}|jttj
d|��y)�;Catch an attempt to specify inconsistent application_names.zapplication name1zapplication name2r�N�rr~rfrgrr�r�s  r�+test_inconsistent_application_name_rejectedzBTestLaunchpadLoginWith.test_inconsistent_application_name_rejected�s9��-��-�
��	
�����)�)��!'�		�	
r c�v�ttdd��}|jttj
d|��y)r�N�consumer_name1r��consumer_name2r�r�r�s  r�(test_inconsistent_consumer_name_rejectedz?TestLaunchpadLoginWith.test_inconsistent_consumer_name_rejected�s;��-��$�.>�
��	
�����)�)��!'�		�	
r c�~�ttddg��}|jttj
dddg|��y)z=Catch an attempt to specify inconsistent allow_access_levels.r��FOO�r��allow_access_levelsN�BAR)r�r�r�r�r�s  r�.test_inconsistent_allow_access_levels_rejectedzETestLaunchpadLoginWith.test_inconsistent_allow_access_levels_rejectedsD��-��
���
��	
�����)�)��$�!&��!'�
	�	
r c�x�d�}t|��}d�}|jttjd||��y)Nc��yrr%r%r r�	callback1zRTestLaunchpadLoginWith.test_inconsistent_credential_save_failed.<locals>.callback1���r )�credential_save_failedc��yrr%r%r r�	callback2zRTestLaunchpadLoginWith.test_inconsistent_credential_save_failed.<locals>.callback2rr �app name)r�r)rrfrgrr�)rrr�rs    r�(test_inconsistent_credential_save_failedz?TestLaunchpadLoginWith.test_inconsistent_credential_save_failedsB��	�'�i�H��	�	
�����)�)��"�#,�	�	
r c�B�tjddg��}|j|jjj
d�|j|jjjd�|j|jjdg�y)Nr�r�r�)	rr�rr�r�r�r�r�r��rr�s  r�test_non_desktop_integrationz3TestLaunchpadLoginWith.test_non_desktop_integration)s���'�1�1�$�5�'�
�	�	
����.�.�7�7�;�;�Z�H�����.�.�7�7�H�H�$�O�����*�*�>�>���	
r c��tjddg��}|j|jjdg�y)Nr�r�)r��DESKTOP_INTEGRATION)rr�rr�r�r
s  r�<test_desktop_integration_doesnt_happen_without_consumer_namezSTestLaunchpadLoginWith.test_desktop_integration_doesnt_happen_without_consumer_name6s@��
'�1�1��U�G�
�	�	
����*�*�>�>�
"�#�	
r c�t�t�}t�}tjd|jt||��}|j|jjjtj�|j|jjjd�|j|jjdg�ttt j"j%|jdd�||tj&��}|j|j(|�y)Nr)r�ro�timeout�
proxy_infor
r�r�)ror�rrrp)�objectrr�r�r~rr��access_tokenr�r�ACCESS_TOKEN_KEYr�r�r�r��dictr�r�r�rur�)rrrr��expected_argumentss     r�*test_no_credentials_creates_new_credentialzATestLaunchpadLoginWith.test_no_credentials_creates_new_credentialCs����(���X�
�&�1�1��!�]�]�%��!�
�	�	
����!�!�.�.�2�2�(�9�9�	
�	
����!�!�*�*�;�;�Z�	
�	
����*�*�>�>�
"�#�	
�"�%��'�'�,�,�t�}�}�.?��I��!�&�6�6�
��	
����1�1�3E�Fr c���tjd|jt��}|j	|j
jjd�|j	|j
jjd�tjj|jddd�}|jtjj|��y)z)Test the anonymous login helper function.zanonymous access)r�ro�r�r�N)r�login_anonymouslyr�r~rr�rr��secretr�r�r�r��exists)rr�r�s   r�test_anonymous_loginz+TestLaunchpadLoginWith.test_anonymous_logines���&�8�8��!�]�]�%�
�	�
	
����.�.�;�;�?�?��D�����.�.�;�;�B�B�B�G��7�7�<�<��M�M�,�m�=O�
��	
��������(8�9�:r c��tjtjj|jdd��tjj|jddd�}tddt
dd���}|j|�t�}t�}d}tjd|jt|||�	�}tt|||tjj|jdd
���}|j�D]&\}}	|j|}
|j|
|	��(y)Nr�r�rzconsumer_secret:42z
access_key:84zaccess_secret:168)�consumer_secretrr�)r�rorrrpr�)rorrrpr�)r��makedirsr�r�r�rr�save_to_pathrrr�r~rrr�r)r�credentials_file_pathr�rrrpr�rr��expected�actuals           r�-test_existing_credentials_arguments_passed_onzDTestLaunchpadLoginWith.test_existing_credentials_arguments_passed_onus#��	����G�G�L�L����(9�=�I�	
�!#������M�M�,�m�Z�!
��"��0�$�_�6I�J�
��
	� � �!6�7��(���X�
���&�1�1��!�]�]�%��!��

�	�"�%��!���'�'�,�,�t�}�}�.?��I�
��0�5�5�7�	/�M�C���-�-�c�2�F����V�X�.�	/r c	��tjjd�}|jtjd<t	j
dt��}|�|tjd<ntjd=|jd}tjjtjj|dd��}|j|tjj|jd��|jtjjtjj|dd���y)N�HOMErrrr�z..z
.launchpadlibr�)r�r�r�r�rr�r~r�r��abspathr�rr=r)r�old_homer��	cache_dirr�s     r�test_None_launchpadlib_dirz1TestLaunchpadLoginWith.test_None_launchpadlib_dir�s����:�:�>�>�&�)��!�]�]��
�
�6��&�1�1��\�
�	���!)�B�J�J�v���
�
�6�"��,�,�W�5�	��7�7�?�?�2�7�7�<�<�	�4��+N�O������b�g�g�l�l�4�=�=�/�J�	
�	
����G�G�N�N������-�/@�'�J�
�	
r c�l�tjdd�}|j|jdd�tjdtj
d�}|j|jdtj
d�d}|j
ttjdd�y)Nrr+roz"https://api.staging.launchpad.net/)rzhttps://r�)rr�rr�rrGrfrgr
s  r�test_short_service_namez.TestLaunchpadLoginWith.test_short_service_name�s���&�1�1�*�i�H�	�����$�$�^�4�0�	
�'�1�1���*�*�9�5�
�	�	
����$�$�^�4����y�)�	
�-�	�����*�5�5�z�5�	
r c�2�tjdd��y)Nr��)�max_failed_attemptsr�r2s r�!test_max_failed_attempts_acceptedz8TestLaunchpadLoginWith.test_max_failed_attempts_accepted�s��	�%�%�o�1�Mr )r!r"r#r$r3r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr%r+r-r1�
__classcell__)r�s@rr�r�^s����+�+�%�:�.L�&L�E�2
�:;�E�
?�
<�


�
�

�
�&
�
� G�D;� $/�L
�2
�2Nr r�c��eZdZdZd�Zd�Zy)�TestDeprecatedLoginMethodsz2Make sure the deprecated login methods still work.c�b�tjd��5}tjd�tjdt�t	j
ddd�|j
t|�d�|j
|d	jt�ddd�y#1swYyxYw)
NTr5r7r�r��tokenrr8r)
r9r:r;�PendingDeprecationWarningr�loginrr<r?r@�rrCs  r�test_login_is_deprecatedz3TestDeprecatedLoginMethods.test_login_is_deprecated�s���
�
$�
$�D�
1�	E�V��!�!�(�+��!�!�(�,E�F��$�$�Z��(�C����S��[�!�,����V�A�Y�/�/�1C�D�	E�	E�	E�s�BB%�%B.c��tjd��5}tjd�tjdt�tjdd�tjd�|jt|dj�d�|j|djt�ddd�y#1swYyxYw)	NTr5r7r�z.*next release of cryptographyr�rz�The Launchpad.get_token_and_login() method is deprecated. You should use Launchpad.login_anonymous() for anonymous access and Launchpad.login_with() for all other purposes.)r9r:r;r7�filterwarningsr�get_token_and_loginrrB�messager?r@r9s  r�&test_get_token_and_login_is_deprecatedzATestDeprecatedLoginMethods.test_get_token_and_login_is_deprecated�s���
�
$�
$�D�
1�
	E�V��!�!�(�+��!�!�(�,E�F��#�#��;�
�
�2�2�:�>�����F�1�I�%�%�&�L�
�
���V�A�Y�/�/�1C�D�
	E�
	E�
	E�s�B&C�CN)r!r"r#r$r:r?r%r rr4r4�s��<�E�Er r4c���eZdZd�Zd�Zejeded���d��Z	ejeded���d��Z
ejeded���d	��Zy
)�!TestCredenitialSaveFailedCallbackc�p�t�tj_t	j
�|_yr�rr�r��socketr�r�r�r2s rr3z'TestCredenitialSaveFailedCallback.setUp��%��)9�(:����%� �(�(�*��
r c�t�ttj_tj|j
�yr�rDr�r�r�r�r�r2s rr�z*TestCredenitialSaveFailedCallback.tearDown�� ��(.����%��
�
�d�m�m�$r �_is_sudoc��y�NFr%r%r r�<lambda>z*TestCredenitialSaveFailedCallback.<lambda>��r c�$��g��fd�}tjj|jd�}d}t	t��5t
jd|||��|jt��d�ddd�y#1swYyxYw)Nc�(���jd�yr)�append)�callback_calleds�r�callbackzPTestCredenitialSaveFailedCallback.test_credentials_save_failed.<locals>.callbacks���
�"�"�4�(r r�rr�)ror�rr8)
r�r�r�r�r
rrr�rr<)rrRr�rorQs    @r�test_credentials_save_failedz>TestCredenitialSaveFailedCallback.test_credentials_save_faileds����
��	)�
�7�7�<�<��
�
�~�F��0��
�.�*�
+�	6��)�)��)�!1�'/�	
�
���S��1�1�5�	6�	6�	6�s�5B�Bc��yrKr%r%r rrLz*TestCredenitialSaveFailedCallback.<lambda>rMr c��tjj|jd�}d}t	t��5|j
ttjd||��ddd�y#1swYyxYw�Nr�rr�r�)
r�r�r�r�r
rrf�RuntimeErrorrr��rr�ros   r�:test_default_credentials_save_failed_is_to_raise_exceptionz\TestCredenitialSaveFailedCallback.test_default_credentials_save_failed_is_to_raise_exceptionsj���7�7�<�<��
�
�~�F��0��
�.�*�
+�	�����"�-�-��)�!1�
�
�	�	�	�s�)A2�2A;c��y)NTr%r%r rrLz*TestCredenitialSaveFailedCallback.<lambda>&rMr c���tjj|jd�}d}t	t��5t
jd||��ddd�y#1swYyxYwrV)r�r�r�r�r
rrr�rXs   r�>test_credentials_save_fail_under_sudo_does_not_raise_exceptionz`TestCredenitialSaveFailedCallback.test_credentials_save_fail_under_sudo_does_not_raise_exception&sY���7�7�<�<��
�
�~�F��0��
�.�*�
+�	��)�)��)�!1�
�	�	�	�s�A"�"A+N)r!r"r#r3r�rrr�staticmethodrSrYr\r%r rrArA�s���+�%��U�\�\�$�j�,�}�2M�N�6�O�6�,�U�\�\�$�j�,�}�2M�N��O���U�\�\�$�j�,�|�2L�M�
�N�
r rAc��eZdZd�Zd�Zejeded���d��Z	ejeded���d��Z
y)	�TestMultipleSitesc�p�t�tj_t	j
�|_yrrCr2s rr3zTestMultipleSites.setUp9rEr c�t�ttj_tj|j
�yrrGr2s rr�zTestMultipleSites.tearDown@rHr rIc��yrKr%r%r rrLzTestMultipleSites.<lambda>DrMr c���tjj|jd�}t	�}d}d}t|�5t
j|||��}|jjj}ddd�t|jj��dd}|j||�|j|�|j||dz|z�y#1swY�oxYw)Nr�rzSuper App 3000r�rr8�@)r�r�r�r�rr
rr�r�r�r��list�datarHrAr)rr�r�ror�r�r��application_keys        r�"test_components_of_application_keyz4TestMultipleSites.test_components_of_application_keyDs����7�7�<�<��
�
�~�F��!�#��0��+��
�'�
"�	?�*�5�5� �)�!1��I�
&�1�1�:�:�>�>�M�
	?��w�|�|�0�0�2�3�A�6�q�9��
	
�
�
�l�O�4��
�
�m�_�5�
	
����-�#�*=��*L�M�'	?�	?�s�9C+�+C4c��yrKr%r%r rrLzTestMultipleSites.<lambda>_rMr c�J�tjj|jd�}t	�}|j
rJd��t
|�5tjdd|��tjdd|��ddd�t|j
j��dk(sJ�t|j
j��dd	}t|j
j��d	d	}|j||�y#1swY��xYw)
Nr�z$oops, a fresh keyring has data in itr�zhttp://alpha.example.com/r�zhttp://beta.example.com/�rr8)
r�r�r�r�rrfr
rr�r<rHrer�)rr�r��application_key_1�application_key_2s     r�test_same_app_different_serversz1TestMultipleSites.test_same_app_different_servers_s����7�7�<�<��
�
�~�F��!�#���<�<�G�!G�G��
�'�
"�	�
�)�)�"�8�!1�
�

�)�)�"�7�!1�
�	� �7�<�<�$�$�&�'�1�,�,�,� ����!2�!2�!4�5�a�8��;�� ����!2�!2�!4�5�a�8��;�����-�/@�A�)	�	�s�1D�D"N)r!r"r#r3r�rrrr]rhrnr%r rr_r_4sd��
+�%��U�\�\�$�j�,�}�2M�N�N�O�N�4�U�\�\�$�j�,�}�2M�N�B�O�Br r_)0r$�type�
__metaclass__�
contextlibrr�r�rDr�r��unittest�
unittest.mockr�ImportError�mockr9�lazr.restfulclient.resourcer�launchpadlib.credentialsrrr�r�launchpadlib.launchpadr	r
�launchpadlib.testing.helpersrrr
rrrrrr~�TestCaserr'rmr{r�r�r�r�r4rAr_r%r r�<module>r{sK��"%��
�%�	�
�
�����#��3��
��,�C�����
)��I�h�/�/�I�qG�h�'�'�qG�h5
��):�):�5
�p 
�(�*;�*;� 
�F�H�,=�,=��<�8�;L�;L��2-�(�#�#�-�rN�[�rN�jE��E�<@��(9�(9�@�FEB��)�)�EB��k�����s�E�E�E

Zerion Mini Shell 1.0