%PDF- %PDF-
Mini Shell

Mini Shell

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

�

D�cTJ���ddlmZddlmZddlmZmZmZmZddlm	Z	m
Z
Gd�de�ZGd�de�ZGd	�d
e�Z
y)�)�datetime)�ResourcedTestCase)�
FakeLaunchpad�FakeResource�FakeRoot�IntegrityError)�FakeLaunchpadResource�get_applicationc��eZdZd�Zy)�FakeRootTestc�h�tt��}|jt|t��y�N)rr
�
assertTrue�
isinstancer)�self�
root_resources  �K/usr/lib/python3/dist-packages/launchpadlib/testing/tests/test_launchpad.py�test_create_root_resourcez&FakeRootTest.test_create_root_resource$s"�� ��!2�3�
����
�=�,�?�@�N)�__name__�
__module__�__qualname__r�rrrr#s��Arrc�8�eZdZde�fgZd�Zd�Zd�Zd�Zy)�FakeResourceTest�	launchpadc���t�}t|g��|j_t|jj�\}|j	dtt
|��zt|��y)z3A custom C{__repr__} is provided for L{FakeEntry}s.��entriesz<FakeEntry bug object at %s>N��dictr�bugs�list�assertEqual�hex�id�repr�r�bugs  r�test_repr_entryz FakeResourceTest.test_repr_entry-sV���f��"�C�5�1������T�^�^�(�(�)������*�S��C��\�9�4��9�	
rc���td���t�fd���|j_|jjjg��t	t���}|j
d|zt���y)z8A custom C{__repr__} is provided for L{FakeCollection}s.�test-branch��
total_sizec����Srr��statuses�branchess �r�<lambda>z7FakeResourceTest.test_repr_collection.<locals>.<lambda>9����h�r��getBranchesz2<FakeCollection branch-page-resource object at %s>N)r!r�mer6r%r&r$r')r�obj_idr2s  @r�test_repr_collectionz%FakeResourceTest.test_repr_collection6sd����=�1�� �-F�G������>�>�$�$�0�0��4���R��\�"�����@�6�I���N�	
rc���td��|j_|jj}|jdt	t|��zt
|��y)z�
        If the fake has a C{name} property it's included in the repr string to
        make it easier to figure out what it is.
        �foo��namez<FakeEntry person foo at %s>N)r!rr7r$r%r&r'�r�persons  r�test_repr_with_namez$FakeResourceTest.test_repr_with_nameAsH��
!�e�,��������"�"�����*�S��F��_�<�d�6�l�	
rc��tdd��}t|g��|j_t|jj�\}|j	dtt
|��zt|��y)z�
        If the fake has an C{id} property it's included in the repr string to
        make it easier to figure out what it is.
        �1�Bug #1�r&�titlerz<FakeEntry bug 1 at %s>Nr r(s  r�test_repr_with_idz"FakeResourceTest.test_repr_with_idLs[��
�c��*��"�C�5�1������T�^�^�(�(�)������2�S��C��\�A�4��9�MrN)	rrrr	�	resourcesr*r9r@rFrrrrr)s(���4�6�7�8�I�
�	
�	
�Nrrc��eZdZde�fgZd�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�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&d$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d)�Z,d*�Z-d+�Z.y,)-�FakeLaunchpadTestrc��t�}t|�}|j||j�|jt	�|j
�y)zy
        The builtin WADL definition is used if the C{application} is not
        provided during instantiation.
        N)�objectrr$�credentialsr
�_application�rrLrs   r�'test_wb_instantiate_without_applicationz9FakeLaunchpadTest.test_wb_instantiate_without_application[sD��
�h��!�+�.�	�����i�&;�&;�<�����*�I�,B�,B�Crc	��t�}t|ddddt���}|j||j�y)z�
        L{FakeLaunchpad} takes the same parameters as L{Launchpad} during
        instantiation, with the addition of an C{application} parameter.  The
        optional parameters are discarded when the object is instantiated.
        N)�service_root�cache�timeout�
