HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/launchpadlib/testing/tests/__pycache__/test_launchpad.cpython-38.pyc
U

,ݛUD>�@stddlmZddlmZddlmZmZmZmZddlm	Z	m
Z
Gdd�de�ZGdd�de�ZGd	d
�d
e�Z
dS)�)�datetime)�ResourcedTestCase)�
FakeLaunchpad�FakeResource�FakeRoot�IntegrityError)�FakeLaunchpadResource�get_applicationc@seZdZdd�ZdS)�FakeRootTestcCstt��}|�t|t��dS�N)rr	�
assertTrue�
isinstancer)�selfZ
root_resource�r�K/usr/lib/python3/dist-packages/launchpadlib/testing/tests/test_launchpad.py�test_create_root_resource#s
z&FakeRootTest.test_create_root_resourceN)�__name__�
__module__�__qualname__rrrrrr
!sr
c@s0eZdZde�fgZdd�Zdd�Zdd�ZdS)	�FakeResourceTest�	launchpadcsRtdd��t�fdd�d�|j_|jj�g��tt���}|�d|t���dS)z6A custom C{__repr__} is provided for L{FakeResource}s.�test-branch��
total_sizecs�Srr�Zstatuses��branchesrr�<lambda>/�z,FakeResourceTest.test_repr.<locals>.<lambda>��getBranchesz0<FakeResource branch-page-resource object at %s>N)�dictr�mer �hex�id�assertEqual�repr)rZobj_idrrr�	test_repr,s
�zFakeResourceTest.test_reprcCs6tdd�|j_|jj}|�dtt|��t|��dS)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!rr"r%r#r$r&�rZpersonrrr�test_repr_with_name6s
�z$FakeResourceTest.test_repr_with_namecCsJtddd�}t|gd�|j_t|jj�\}|�dtt|��t|��dS)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$�title��entriesz<FakeResource bug 1 at %s>N)r!r�bugs�listr%r#r$r&�r�bugrrr�test_repr_with_id@sz"FakeResourceTest.test_repr_with_idN)rrrr�	resourcesr'r,r7rrrrr(s

rc@s8eZdZde�fgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dBdC�Z%dDdE�Z&dFdG�Z'dHdI�Z(dJS)K�FakeLaunchpadTestrcCs0t�}t|�}|�||j�|�t�|j�dS)zy
        The builtin WADL definition is used if the C{application} is not
        provided during instantiation.
        N)�objectrr%�credentialsr	Z_application�rr;rrrr�'test_wb_instantiate_without_applicationOsz9FakeLaunchpadTest.test_wb_instantiate_without_applicationcCs.t�}t|ddddt�d�}|�||j�dS)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)Zservice_root�cacheZtimeoutZ
proxy_info�application�r:rr	r%r;r<rrr� test_instantiate_with_everythingYs�z2FakeLaunchpadTest.test_instantiate_with_everythingcCs&t�}t|t�d�}|�||j�dS)z8A L{FakeLaunchpad} can be instantiated with credentials.)r?Nr@r<rrr�!test_instantiate_with_credentialsesz3FakeLaunchpadTest.test_instantiate_with_credentialscCs|�|jj�dS)z~
        A L{FakeLaunchpad} instantiated without credentials has its
        C{credentials} attribute set to C{None}.
        N)ZassertIsNonerr;�rrrr�$test_instantiate_without_credentialsksz6FakeLaunchpadTest.test_instantiate_without_credentialscCs|�tt|jdd�dS)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�setattrrrCrrr�test_set_undefined_propertyrsz-FakeLaunchpadTest.test_set_undefined_propertycCs&tdd�|j_|�tt|jjd�dS)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!rr"rF�AttributeError�getattrrCrrr�test_get_undefined_resourceysz-FakeLaunchpadTest.test_get_undefined_resourcecCs$tdd�|j_|�d|jjj�dS)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!rr"r%r*rCrrr�test_string_property�sz&FakeLaunchpadTest.test_string_propertycCs$tdd�|j_|�d|jjj�dS)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)NrNrCrrr�test_unicode_property�sz'FakeLaunchpadTest.test_unicode_propertycCs,t��}t|d�|j_|�||jjj�dS)zU
        Attributes that represent dates are set with C{datetime} instances.
        ��date_createdN)rZutcnowr!rr"r%rR)r�nowrrr�test_datetime_property�sz(FakeLaunchpadTest.test_datetime_propertyc	Cs|�tt|jdtdd��dS)z
        Only C{datetime} values can be set on L{FakeLaunchpad} instances for
        attributes that represent dates.
        r"rSrQN�rFrrGrr!rCrrr�test_invalid_datetime_property�s�z0FakeLaunchpadTest.test_invalid_datetime_propertycCs8tddd�|j_|�d|jjj�|�d|jjj�dS)z~
        Sample data can be created by setting L{FakeLaunchpad} attributes with
        dicts that represent objects.
        r(rI)r*rJN)r!rr"r%r*rJrCrrr�test_multiple_string_properties�sz1FakeLaunchpadTest.test_multiple_string_propertiesc	Cs|�tt|jdtdd��dS)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.
        r"rE�r(NrUrCrrr�test_invalid_property_name�s�z,FakeLaunchpadTest.test_invalid_property_namec	Cs|�tt|jdtdd��dS)z�
        The types of sample data values set on L{FakeLaunchpad} instances are
        validated against types defined in the WADL definition.
        r"�fr)NrUrCrrr�test_invalid_property_value�s�z-FakeLaunchpadTest.test_invalid_property_valuecs:tdd��t�fdd�d�|j_|�d|jj�g��dS)z�
        A callable set on a L{FakeLaunchpad} instance is validated against the
        WADL definition, to make sure a matching method exists.
        rrcs�Srrrrrrr�rz1FakeLaunchpadTest.test_callable.<locals>.<lambda>rN)r!rr"ZassertNotEqualr rCrrr�
