Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyc


Nc@sddlmZddlmZddlmZmZmZmZddlm	Z	m
Z
defdYZdefdYZd	efd
YZ
dS(i(tdatetime(tResourcedTestCase(t
FakeLaunchpadtFakeResourcetFakeRoottIntegrityError(tFakeLaunchpadResourcetget_applicationtFakeRootTestcBseZdZRS(cCs)tt}|jt|tdS(N(RRt
assertTruet
isinstanceR(tselft
root_resource((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_create_root_resource#s(t__name__t
__module__R
(((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR!stFakeResourceTestcBs5eZdefgZdZdZdZRS(t	launchpadcsrtddtdfd|j_|jjjgtt}|jd|tdS(s6A custom C{__repr__} is provided for L{FakeResource}s.t
total_sizestest-branchtgetBranchescsS(N((tstatuses(tbranches(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt<lambda>/ss0<FakeResource branch-page-resource object at %s>N(tdictRtmeRthextidtassertEqualtrepr(Rtobj_id((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt	test_repr,scCsKtdd|j_|jj}|jdtt|t|dS(s
        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.
        tnametfoos<FakeEntry person foo at %s>N(RRRRRRR(Rtperson((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_repr_with_name6scCsltdddd}td|g|j_t|jj\}|jdtt|t|dS(s
        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.
        Rt1ttitlesBug #1tentriess<FakeResource bug 1 at %s>N(RRtbugstlistRRRR(Rtbug((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_repr_with_id@s(RRRt	resourcesRR"R)(((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR(s	
	
tFakeLaunchpadTestcBs^eZdefgZdZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'RS(%RcCsBt}t|}|j||j|jt|jdS(sy
        The builtin WADL definition is used if the C{application} is not
        provided during instantiation.
        N(tobjectRRtcredentialsRt_application(RR-R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt'test_wb_instantiate_without_applicationOs	cCsMt}t|dddddddddt}|j||jdS(s
        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.
        tservice_roottcachettimeoutt
proxy_infotapplicationN(R,RtNoneRRR-(RR-R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt test_instantiate_with_everythingYs
	cCs5t}t|dt}|j||jdS(s8A L{FakeLaunchpad} can be instantiated with credentials.R4N(R,RRRR-(RR-R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt!test_instantiate_with_credentialses	cCs|jd|jjdS(s~
        A L{FakeLaunchpad} instantiated without credentials has its
        C{credentials} attribute set to C{None}.
        N(RR5RR-(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt$test_instantiate_without_credentialskscCs |jtt|jdddS(s
        An L{IntegrityError} is raised if an attribute is set on a
        L{FakeLaunchpad} instance that isn't present in the WADL definition.
        R tbarN(tassertRaisesRtsetattrR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_set_undefined_propertyrscCs5tdd|j_|jtt|jjddS(s
        An L{AttributeError} is raised if an attribute is accessed on a
        L{FakeLaunchpad} instance that doesn't exist.
        tdisplay_nametFooRN(RRRR:tAttributeErrortgetattr(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_get_undefined_resourceyscCs2tdd|j_|jd|jjjdS(s
        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.
        RR N(RRRRR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_string_propertyscCs2tdd|j_|jd|jjjdS(s
        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.
        RufooN(RRRRR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_unicode_propertyscCs>tj}td||j_|j||jjjdS(sU
        Attributes that represent dates are set with C{datetime} instances.
        tdate_createdN(RtutcnowRRRRRD(Rtnow((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_datetime_propertyscCs)|jtt|jdtdddS(s
        Only C{datetime} values can be set on L{FakeLaunchpad} instances for
        attributes that represent dates.
        RRDRFN(R:RR;RR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_invalid_datetime_propertyscCsQtdddd|j_|jd|jjj|jd|jjjdS(s~
        Sample data can be created by setting L{FakeLaunchpad} attributes with
        dicts that represent objects.
        RR R=R>N(RRRRRR=(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_multiple_string_propertiesscCs)|jtt|jdtdddS(s
        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.
        RR R9N(R:RR;RR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_invalid_property_namescCs)|jtt|jdtdddS(s
        The types of sample data values set on L{FakeLaunchpad} instances are
        validated against types defined in the WADL definition.
        RRifN(R:RR;RR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_invalid_property_valuescsPtddtdfd|j_|jd|jjjgdS(s
        A callable set on a L{FakeLaunchpad} instance is validated against the
        WADL definition, to make sure a matching method exists.
        Rstest-branchRcsS(N((R(R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsN(RRRtassertNotEqualR5R(R((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt
test_callablescCs,|jtt|jdtdddS(s
        An L{IntegrityError} is raised if a method is defined on a resource
        that doesn't match a method defined in the WADL definition.
        RR cSsdS(N(R5(((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsN(R:RR;RR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_invalid_callable_namescsotddtdfd|j_|jjjg|jtt|jdjdS(s
        The result of a fake method is a L{FakeResource}, automatically
        created from the object used to define the return object.
        Rt8RcsS(N((R(R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsN(	RRRRR	R
RRR(R((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt test_callable_object_return_types
csMtddtdfd|j_|jt|jjjgdS(sW
        An L{IntegrityError} is raised if a method returns an invalid result.
        RiRcsS(N((R(R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsN(RRRR:RR(R((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt(test_invalid_callable_object_return_typescsYtddtdfd|j_|jjjd|jdjdS(s
        Sample collections can be set on L{FakeLaunchpad} instances.  They are
        validated the same way other sample data is validated.
        RR tgetByUniqueNamecsS(N((R(tbranch(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsN(RRRRRRR(R((RSsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_collection_propertyscCstdddd}td|g|j_g|jjD]}|^q:}|jdt||d}|jd|j|jd|jdS(	s
        Data for a sample collection set on a L{FakeLaunchpad} instance can be
        iterated over if an C{entries} key is defined.
        RR#R$sBug #1R%iiN(RRR&RtlenRR$(RR(R&((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_iterate_collections
cCs;tdd}|jtt|jdtd|gdS(s
        Sample data for each entry in a collection is validated when it's set
        on a L{FakeLaunchpad} instance.
        R R9R&R%N(RR:RR;R(RR(((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt$test_collection_with_invalid_entriesscCstdddd}tdddd}tdddd}td	|||g|j_|jjd
d!}|jdt||jd|d
j|jd|d
jdS(s
        Data for a sample collection set on a L{FakeLaunchpad} instance can be
        sliced if an C{entries} key is defined.
        RR#R$sBug #1t2sBug #2t3sBug #3R%iiiiN(RRR&RRUR(Rtbug1tbug2tbug3R&((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_slice_collectionscs{tdddd}tdddd}td||gj_jtfdjtfd	d
S(s
        A C{ValueError} is raised if a negative start value is used when
        slicing a sample collection set on a L{FakeLaunchpad} instance.
        RR#R$sBug #1RXsBug #2R%csjjdS(Ni(RR&((R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRscsjjdd!S(Nii(RR&((R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsN(RRR&R:t
ValueError(RRZR[((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt)test_slice_collection_with_negative_starts
cs{tdddd}tdddd}td||gj_jtfdjtfd	d
S(s
        A C{ValueError} is raised if a negative stop value is used when
        slicing a sample collection set on a L{FakeLaunchpad} instance.
        RR#R$sBug #1RXsBug #2R%csjjd S(Ni(RR&((R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR"scsjjdd!S(Nii(RR&((R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR#sN(RRR&R:R^(RRZR[((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt(test_slice_collection_with_negative_stops
csJtdddd}td|gj_jtfddS(s
        An C{IndexError} is raised if an invalid index is used when retrieving
        data from a sample collection.
        RR#R$sBug #1R%csjjdS(Ni(RR&((R(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR,sN(RRR&R:t
IndexError(RRZ((RsM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt$test_subscript_operator_out_of_range%scCsmtdd|j_|jj}|jd|jd|_|jd|j|jd|jjjdS(s<Values already set on fake resource objects can be replaced.RR R9N(RRRRR(RR!((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_replace_property.s	cstddddtddddtdfd|j_fd|jj_|jjjd}|jd|jd	S(
s=Methods already set on fake resource objects can be replaced.RR tbzr_identityslp:~user/project/branch1slp:~user/project/branch2RRcsS(N((R(tbranch1(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR;scsS(N((R(tbranch2(sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR<sN(RRRRRRRd(RRS((RfResM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_replace_method7scCs>tdd|j_|jj}|jtt|dddS(s2Values set on fake resource objects are validated.RR iN(RRRR:RR;(RR!((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt(test_replace_property_with_invalid_value@scCs`tdd|j_|jd|jjjtdd|j_|jd|jjjdS(s:Resources already set on L{FakeLaunchpad} can be replaced.RR R9N(RRRRR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_replace_resourceFscCstdd|j_|jj}d|_|jd|j|jd|j|jd|jjj|jd|jjjdS(s?Sample data set on a L{FakeLaunchpad} instance can be added to.RR R>N(RRRR=RR(RR!((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_add_propertyMs	cCsWt|j_|jtt|jjdd|jj_|jd|jjjdS(s6An empty object can be used when creating sample data.RR N(RRRR:R?R@RR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt!test_add_property_to_empty_objectWscCs/tjddd}|jt|tdS(s
        L{FakeLaunchpad.login} ignores all parameters and returns a new
        instance using the builtin WADL definition.
        RttokentsecretN(RtloginR	R
(RR((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt
test_login^scCs)tjd}|jt|tdS(s
        L{FakeLaunchpad.get_token_and_login} ignores all parameters and
        returns a new instance using the builtin WADL definition.
        RN(Rtget_token_and_loginR	R
(RR((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_get_token_and_loginfscCs)tjd}|jt|tdS(s
        L{FakeLaunchpad.login_with} ignores all parameters and returns a new
        instance using the builtin WADL definition.
        RN(Rt
login_withR	R
(RR((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_login_withnscCs2tdd|j_|j|jjjdS(sU
        Sample object have an C{lp_save} method that is a no-op by default.
        RR N(RRRR	tlp_save(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_lp_savevscCs>tdddd|j_|jd|jjjdS(s;A custom C{lp_save} method can be set on a L{FakeResource}.RR RtcSsdS(Ntcustom((((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsRvN(RRRRRt(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_custom_lp_save}scCsGtdd|j_d|jj_|jd|jjjdS(sl
        A custom C{lp_save} method can be set on a L{FakeResource} after its
        been created.
        RR cSsdS(NRv((((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyRsRvN(RRRRtR(R((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyttest_set_custom_lp_saves((RRRR*R/R6R7R8R<RARBRCRGRHRIRJRKRMRNRPRQRTRVRWR]R_R`RbRcRgRhRiRjRkRoRqRsRuRwRx(((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyR+KsJ	
																						
	
														
						N(Rt
testresourcesRtlaunchpadlib.testing.launchpadRRRRtlaunchpadlib.testing.resourcesRRRRR+(((sM/usr/lib/python2.7/dist-packages/launchpadlib/testing/tests/test_launchpad.pyt<module>s"#