+
    Z4i                     2   R t . ROt^ RIHt ^ RIt^ R	IHt ^ R
IHtH	t	H
t
 ]! 4       tR t ! R R]
4      t ! R R]4      t ! R R]4      t]R 4       t ! R R4      t ! R R4      t ! R R4      t ! R R4      t]! RR4      t]! RR4      t]! RR4      tR# )zlaunchpadlib testing helpers.BadSaveKeyringFauxSocketModuleInMemoryKeyringNoNetworkAuthorizationEngineNoNetworkLaunchpadTestableLaunchpad)contextmanagerN)	Launchpad)AccessTokenCredentialsRequestTokenAuthorizationEnginec                  b    \        \        P                  R \        4      \        J g   Q R4       hR# )keyringz>During tests the real keyring module should never be imported.N)getattrlaunchpadlibcredentialsmissing     >/usr/lib/python3/dist-packages/launchpadlib/testing/helpers.pyassert_keyring_not_importedr   0   s+    (()W=HHGHHr   c                   F   a a ] tR t^6t oRtRtV 3R ltR tR tRt	Vt
V ;t# )r   a  An 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.
zaccess_key:84c                D   < \         SV `  ! V/ VB  ^ V n        ^ V n        R# )    N)super__init__request_tokens_obtainedaccess_tokens_obtained)selfargskwargs	__class__s   &*,r   r   %NoNetworkAuthorizationEngine.__init__@   s%    $)&)'($&'#r   c                8    V ;P                   ^,          un         R# )zcPretend to get a request token from the server.

We do this by simply returning a static token ID.
zrequest_token:42)r   )r   r   s   &&r   get_request_token.NoNetworkAuthorizationEngine.get_request_tokenF   s    
 	$$)$!r   c                n    \        V P                  R4      Vn        V ;P                  ^,          un        R# )zrPretend to exchange a request token for an access token.

We do this by simply setting the access_token property.
zaccess_secret:168N)r
   ACCESS_TOKEN_KEYaccess_tokenr   )r   r   request_tokens   &&&r   make_end_user_authorize_token:NoNetworkAuthorizationEngine.make_end_user_authorize_tokenN   s0    
 $/!!#6$
  	##q(#r   )r   r   )__name__
__module____qualname____firstlineno____doc__r'   r   r$   r*   __static_attributes____classdictcell____classcell__r!   __classdict__s   @@r   r   r   6   s&      '(") )r   c                   :   a  ] tR t^Yt o RtR t]R 4       tRtV t	R# )r   zA 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	                T    Wn         W n        W0n        \        VVVVVR 7      V n        R# )service_rootcachetimeout
proxy_infoversionN)r   authorization_enginecredential_storedictpassed_in_args)	r   r   r>   r?   r9   r:   r;   r<   r=   s	   &&&&&&&&&r   r   NoNetworkLaunchpad.__init__`   s2     '$8! 0"%!
r   c                    \        V!  # N)r   )clsr   s   &*r   authorization_engine_factory/NoNetworkLaunchpad.authorization_engine_factoryv   s    +T22r   )r>   r?   r   rA   N)
r,   r-   r.   r/   r0   r   classmethodrF   r1   r2   r5   s   @r   r   r   Y   s#     
, 3 3r   c                   \   a a ] tR t^{t oRtRRRRRR]P                  3V 3R lltRtVt	V ;t
# )r   z5A base class for talking to the testing root service.Ntest_devc	                6   < \         S	V `  VVVVVVVVR7       R# )a,  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'.
r8   N)r   r   )
r   r   r>   r?   r9   r:   r;   r<   r=   r!   s
   &&&&&&&&&r   r   TestableLaunchpad.__init__~   s/    & 	 %! 	 		
r   r   )r,   r-   r.   r/   r0   r	   DEFAULT_VERSIONr   r1   r2   r3   r4   s   @@r   r   r   {   s/     ?
 "))
 
r   c              #    "   \        4        V \        P                  n        \        \        P                  n         Rx  \        P                  =\        P                  =R#   \        P                  =\        P                  =i ; i5i)zAA context manager which injects a testing keyring implementation.N)r   r   r   r   RuntimeErrorNoKeyringError)fakes   &r   fake_keyringrS      sd       !'+L$.:L+4$$,$$3 $$,$$3s   9BA"  "B""BBc                   *   a  ] tR t^t o RtR tRtV tR# )r   z:A socket module replacement that provides a fake hostname.c                    R # )HOSTNAMEr   r   s   &r   gethostnameFauxSocketModule.gethostname   s    r   r   N)r,   r-   r.   r/   r0   rX   r1   r2   rI   s   @r   r   r      s     D r   c                   0   a  ] tR t^t o RtR tR tRtV tR# )r   z6A keyring that generates errors when saving passwords.c                    R # rD   r   r   serviceusernames   &&&r   get_passwordBadSaveKeyring.get_password   s    r   c                    \         hrD   )rP   r   r]   r^   passwords   &&&&r   set_passwordBadSaveKeyring.set_password   s    r   r   N)	r,   r-   r.   r/   r0   r_   rd   r1   r2   rI   s   @r   r   r      s     @ r   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )r   z.A keyring that saves passwords only in memory.c                    / V n         R # rD   datarW   s   &r   r   InMemoryKeyring.__init__   s	    	r   c                $    W0P                   W3&   R # rD   rh   rb   s   &&&&r   rd   InMemoryKeyring.set_password   s    '/		'#$r   c                :    V P                   P                  W34      # rD   )ri   getr\   s   &&&r   r_   InMemoryKeyring.get_password   s    yy}}g011r   rh   N)
r,   r-   r.   r/   r0   r   rd   r_   r1   r2   rI   s   @r   r   r      s     802 2r   c                   P   a  ] tR t^t o RtR tRRR]P                  3R ltRt	V t
R# )KnownTokensz'Known access token/secret combinations.c                v    Wn         W n        \        W4      V n        \	        R V P                  R7      V n        R# )zlaunchpad-library)consumer_namer(   N)token_stringaccess_secretr
   tokenr   r   )r   rt   ru   s   &&&r   r   KnownTokens.__init__   s0    (* =
&-DJJ
r   Nc                6    \        V P                  VVVVR7      # )z2Create a Launchpad object using these credentials.)r:   r;   r<   r=   )r   r   )r   r:   r;   r<   r=   s   &&&&&r   loginKnownTokens.login   s&     !!
 	
r   )ru   r   rv   rt   )r,   r-   r.   r/   r0   r   r	   rN   ry   r1   r2   rI   s   @r   rq   rq      s+     1
 ))
 
r   rq   zsalgado-change-anythingtestzsalgado-read-nonprivatesecretznopriv-read-nonprivatemystery)
r   rS   r   r   r   r   r   nopriv_read_nonprivatesalgado_read_nonprivatesalgado_with_full_permissions)r0   __all__
contextlibr   r   launchpadlib.launchpadr	   launchpadlib.credentialsr
   r   r   objectr   r   r   r   r   rS   r   r   r   rq   r   r   r~   r   r   r   <module>r      s   & $ &  ,  (H )#B  )F3 3D
	 
D 
4 
4  
2 
2
 
8 !,,Ev N %&?J $%=yI r   