test_callable�s
zFakeLaunchpadTest.test_callablec	Cs"|�tt|jdtdd�d��dS)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.
        r"cSsdSrrrrrrr�rz>FakeLaunchpadTest.test_invalid_callable_name.<locals>.<lambda>rXNrUrCrrr�test_invalid_callable_name�s�z,FakeLaunchpadTest.test_invalid_callable_namecsPtdd��t�fdd�d�|j_|jj�g��|�t�t��|�d�j�dS)z�
        The result of a fake method is a L{FakeResource}, automatically
        created from the object used to define the return object.
        �8rcs�Srrrrrrr�rzDFakeLaunchpadTest.test_callable_object_return_type.<locals>.<lambda>rN)	r!rr"r rr
rr%rrCrrr� test_callable_object_return_type�s

z2FakeLaunchpadTest.test_callable_object_return_typecs8tdd��t�fdd�d�|j_|�t|jjjg�dS)zW
        An L{IntegrityError} is raised if a method returns an invalid result.
        �rcs�Srrrrrrr�rzLFakeLaunchpadTest.test_invalid_callable_object_return_type.<locals>.<lambda>rN)r!rr"rFrr rCrrr�(test_invalid_callable_object_return_type�s
z:FakeLaunchpadTest.test_invalid_callable_object_return_typecs@tdd��t�fdd�d�|j_|jj�d��|�d�j�dS)z�
        Sample collections can be set on L{FakeLaunchpad} instances.  They are
        validated the same way other sample data is validated.
        r(r)cs�Srrr)��branchrrr�rz<FakeLaunchpadTest.test_collection_property.<locals>.<lambda>��getByUniqueNameN)r!rrrer%r*rCrrbr�test_collection_property�s