proxy_info�application�rKrr
r$rLrNs   r� test_instantiate_with_everythingz2FakeLaunchpadTest.test_instantiate_with_everythingesB���h��!������'�)�

�	�	
����i�&;�&;�<rc�z�t�}t|t���}|j||j�y)z8A L{FakeLaunchpad} can be instantiated with credentials.)rUNrVrNs   r�!test_instantiate_with_credentialsz3FakeLaunchpadTest.test_instantiate_with_credentialsvs.���h��!�+�?�;L�M�	�����i�&;�&;�<rc�N�|j|jj�y)z~
        A L{FakeLaunchpad} instantiated without credentials has its
        C{credentials} attribute set to C{None}.
        N)�assertIsNonerrL�rs r�$test_instantiate_without_credentialsz6FakeLaunchpadTest.test_instantiate_without_credentials|s��
	
���$�.�.�4�4�5rc�R�|jtt|jdd�y)z�
        An L{IntegrityError} is raised if an attribute is set on a
        L{FakeLaunchpad} instance that isn't present in the WADL definition.
        r;�barN)�assertRaisesr�setattrrr\s r�test_set_undefined_propertyz-FakeLaunchpadTest.test_set_undefined_property�s!��
	
����G�T�^�^�U�E�	
rc��td��|j_|jtt
|jjd�y)z�
        An L{AttributeError} is raised if an attribute is accessed on a
        L{FakeLaunchpad} instance that doesn't exist.
        �Foo)�display_namer=N)r!rr7r`�AttributeError�getattrr\s r�test_get_undefined_resourcez-FakeLaunchpadTest.test_get_undefined_resource�s3��
!�e�4��������.�'�4�>�>�3D�3D�f�Mrc��td��|j_|jd|jjj�y)z�
        Sample data can be created by setting L{FakeLaunchpad} attributes with
        dicts that represent objects.  Plain string values can be represented
        as C{str} values.
        r;r<N�r!rr7r$r=r\s r�test_string_propertyz&FakeLaunchpadTest.test_string_property�s5��!�e�,������������ 1� 1� 6� 6�7rc��td��|j_|jd|jjj�y)z�
        Sample data can be created by setting L{FakeLaunchpad} attributes with
        dicts that represent objects.  Plain string values can be represented
        as C{unicode} strings.
        r;r<Nrjr\s r�test_unicode_propertyz'FakeLaunchpadTest.test_unicode_property�s5��!�f�-������������!2�!2�!7�!7�8rc���tj�}t|��|j_|j||jjj�y)zU
        Attributes that represent dates are set with C{datetime} instances.
        ��date_createdN)r�utcnowr!rr7r$rp)r�nows  r�test_datetime_propertyz(FakeLaunchpadTest.test_datetime_property�sA���o�o��� �c�2���������d�n�n�/�/�<�<�=rc	�f�|jtt|jdt	d���y)z
        Only C{datetime} values can be set on L{FakeLaunchpad} instances for
        attributes that represent dates.
        r7rrroN�r`rrarr!r\s r�test_invalid_datetime_propertyz0FakeLaunchpadTest.test_invalid_datetime_property�s*��
	
������N�N���e�$�	
rc��tdd��|j_|jd|jjj�|jd|jjj
�y)z~
        Sample data can be created by setting L{FakeLaunchpad} attributes with
        dicts that represent objects.
        r;rd)r=reN)r!rr7r$r=rer\s r�test_multiple_string_propertiesz1FakeLaunchpadTest.test_multiple_string_properties�sW��
!�e�%�@������������ 1� 1� 6� 6�7�������� 1� 1� >� >�?rc	�f�|jtt|jdt	d���y)z�
        Sample data set on a L{FakeLaunchpad} instance is validated against
        the WADL definition.  If a key is defined on a resource that doesn't
        match a related parameter, an L{IntegrityError} is raised.
        r7r_�r;Nrur\s r�test_invalid_property_namez,FakeLaunchpadTest.test_invalid_property_name�s%��	
