+
    Z4i‘$  ã                   ó2  € R t ^ RIHt ^ RIHtHt ^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt Rt]! / 4      P%                  R	4      t ! R
 R4      t ! R R]4      t ! R R]4      t ! R R]P.                  4      t ! R R]4      t ! R R]4      tR# )z,Tests for the LaunchpadOAuthAwareHTTP class.)Údeque)ÚdumpsÚJSONDecodeErrorN)ÚUnauthorized)ÚUnencryptedFileCredentialStore)Ú	LaunchpadÚLaunchpadOAuthAwareHttp)ÚNoNetworkAuthorizationEnginesÝ  <?xml version="1.0"?>
<application xmlns="http://research.sun.com/wadl/2006/10">
  <resources base="http://www.example.com/">
    <resource path="" type="#service-root"/>
  </resources>

  <resource_type id="service-root">
    <method name="GET" id="service-root-get">
      <response>
        <representation href="#service-root-json"/>
      </response>
    </method>
  </resource_type>

  <representation id="service-root-json" mediaType="application/json"/>
</application>
zutf-8c                   ó*   a € ] tR t^8t o RtR tRtV tR# )ÚResponsezA fake HTTP response object.c                ó   € Wn         W n        R # ©N)ÚstatusÚcontent)Úselfr   r   s   &&&Ú>/usr/lib/python3/dist-packages/launchpadlib/tests/test_http.pyÚ__init__ÚResponse.__init__;   s   € ØŒØŽó    )r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   8   s   ø‡ € Ù&÷ð r   r   c                   ó<   a a€ ] tR t^@t oRtV 3R ltR tRtVtV ;t	# )ÚSimulatedResponsesHttpz<Responds to HTTP requests by shifting responses off a stack.c                óL   <€ \         SV `  ! V!   . V n        Wn        RV n        R# )zcConstructor.

:param responses: A list of HttpResponse objects to use
    in response to requests.
N)Úsuperr   Úsent_responsesÚunsent_responsesÚcache)r   Ú	responsesÚargsÚ	__class__s   &&*€r   r   ÚSimulatedResponsesHttp.__init__C   s'   ø€ ô 	‰Ò˜$ÒØ ˆÔØ )ÔØˆŽ
r   c                ó¨   € V P                   P                  4       pV P                  P                  V4       V P                  ! W"P
                  .VO5!  # r   )r#   Úpopleftr"   ÚappendÚretry_on_bad_tokenr   )r   r&   Úresponses   &* r   Ú_requestÚSimulatedResponsesHttp._requestN   sF   € Ø×(Ñ(×0Ñ0Ó2ˆØ×Ñ×"Ñ" 8Ô,Ø×&Ò& x×1AÑ1AÐIÀDÓIÐIr   )r$   r"   r#   )
r   r   r   r   r   r   r.   r   r   Ú__classcell__)r'   r   s   @@r   r   r   @   s   ù‡ € ÙFõ	÷Jò Jr   r   c                   ó:   a € ] tR t^Tt o . tR t]R 4       tRtV t	R# )ÚSimulatedResponsesLaunchpadc                óX   € \        \        V P                  4      W P                  .VO5!  # r   )r   r   r%   Úauthorization_engine)r   r&   s   &*r   ÚhttpFactoryÚ'SimulatedResponsesLaunchpad.httpFactoryZ   s+   € Ü%Ü�$—.‘.Ó! 4×)BÑ)Bð
ØEIó
ð 	
r   c                óN   € \        \        P                  ! 4       ^,          V4      # )é   )r   ÚtempfileÚmkstemp)ÚclsÚcredential_save_faileds   &&r   Úcredential_store_factoryÚ4SimulatedResponsesLaunchpad.credential_store_factory_   s#   € ä-Ü×ÒÓ˜qÕ!Ð#9ó
ð 	
r   © N)
r   r   r   r   r%   r5   Úclassmethodr=   r   r   r   s   @r   r2   r2   T   s%   ø‡ € ð €Iò
ð
 ñ
ó ö
r   r2   c                   ó0   a € ] tR t^ft o RtR tR tRtV tR# )ÚSimulatedResponsesTestCasezATest cases that give fake responses to launchpad's HTTP requests.c                ó>   € . \         n        \        RR4      V n        R# )z*Clear out the list of simulated responses.zhttp://api.example.com/úapplication nameN)r2   r%   r	   Úengine©r   s   &r   ÚsetUpÚ SimulatedResponsesTestCase.setUpi   s   € à02Ô#Ô-Ü2Ø%Ð'9ó
ˆŽr   c                óZ   € V\         n        \         P                  RV P                  R7      # )aA  Use simulated HTTP responses to get a Launchpad object.