z*FakeLaunchpadTest.test_collection_propertycCs`tddd�}t|gd�|j_t|jj�}|�dt|��|d}|�d|j�|�d|j�dS)z�
        Data for a sample collection set on a L{FakeLaunchpad} instance can be
        iterated over if an C{entries} key is defined.
        r-r.r/r1�rN)r!rr3r4r%�lenr$r0)rr6r3rrr�test_iterate_collection�sz)FakeLaunchpadTest.test_iterate_collectionc	Cs*tdd�}|�tt|jdt|gd��dS)z
        Sample data for each entry in a collection is validated when it's set
        on a L{FakeLaunchpad} instance.
        rErXr3r1N)r!rFrrGrr5rrr�$test_collection_with_invalid_entries�s

�z6FakeLaunchpadTest.test_collection_with_invalid_entriescCs�tddd�}tddd�}tddd�}t|||gd�|j_|jjd	d
�}|�dt|��|�d|dj�|�d|d	j�d
S)z�
        Data for a sample collection set on a L{FakeLaunchpad} instance can be
        sliced if an C{entries} key is defined.
        r-r.r/�2�Bug #2�3zBug #3r1rg��rN)r!rr3r%rhr$)r�bug1�bug2Zbug3r3rrr�test_slice_collectionsz'FakeLaunchpadTest.test_slice_collectioncsVtddd�}tddd�}t||gd��j_��t�fdd����t�fd	d��d
S)z�
        A C{ValueError} is raised if a negative start value is used when
        slicing a sample collection set on a L{FakeLaunchpad} instance.
        r-r.r/rkrlr1cs�jjdd�S�N����rr3rrCrrrrzMFakeLaunchpadTest.test_slice_collection_with_negative_start.<locals>.<lambda>cs�jjdd�S)NrtrorurrCrrrrN�r!rr3rF�
ValueError�rrprqrrCr�)test_slice_collection_with_negative_starts
z;FakeLaunchpadTest.test_slice_collection_with_negative_startcsVtddd�}tddd�}t||gd��j_��t�fdd����t�fd	d��d
S)z�
        A C{ValueError} is raised if a negative stop value is used when
        slicing a sample collection set on a L{FakeLaunchpad} instance.
        r-r.r/rkrlr1cs�jjdd�SrsrurrCrrr"rzLFakeLaunchpadTest.test_slice_collection_with_negative_stop.<locals>.<lambda>cs�jjdd�S)NrrtrurrCrrr#rNrvrxrrCr�(test_slice_collection_with_negative_stops
z:FakeLaunchpadTest.test_slice_collection_with_negative_stopcs4tddd�}t|gd��j_��t�fdd��dS)z
        An C{IndexError} is raised if an invalid index is used when retrieving
        data from a sample collection.
        r-r.r/r1cs�jjdS)NrorurrCrrr,rzHFakeLaunchpadTest.test_subscript_operator_out_of_range.<locals>.<lambda>N)r!rr3rF�
IndexError)rrprrCr�$test_subscript_operator_out_of_range%sz6FakeLaunchpadTest.test_subscript_operator_out_of_rangecCsNtdd�|j_|jj}|�d|j�d|_|�d|j�|�d|jjj�dS)z<Values already set on fake resource objects can be replaced.r(r)rENrNr+rrr�test_replace_property.sz'FakeLaunchpadTest.test_replace_propertycs`tddd��tddd��t�fdd�d�|j_�fdd�|jj_|jj�d�}|�d|j�d	S)
z=Methods already set on fake resource objects can be replaced.r(zlp:~user/project/branch1)r*�bzr_identityzlp:~user/project/branch2cs�Srrr))�branch1rrr;rz7FakeLaunchpadTest.test_replace_method.<locals>.<lambda>rdcs�Srrr))�branch2rrr<rN)r!rrrer%r~)rrcr)rr�r�test_replace_method7sz%FakeLaunchpadTest.test_replace_methodcCs,tdd�|j_|jj}|�tt|dd�dS)z2Values set on fake resource objects are validated.r(r)r*rgN)r!rr"rFrrGr+rrr�(test_replace_property_with_invalid_value@sz:FakeLaunchpadTest.test_replace_property_with_invalid_valuecCsDtdd�|j_|�d|jjj�tdd�|j_|�d|jjj�dS)z:Resources already set on L{FakeLaunchpad} can be replaced.r(r)rENrNrCrrr�test_replace_resourceFsz'FakeLaunchpadTest.test_replace_resourcecCs`tdd�|j_|jj}d|_|�d|j�|�d|j�|�d|jjj�|�d|jjj�dS)z?Sample data set on a L{FakeLaunchpad} instance can be added to.r(r)rIN)r!rr"rJr%r*r+rrr�test_add_propertyMsz#FakeLaunchpadTest.test_add_propertycCs>t�|j_|�tt|jjd�d|jj_|�d|jjj�dS)z6An empty object can be used when creating sample data.r*r(N)r!rr"rFrKrLr*r%rCrrr�!test_add_property_to_empty_objectWs

z3FakeLaunchpadTest.test_add_property_to_empty_objectcCs"t�ddd�}|�t|t��dS)z�
        L{FakeLaunchpad.login} ignores all parameters and returns a new
        instance using the builtin WADL definition.
        r*�tokenZsecretN)rZloginrr
�rrrrr�
test_login^szFakeLaunchpadTest.test_logincCst�d�}|�t|t��dS)z�
        L{FakeLaunchpad.get_token_and_login} ignores all parameters and
        returns a new instance using the builtin WADL definition.
        r*N)rZget_token_and_loginrr
r�rrr�test_get_token_and_loginfs
z*FakeLaunchpadTest.test_get_token_and_logincCst�d�}|�t|t��dS)z�
        L{FakeLaunchpad.login_with} ignores all parameters and returns a new
        instance using the builtin WADL definition.
        r*N)rZ
login_withrr
r�rrr�test_login_withns
z!FakeLaunchpadTest.test_login_withcCs$tdd�|j_|�|jj���dS)zU
        Sample object have an C{lp_save} method that is a no-op by default.
        r(r)N)r!rr"r�lp_saverCrrr�test_lp_savevszFakeLaunchpadTest.test_lp_savecCs,tddd�d�|j_|�d|jj���dS)z;A custom C{lp_save} method can be set on a L{FakeResource}.r(cSsdS�N�customrrrrrrrz7FakeLaunchpadTest.test_custom_lp_save.<locals>.<lambda>)r*r�r�N)r!rr"r%r�rCrrr�test_custom_lp_save}sz%FakeLaunchpadTest.test_custom_lp_savecCs4tdd�|j_dd�|jj_|�d|jj���dS)zl
        A custom C{lp_save} method can be set on a L{FakeResource} after its
        been created.
        r(r)cSsdSr�rrrrrr�rz;FakeLaunchpadTest.test_set_custom_lp_save.<locals>.<lambda>r�N)r!rr"r�r%rCrrr�test_set_custom_lp_save�sz)FakeLaunchpadTest.test_set_custom_lp_saveN))rrrrr8r=rArBrDrHrMrOrPrTrVrWrYr[r\r]r_rarfrirjrrryrzr|r}r�r�r�r�r�r�r�r�r�r�r�rrrrr9KsJ
					

				
r9N)rZ
testresourcesrZlaunchpadlib.testing.launchpadrrrrZlaunchpadlib.testing.resourcesrr	r
rr9rrrr�<module>s#