����G�T�^�^�T�4�E�?�	
rc	�f�|jtt|jdt	d���y)z�
        The types of sample data values set on L{FakeLaunchpad} instances are
        validated against types defined in the WADL definition.
        r7�fr<Nrur\s r�test_invalid_property_valuez-FakeLaunchpadTest.test_invalid_property_value�s%��
	
����G�T�^�^�T�4�S�>�	
rc����td���t�fd���|j_|jd|jjj	g��y)z�
        A callable set on a L{FakeLaunchpad} instance is validated against the
        WADL definition, to make sure a matching method exists.
        r,r-c����Srrr0s �rr3z1FakeLaunchpadTest.test_callable.<locals>.<lambda>�r4rr5N)r!rr7�assertNotEqualr6�rr2s @r�
test_callablezFakeLaunchpadTest.test_callable�sF���
�=�1�� �-F�G��������D�$�.�.�"3�"3�"?�"?��"C�Drc	�h�|jtt|jdt	d����y)z�
        An L{IntegrityError} is raised if a method is defined on a resource
        that doesn't match a method defined in the WADL definition.
        r7c��yrrrrrr3z>FakeLaunchpadTest.test_invalid_callable_name.<locals>.<lambda>���rrzNrur\s r�test_invalid_callable_namez,FakeLaunchpadTest.test_invalid_callable_name�s*��
	
������N�N���\�"�	
rc���td���t�fd���|j_|jjjg��|j	t�t��|jd�j�y)z�
        The result of a fake method is a L{FakeResource}, automatically
        created from the object used to define the return object.
        �8r-c����Srrr0s �rr3zDFakeLaunchpadTest.test_callable_object_return_type.<locals>.<lambda>�r4rr5N)	r!rr7r6rrrr$r.r�s @r� test_callable_object_return_typez2FakeLaunchpadTest.test_callable_object_return_type�sd���
�3�'�� �-F�G������>�>�$�$�0�0��4�����
�8�\�:�;�����h�1�1�2rc����td���t�fd���|j_|jt|jjj
g�y)zW
        An L{IntegrityError} is raised if a method returns an invalid result.
        �r-c����Srrr0s �rr3zLFakeLaunchpadTest.test_invalid_callable_object_return_type.<locals>.<lambda>�r4rr5N)r!rr7r`rr6r�s @r�(test_invalid_callable_object_return_typez:FakeLaunchpadTest.test_invalid_callable_object_return_type�sC����1�%�� �-F�G��������.�$�.�.�*;�*;�*G�*G��Lrc��td���|j_|j|jjj	d��y)z}
        A fake method passes through a return value of None rather than
        trying to create a L{FakeResource}.
        c��yrrr<s rr3zDFakeLaunchpadTest.test_callable_object_return_None.<locals>.<lambda>r�r��getByUniqueNamer;N)r!rr2r[r�r\s r� test_callable_object_return_Nonez2FakeLaunchpadTest.test_callable_object_return_Nones9��
#'�7H�"I��������$�.�.�1�1�A�A�%�H�Irc����td����t�fd���|j_|jjjd��|j	�j��y)z�
        If the WADL definition of a method does not include a response
        representation, then fake versions of that method just pass through
        the return value.
        c��y)NTrrrrr3zSFakeLaunchpadTest.test_callable_object_no_response_representation.<locals>.<lambda>r�r)�canBeDeletedc����Srr�r=�branchs �rr3zSFakeLaunchpadTest.test_callable_object_no_response_representation.<locals>.<lambda>����F�rr�r;N)r!rr2r�rr��rr�s @r�/test_callable_object_no_response_representationzAFakeLaunchpadTest.test_callable_object_no_response_representationsP����<�0��"&�7J�"K��������(�(�8�8��?������+�+�-�.rc���ttd����}t|g��|j_|jjd}|jd|jj
�y)zx
        Attributes that represent links to other objects are set using a
        dict representing the object.
        ztest-personr<��ownerrrN)r!rr"r$r�r=r(s  r�test_entry_propertyz%FakeLaunchpadTest.test_entry_propertysR��
��=�1�2��"�C�5�1������n�n�!�!�!�$�������	�	���7rc	��ttd����}|jtt|jdt|g���y)z>
        Sample data for linked entries is validated.
        r_rzr�r"rN�r!r`rrarr(s  r�test_invalid_entry_propertyz-FakeLaunchpadTest.test_invalid_entry_propertys:����%��)��������N�N���#���	