The given Response objects will be sent, in order, in response
to launchpadlib's requests.

:param responses: Some number of Response objects.
:return: The Launchpad object, assuming that errors in the
    simulated requests didn't prevent one from being created.
rD   ©r4   )r2   r%   Ú
login_withrE   )r   r%   s   &*r   Úlaunchpad_with_responsesÚ3SimulatedResponsesTestCase.launchpad_with_responsesp   s.   € ð 1:Ô#Ô-Ü*×5Ñ5Ø°T·[±[ð 6ó 
ð 	
r   )rE   N)	r   r   r   r   r   rG   rL   r   r   r   s   @r   rB   rB   f   s   ø‡ € ÙKò
÷
ð 
r   rB   c                   ó6   a € ] tR t^€t o RtR tR tR tRtV t	R# )ÚTestAbilityToParseDataaG  Test launchpadlib's ability to handle the sample data.

To create a Launchpad object, two HTTP requests must succeed and
return usable data: the requests for the WADL and JSON
representations of the service root. This test shows that the
minimal data in SIMPLE_WADL and SIMPLE_JSON is good enough to
create a Launchpad object.
c                ób   € V P                  \        ^È\        4      \        ^È\        4      4       R# )z5Make sure that launchpadlib can use the minimal data.N)rL   r   ÚSIMPLE_WADLÚSIMPLE_JSONrF   s   &r   Útest_minimal_dataÚ(TestAbilityToParseData.test_minimal_dataŠ   s#   € à×%Ñ%Ü�Sœ+Ó&¬°´kÓ(Bö	
r   c           	     óz   € V P                  \        V P                  \        ^ÈR4      \        ^È\        4      4       R# )z'Show that bad WADL causes an exception.s   This is not WADL.N)ÚassertRaisesÚSyntaxErrorrL   r   rR   rF   s   &r   Útest_bad_wadlÚ$TestAbilityToParseData.test_bad_wadl�   s1   € à×ÑÜØ×)Ñ)Ü�SÐ.Ó/Ü�Sœ+Ó&ö		
r   c           	     óz   € V P                  \        V P                  \        ^È\        4      \        ^ÈR4      4       R# )z'Show that bad JSON causes an exception.s   This is not JSON.N)rV   r   rL   r   rQ   rF   s   &r   Útest_bad_jsonÚ$TestAbilityToParseData.test_bad_json™   s1   € à×ÑÜØ×)Ñ)Ü�Sœ+Ó&Ü�SÐ.Ó/ö		
r   r?   N)
r   r   r   r   r   rS   rX   r[   r   r   r   s   @r   rO   rO   €   s   ø‡ € ñò
ò
÷
ð 
r   rO   c                   óN   a € ] tR t^£t o RtR tR tR tR tR t	R t
R tR	tV tR
# )ÚTestTokenFailureDuringRequesta  Test access token failures during a request.

launchpadlib makes two HTTP requests on startup, to get the WADL
and JSON representations of the service root. If Launchpad
receives a 401 error during this process, it will acquire a fresh
access token and try again.
c                ó2  € \        ^È\        4      \        ^È\        4      .\        n        V P                  V P                  P                  ^ 4       \        P                  RV P                  R7       V P                  V P                  P                  ^4       R# )z/If our token is good, we never get another one.rD   rJ   N©	r   rQ   rR   r2   r%   ÚassertEqualrE   Úaccess_tokens_obtainedrK   rF   s   &r   Útest_good_tokenÚ-TestTokenFailureDuringRequest.test_good_token¬   sw   € ô �Sœ+Ó&Ü�Sœ+Ó&ð1
Ô#Ô-ð
 	×Ñ˜Ÿ™×;Ñ;¸QÔ?Ü#×.Ñ.Ø°T·[±[ð 	/ô 	
