Your IP : 172.28.240.42


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

ó
µÌØNc
@sXdZeZddddddddd	d
g
ZddlmZdd
lZddlmZddl	m
Z
mZmZe
ƒZd„Zdefd„ƒYZdefd„ƒYZdefd„ƒYZed„ƒZdd d„ƒYZdd!d„ƒYZdd"d„ƒYZdd#d„ƒYZeddƒZeddƒZeddƒZd
S($slaunchpadlib testing helpers.tBadSaveKeyringtfake_keyringtFauxSocketModuletInMemoryKeyringtNoNetworkAuthorizationEnginetNoNetworkLaunchpadtTestableLaunchpadtnopriv_read_nonprivatetsalgado_read_nonprivatetsalgado_with_full_permissionsiÿÿÿÿ(tcontextmanagerN(t	Launchpad(tAccessTokentCredentialstRequestTokenAuthorizationEnginecCs+ttjdtƒtks'tdƒ‚dS(Ntkeyrings>During tests the real keyring module should never be imported.(tgetattrtlaunchpadlibtcredentialstmissingtAssertionError(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytassert_keyring_not_imported2scBs/eZdZdZd„Zd„Zd„ZRS(sAn authorization engine that doesn't open a web browser.

    You can use this to test the creation of Launchpad objects and the
    storing of credentials. You can't use it to interact with the web
    service, since it only pretends to authorize its OAuth request tokens.
    s
access_key:84cOs/tt|ƒj||Žd|_d|_dS(Ni(tsuperRt__init__trequest_tokens_obtainedtaccess_tokens_obtained(tselftargstkwargs((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR@s	cCs|jd7_dS(ssPretend to get a request token from the server.

        We do this by simply returning a static token ID.
        isrequest_token:42(R(RR((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytget_request_tokenFscCs(t|jdƒ|_|jd7_dS(s‚Pretend to exchange a request token for an access token.

        We do this by simply setting the access_token property.
        saccess_secret:168iN(RtACCESS_TOKEN_KEYtaccess_tokenR(RRt
request_token((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytmake_end_user_authorize_tokenNs(t__name__t
__module__t__doc__RRRR!(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR7s
		cBs&eZdZd„Zed„ƒZRS(s²A Launchpad instance for tests with no network access.

    It's only useful for making sure that certain methods were called.
    It can't be used to interact with the API.
    c		CsI||_||_||_td|d|d|d|d|ƒ|_dS(Ntservice_roottcachettimeoutt
proxy_infotversion(Rtauthorization_enginetcredential_storetdicttpassed_in_args(	RRR*R+R%R&R'R(R)((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR_s			cGs
t|ŒS(N(R(tclsR((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytauthorization_engine_factoryhs(R"R#R$RtclassmethodR/(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyRXs		cBs/eZdZddddddejd„ZRS(s5A base class for talking to the testing root service.ttest_devc		Cs>tt|ƒj|||d|d|d|d|d|ƒdS(s\Provide test-friendly defaults.

        :param authorization_engine: Defaults to None, since a test
            environment can't use an authorization engine.
        :param credential_store: Defaults to None, since tests
            generally pass in fully-formed Credentials objects.
        :param service_root: Defaults to 'test_dev'.
        R%R&R'R(R)N(RRR(	RRR*R+R%R&R'R(R)((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyRpsN(R"R#R$tNoneRtDEFAULT_VERSIONR(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyRms
	ccs-tƒ|tj_z	dVWdtj`XdS(sAA context manager which injects a testing keyring implementation.N(RRRR(tfake((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR‚s
	cBseZdZd„ZRS(s:A socket module replacement that provides a fake hostname.cCsdS(NtHOSTNAME((R((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytgethostname‘s(R"R#R$R6(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyRŽscBs eZdZd„Zd„ZRS(s6A keyring that generates errors when saving passwords.cCsdS(N(R2(Rtservicetusername((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytget_password˜scCs
t‚dS(N(tRuntimeError(RR7R8tpassword((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytset_password›s(R"R#R$R9R<(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR•s	cBs)eZdZd„Zd„Zd„ZRS(s.A keyring that saves passwords only in memory.cCs
i|_dS(N(tdata(R((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR¢scCs||j||f<dS(N(R=(RR7R8R;((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR<¥scCs|jj||fƒS(N(R=tget(RR7R8((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR9¨s(R"R#R$RR<R9(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyRŸs		tKnownTokenscBs/eZdZd„Zdddejd„ZRS(s'Known access token/secret combinations.cCsC||_||_t||ƒ|_tddd|jƒ|_dS(Nt
consumer_nameslaunchpad-libraryR(ttoken_stringt
access_secretRttokenR
R(RRARB((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR¯s
		c
Cs%t|jd|d|d|d|ƒS(s2Create a Launchpad object using these credentials.R&R'R(R)(RR(RR&R'R(R)((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pytlogin¶sN(R"R#R$RR2RR3RD(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyR?¬s		ssalgado-change-anythingttestssalgado-read-nonprivatetsecretsnopriv-read-nonprivatetmystery(((((R$ttypet
__metaclass__t__all__t
contextlibR
Rtlaunchpadlib.launchpadRtlaunchpadlib.credentialsRR
RtobjectRRRRRRRRRR?R	RR(((s@/usr/lib/python2.7/dist-packages/launchpadlib/testing/helpers.pyt<module>s8			!