rc����td���t�fd���|j_|jjjd��|j	d�j
�y)z�
        Sample top-level collections can be set on L{FakeLaunchpad}
        instances.  They are validated the same way other sample data is
        validated.
        r;r<c����Srrr�s �rr3zFFakeLaunchpadTest.test_top_level_collection_property.<locals>.<lambda>1r�rr�N)r!rr2r�r$r=r�s @r�"test_top_level_collection_propertyz4FakeLaunchpadTest.test_top_level_collection_property*sO����5�!��"&�7J�"K��������(�(�8�8��?���������,rc�8��td��}tt|g�����t�fd���|j_|jjjd��t	�j
�\}|j
d|j�y)	z�
        Attributes that represent links to collections of other objects are
        set using a dict representing the collection.
        rB)r&r��linked_bugsc����Srrr�s �rr3z<FakeLaunchpadTest.test_collection_property.<locals>.<lambda><r�rr�r;N)r!rr2r�r#r�r$r&�rr)r�s  @r�test_collection_propertyz*FakeLaunchpadTest.test_collection_property5sq���
�c�l���$��u�"5�6��"&�7J�"K��������(�(�8�8��?���V�'�'�(�������c�f�f�%rc�D�tdd��}t|g��|j_t|jj�}|j	dt|��|d}|j	d|j�|j	d|j�y)z�
        Data for a sample collection set on a L{FakeLaunchpad} instance can be
        iterated over if an C{entries} key is defined.
        rBrCrDr�rN)r!rr"r#r$�lenr&rE)rr)r"s   r�test_iterate_collectionz)FakeLaunchpadTest.test_iterate_collectionAs|��
�c��*��"�C�5�1������D�N�N�'�'�(������C��I�&��1�g������c�f�f�%�����3�9�9�-rc	��td��}|jtt|jdt|g���y)z
        Sample data for each entry in a collection is validated when it's set
        on a L{FakeLaunchpad} instance.
        r_rzr"rNr�r(s  r�.test_top_level_collection_with_invalid_entriesz@FakeLaunchpadTest.test_top_level_collection_with_invalid_entriesNs5��
�u�o��������N�N���#���	
rc����td��}tt|g�����t�fd���|j_|jt|jjj
d�y)	z�
        Sample data for each entry in a collection is validated when it's set
        on an attribute representing a link to a collection of objects.
        r_rzrr�c����Srrr�s �rr3zHFakeLaunchpadTest.test_collection_with_invalid_entries.<locals>.<lambda>cr�rr�r;N)r!rr2r`rr�r�s  @r�$test_collection_with_invalid_entriesz6FakeLaunchpadTest.test_collection_with_invalid_entries\sX���
�u�o���$��u�"5�6��"&�7J�"K����������N�N�#�#�3�3��	
rc�r�tdd��}tdd��}tdd��}t|||g��|j_|jjd	d
}|jdt	|��|jd|dj
�|jd|d	j
�y
)z�
        Data for a sample collection set on a L{FakeLaunchpad} instance can be
        sliced if an C{entries} key is defined.
        rBrCrD�2�Bug #2�3zBug #3rr���rN)r!rr"r$r�r&)r�bug1�bug2�bug3r"s     r�test_slice_collectionz'FakeLaunchpadTest.test_slice_collectionjs���
�s�(�+���s�(�+���s�(�+��"�D�$��+=�>������~�~�"�"�1�Q�'������C��I�&�����d�1�g�j�j�)�����d�1�g�j�j�)rc����tdd��}tdd��}t||g���j_�jt�fd���jt�fd��y	)
z�
        A C{ValueError} is raised if a negative start value is used when
        slicing a sample collection set on a L{FakeLaunchpad} instance.
        rBrCrDr�r�rc�6���jjddS�N����rr"r\s�rr3zMFakeLaunchpadTest.test_slice_collection_with_negative_start.<locals>.<lambda>�s���d�n�n�.A�.A�"�#�.F�rc�6���jjddS)Nr�r�r�r\s�rr3zMFakeLaunchpadTest.test_slice_collection_with_negative_start.<locals>.<lambda>�s���d�n�n�.A�.A�"�Q�.G�rN�r!rr"r`�
ValueError�rr�r�s`  r�)test_slice_collection_with_negative_startz;FakeLaunchpadTest.test_slice_collection_with_negative_startx�T���
�s�(�+���s�(�+��"�D�$�<�8��������*�&F�G����*�&G�Hrc����tdd��}tdd��}t||g���j_�jt�fd���jt�fd��y	)
z�
        A C{ValueError} is raised if a negative stop value is used when
        slicing a sample collection set on a L{FakeLaunchpad} instance.
        rBrCrDr�r�rc�6���jjddSr�r�r\s�rr3zLFakeLaunchpadTest.test_slice_collection_with_negative_stop.<locals>.<lambda>�s���d�n�n�.A�.A�#�2�.F�rc�6���jjddS)Nrr�r�r\s�rr3zLFakeLaunchpadTest.test_slice_collection_with_negative_stop.<locals>.<lambda>�s���d�n�n�.A�.A�!�B�.G�rNr�r�s`  r�(test_slice_collection_with_negative_stopz:FakeLaunchpadTest.test_slice_collection_with_negative_stop�r�rc���tdd��}t|g���j_�jt�fd��y)z
        An C{IndexError} is raised if an invalid index is used when retrieving
        data from a sample collection.
        rBrCrDrc�6���jjdS)Nr�r�r\s�rr3zHFakeLaunchpadTest.test_subscript_operator_out_of_range.<locals>.<lambda>�s���d�n�n�.A�.A�!�.D�rN)r!rr"r`�
IndexError)rr�s` r�$test_subscript_operator_out_of_rangez6FakeLaunchpadTest.test_subscript_operator_out_of_range�s5���
�s�(�+��"�D�6�2��������*�&D�Erc�D�td��|j_|jj}|jd|j�d|_|jd|j�|jd|jjj�y)z<Values already set on fake resource objects can be replaced.r;r<r_Nrjr>s  r�test_replace_propertyz'FakeLaunchpadTest.test_replace_property�sq�� �e�,��������"�"���������,�����������,�������� 1� 1� 6� 6�7rc�6���tdd���tdd���t�fd���|j_�fd�|jj_|jjjd�}|j	d|j
�y)	z=Methods already set on fake resource objects can be replaced.r;zlp:~user/project/branch1)r=�bzr_identityzlp:~user/project/branch2c����Srr)r=�branch1s �rr3z7FakeLaunchpadTest.test_replace_method.<locals>.<lambda>�s���G�rr�c����Srr)r=�branch2s �rr3z7FakeLaunchpadTest.test_replace_method.<locals>.<lambda>�s���w�rN)r!rr2r�r$r�)rr�r�r�s  @@r�test_replace_methodz%FakeLaunchpadTest.test_replace_method�sr����E�0J�K���E�0J�K��"&�7K�"L�����2F������/����(�(�8�8��?�����3�V�5H�5H�Irc��td��|j_|jj}|jtt
|dd�y)z2Values set on fake resource objects are validated.r;r<r=r�N)r!rr7r`rrar>s  r�(test_replace_property_with_invalid_valuez:FakeLaunchpadTest.test_replace_property_with_invalid_value�s8�� �e�,��������"�"�����.�'�6�6�1�Erc�0�td��|j_|jd|jjj�td��|j_|jd|jjj�y)z:Resources already set on L{FakeLaunchpad} can be replaced.r;r<r_Nrjr\s r�test_replace_resourcez'FakeLaunchpadTest.test_replace_resource�sd�� �e�,������������ 1� 1� 6� 6�7� �e�,������������ 1� 1� 6� 6�7rc��td��|j_|jj}d|_|j	d|j
�|j	d|j�|j	d|jjj
�|j	d|jjj�y)z?Sample data set on a L{FakeLaunchpad} instance can be added to.r;r<rdN)r!rr7rer$r=r>s  r�test_add_propertyz#FakeLaunchpadTest.test_add_property�s��� �e�,��������"�"��#����������,������ 3� 3�4�������� 1� 1� 6� 6�7�������� 1� 1� >� >�?rc�,�t�|j_|jtt
|jjd�d|jj_|jd|jjj�y)z6An empty object can be used when creating sample data.r=r;N)r!rr7r`rfrgr=r$r\s r�!test_add_property_to_empty_objectz3FakeLaunchpadTest.test_add_property_to_empty_object�s`�� �F��������.�'�4�>�>�3D�3D�f�M�!&�������������� 1� 1� 6� 6�7rc�p�tjddd�}|jt|t��y)z�
        L{FakeLaunchpad.login} ignores all parameters and returns a new
        instance using the builtin WADL definition.
        r=�token�secretN)r�loginrr�rrs  r�
test_loginzFakeLaunchpadTest.test_login�s+��
"�'�'����B�	����
�9�m�<�=rc�l�tjd�}|jt|t��y)z�
        L{FakeLaunchpad.get_token_and_login} ignores all parameters and
        returns a new instance using the builtin WADL definition.
        r=N)r�get_token_and_loginrrr�s  r�test_get_token_and_loginz*FakeLaunchpadTest.test_get_token_and_login�s'��
"�5�5�f�=�	����
�9�m�<�=rc�l�tjd�}|jt|t��y)z�
        L{FakeLaunchpad.login_with} ignores all parameters and returns a new
        instance using the builtin WADL definition.
        r=N)r�
login_withrrr�s  r�test_login_withz!FakeLaunchpadTest.test_login_with�s'��
"�,�,�V�4�	����
�9�m�<�=rc��td��|j_|j|jjj	��y)zU
        Sample object have an C{lp_save} method that is a no-op by default.
        r;r<N)r!rr7r�lp_saver\s r�test_lp_savezFakeLaunchpadTest.test_lp_save�s4��!�e�,�����������)�)�1�1�3�4rc��tdd���|j_|jd|jjj	��y)z;A custom C{lp_save} method can be set on a L{FakeResource}.r;c��y�N�customrrrrr3z7FakeLaunchpadTest.test_custom_lp_save.<locals>.<lambda>�r�r)r=r�r�N)r!rr7r$r�r\s r�test_custom_lp_savez%FakeLaunchpadTest.test_custom_lp_save�s9�� �e�5E�F���������4�>�>�#4�#4�#<�#<�#>�?rc���td��|j_d�|jj_|j	d|jjj��y)zl
        A custom C{lp_save} method can be set on a L{FakeResource} after its
        been created.
        r;r<c��yr�rrrrr3z;FakeLaunchpadTest.test_set_custom_lp_save.<locals>.<lambda>�r�rr�N)r!rr7r�r$r\s r�test_set_custom_lp_savez)FakeLaunchpadTest.test_set_custom_lp_save�sJ��
!�e�,�����$4������!�����4�>�>�#4�#4�#<�#<�#>�?rN)/rrrr	rGrOrWrYr]rbrhrkrmrsrvrxr{r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrIrIWs����4�6�7�8�I�D�=�"=�6�
�N�8�9�>�
�@�
�
�E�
�	3�M�J�	/�8�
�	-�
&�.�
�
�*�	I�	I�F�8�J�F�8�@�8�>�>�>�5�@�
@rrIN)r�
testresourcesr�launchpadlib.testing.launchpadrrrr�launchpadlib.testing.resourcesr	r
rrrIrrr�<module>r�sL��&�+����A�$�A�+N�(�+N�\[@�)�[@r

Zerion Mini Shell 1.0