ð 	×Ñ˜Ÿ™×;Ñ;¸QÖ?r   c                óH  € \        RR4      \        ^È\        4      \        ^È\        4      .\        n        V P                  V P                  P                  ^ 4       \        P                  RV P                  R7       V P                  V P                  P                  ^4       R# )z(If our token is bad, we get another one.é‘  ó   Invalid token.rD   rJ   Nr`   rF   s   &r   Útest_bad_tokenÚ,TestTokenFailureDuringRequest.test_bad_token¹   s‚   € ô �SÐ+Ó,Ü�Sœ+Ó&Ü�Sœ+Ó&ð1
Ô#Ô-ð 	×Ñ˜Ÿ™×;Ñ;¸QÔ?Ü#×.Ñ.Ø°T·[±[ð 	/ô 	
ð 	×Ñ˜Ÿ™×;Ñ;¸QÖ?r   c                óH  € \        RR4      \        ^È\        4      \        ^È\        4      .\        n        V P                  V P                  P                  ^ 4       \        P                  RV P                  R7       V P                  V P                  P                  ^4       R# )z,If our token is expired, we get another one.rf   ó   Expired token.rD   rJ   Nr`   rF   s   &r   Útest_expired_tokenÚ0TestTokenFailureDuringRequest.test_expired_tokenÇ   s‚   € ô �SÐ+Ó,Ü�Sœ+Ó&Ü�Sœ+Ó&ð1
Ô#Ô-ð 	×Ñ˜Ÿ™×;Ñ;¸QÔ?Ü#×.Ñ.Ø°T·[±[ð 	/ô 	
ð 	×Ñ˜Ÿ™×;Ñ;¸QÖ?r   c                óH  € \        RR4      \        ^È\        4      \        ^È\        4      .\        n        V P                  V P                  P                  ^ 4       \        P                  RV P                  R7       V P                  V P                  P                  ^4       R# )z,If our token is unknown, we get another one.rf   s   Unknown access token.rD   rJ   Nr`   rF   s   &r   Útest_unknown_tokenÚ0TestTokenFailureDuringRequest.test_unknown_tokenÖ   s‚   € ô �SÐ2Ó3Ü�Sœ+Ó&Ü�Sœ+Ó&ð1
Ô#Ô-ð 	×Ñ˜Ÿ™×;Ñ;¸QÔ?Ü#×.Ñ.Ø°T·[±[ð 	/ô 	
ð 	×Ñ˜Ÿ™×;Ñ;¸QÖ?r   c                óH  € \        ^È\        4      \        RR4      \        ^È\        4      .\        n        V P                  V P                  P                  ^ 4       \        P                  RV P                  R7       V P                  V P                  P                  ^4       R# )z6We get another token no matter when the error happens.rf   rk   rD   rJ   Nr`   rF   s   &r   Útest_delayed_errorÚ0TestTokenFailureDuringRequest.test_delayed_errorå   s‚   € ô �Sœ+Ó&Ü�SÐ+Ó,Ü�Sœ+Ó&ð1
Ô#Ô-ð 	×Ñ˜Ÿ™×;Ñ;¸QÔ?Ü#×.Ñ.Ø°T·[±[ð 	/ô 	
ð 	×Ñ˜Ÿ™×;Ñ;¸QÖ?r   c                ót  € \        RR4      \        ^È\        4      \        RR4      \        RR4      \        ^È\        4      .\        n        V P                  V P                  P                  ^ 4       \        P                  RV P                  R7       V P                  V P                  P                  ^4       R# )z@We'll keep getting new tokens as long as tokens are the problem.rf   rg   rk   rD   rJ   Nr`   rF   s   &r   Útest_many_errorsÚ.TestTokenFailureDuringRequest.test_many_errorsó   s˜   € ô �SÐ+Ó,Ü�Sœ+Ó&Ü�SÐ+Ó,Ü�SÐ+Ó,Ü�Sœ+Ó&ð1
Ô#Ô-ð 	×Ñ˜Ÿ™×;Ñ;¸QÔ?Ü#×.Ñ.Ø°T·[±[ð 	/ô 	
ð 	×Ñ˜Ÿ™×;Ñ;¸QÖ?r   c                ó”   € \        RR4      .\        n        V P                  \        \        P
                  RV P                  R7       R# )z>If the token is not at fault, a 401 error raises an exception.rf   s   Some other error.rD   rJ   N)r   r2   r%   rV   r   rK   rE   rF   s   &r   Útest_other_unauthorizedÚ5TestTokenFailureDuringRequest.test_other_unauthorized  sE   € ô �SÐ.Ó/ð1
Ô#Ô-ð 	×ÑÜÜ'×2Ñ2ØØ!%§¡ð	 	ö 	
r   r?   N)r   r   r   r   r   rc   rh   rl   ro   rr   ru   rx   r   r   r   s   @r   r^   r^   £   s8   ø‡ € ñò@ò@ò@ò@ò@ò@÷
ð 
r   r^   )r   Úcollectionsr   Újsonr   r   r9   ÚunittestÚlaunchpadlib.errorsr   Úlaunchpadlib.credentialsr   Úlaunchpadlib.launchpadr   r   Úlaunchpadlib.testing.helpersr	   rQ   ÚencoderR   r   r   r2   ÚTestCaserB   rO   r^   r?   r   r   Ú<module>rƒ      s˜   ðñ" 3å ß 'Û Û å ,Ý C÷õ Fð€ñ& �B‹i×Ñ˜wÓ'€÷ñ ôJÐ4ô Jô(
 )ô 
ô$
 ×!2Ñ!2ô 
ô4 
Ð7ô  
ôFk
Ð$>ö k
r   