+
    üÐj(  ã                   ó  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHtHtHtHtHt ^ RIH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$
Tests for L{twisted.web.resource}.
)ÚTestCase)ÚUnsupportedMethod)ÚHeaders)ÚIRequest)Ú	FORBIDDENÚ	NOT_FOUNDÚResourceÚ_UnsafeErrorPageÚ_UnsafeForbiddenResourceÚ_UnsafeNoResourceÚgetChildForRequest)ÚDummyRequestc                   ó´   a € ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltRtV tR# )ÚErrorPageTestszV
Tests for L{_UnafeErrorPage}, L{_UnsafeNoResource}, and
L{_UnsafeForbiddenResource}.
c                ó   <€ V ^8„  d   QhRR/# ©é   ÚreturnN© )ÚformatÚ__classdict__s   "€Ú@/usr/lib/python3/dist-packages/twisted/web/test/test_resource.pyÚ__annotate__ÚErrorPageTests.__annotate__   s   ø€ ÷ 	Iñ 	I¨$ñ 	Ió    c                ó°   € \        ^{RR4      pV P                  4       w  pV P                  VR,          \        4       V P	                  RVR,          4       R# )z‡
The public C{twisted.web.resource.ErrorPage} alias for the
corresponding C{_Unsafe} class produces a deprecation warning when
called.
Úonozono!Úcategoryztwisted.web.pages.errorPageÚmessageN)Ú	ErrorPageÚflushWarningsÚassertEqualÚDeprecationWarningÚassertIn©ÚselfÚ_Úwarnings   &  r   Útest_deprecatedErrorPageÚ'ErrorPageTests.test_deprecatedErrorPage   sL   € ô �c˜5 &Ó)ˆØ×&Ñ&Ó(‰	ˆØ×Ñ˜ Õ,Ô.@ÔAØ�‰Ð3°W¸YÕ5GÖHr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   )   s   ø€ ÷ 	Hñ 	H¨4ñ 	Hr   c                óª   € \        4       pV P                  4       w  pV P                  VR,          \        4       V P	                  RVR,          4       R# )zˆ
The public C{twisted.web.resource.NoResource} alias for the
corresponding C{_Unsafe} class produces a deprecation warning when
called.
r   ztwisted.web.pages.notFoundr   N)Ú
NoResourcer    r!   r"   r#   r$   s   &  r   Útest_deprecatedNoResourceÚ(ErrorPageTests.test_deprecatedNoResource)   sE   € ô ‹LˆØ×&Ñ&Ó(‰	ˆØ×Ñ˜ Õ,Ô.@ÔAØ�‰Ð2°G¸IÕ4FÖGr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   4   s   ø€ ÷ 	Iñ 	I°$ñ 	Ir   c                óª   € \        4       pV P                  4       w  pV P                  VR,          \        4       V P	                  RVR,          4       R# )zŽ
The public C{twisted.web.resource.ForbiddenResource} alias for the
corresponding C{_Unsafe} class produce a deprecation warning when
called.
r   ztwisted.web.pages.forbiddenr   N)ÚForbiddenResourcer    r!   r"   r#   r$   s   &  r   Ú test_deprecatedForbiddenResourceÚ/ErrorPageTests.test_deprecatedForbiddenResource4   sF   € ô ÓˆØ×&Ñ&Ó(‰	ˆØ×Ñ˜ Õ,Ô.@ÔAØ�‰Ð3°W¸YÕ5GÖHr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   ?   s   ø€ ÷ Eñ E˜tñ Er   c                ót   € \        RRR4      pV P                  VP                  R\        4       4      V4       R# )zR
The C{getChild} method of L{ErrorPage} returns the L{ErrorPage} it is
called on.
éA  ÚfooÚbars   nameN)r   ÚassertIdenticalÚgetChildÚobject)r%   Úpages   & r   Útest_getChildÚErrorPageTests.test_getChild?   s/   € ô
 ˜˜e UÓ+ˆØ×Ñ˜TŸ]™]¨7´F³HÓ=¸tÖDr   c          
      ó6   <€ V ^8„  d   QhRS[ RS[RS[RS[RR/# )r   r<   ÚcodeÚbriefÚdetailr   N)r   ÚintÚstr)r   r   s   "€r   r   r   G   s5   ø€ ÷ 
ñ 
Ùð
Ù$'ð
Ù03ð
Ù=@ð
à	ñ
r   c                ó   € \        R .4      pRpWbW3V3,          pV P                  VP                  V4      VP                  R4      4       V P                  VP                  V4       V P                  VP
                  \        RR./4      4       R# )r   zg
<html>
  <head><title>%s - %s</title></head>
  <body>
    <h1>%s</h1>
    <p>%s</p>
  </body>
</html>
zutf-8s   content-types   text/html; charset=utf-8N)r   r!   ÚrenderÚencodeÚresponseCodeÚresponseHeadersr   )r%   r<   r@   rA   rB   ÚrequestÚtemplateÚexpecteds   &&&&&   r   Ú_pageRenderingTestÚ!ErrorPageTests._pageRenderingTestG   s‹   € ô  ˜uÓ%ˆðð 	ð  U°6Ð:Õ:ˆØ×Ñ˜Ÿ™ WÓ-¨x¯©¸wÓ/GÔHØ×Ñ˜×-Ñ-¨tÔ4Ø×ÑØ×#Ñ#Ü�_Ð'BÐ&CÐDÓEö	
r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   ]   s   ø€ ÷ ;ñ ;¨ñ ;r   c                óN   € RpRpRp\        WV4      pV P                  WAW#4       R# )zÞ
L{ErrorPage.render} returns a C{bytes} describing the error defined by
the response code and message passed to L{ErrorPage.__init__}.  It also
uses that response code to set the response code on the L{Request}
passed in.
r6   zbrief description textzmuch longer text might go hereN)r   rM   )r%   r@   rA   rB   r<   s   &    r   Útest_errorPageRenderingÚ&ErrorPageTests.test_errorPageRendering]   s/   € ð ˆØ(ˆØ1ˆÜ˜ fÓ-ˆØ×Ñ ¨EÖ:r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   j   s   ø€ ÷ Mñ M¨$ñ Mr   c                óP   € Rp\        V4      pV P                  V\        RV4       R# )z0
L{NoResource} sets the HTTP I{NOT FOUND} code.
zlong messagezNo Such ResourceN)r,   rM   r   ©r%   rB   r<   s   &  r   Útest_noResourceRenderingÚ'ErrorPageTests.test_noResourceRenderingj   s(   € ð  ˆÜ˜&Ó!ˆØ×Ñ ¤iÐ1CÀVÖLr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r   r   s   ø€ ÷ Oñ O°ñ Or   c                óP   € Rp\        V4      pV P                  V\        RV4       R# )z7
L{ForbiddenResource} sets the HTTP I{FORBIDDEN} code.
zlonger messagezForbidden ResourceN)r1   rM   r   rU   s   &  r   Útest_forbiddenResourceRenderingÚ.ErrorPageTests.test_forbiddenResourceRenderingr   s(   € ð "ˆÜ  Ó(ˆØ×Ñ ¤iÐ1EÀvÖNr   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r(   r-   r2   r=   rM   rQ   rV   rZ   Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      sf   ø‡ € ñ÷
	Ið 	I÷	Hð 	H÷	Ið 	I÷Eð E÷
ð 
÷,;ð ;÷Mð M÷Oö Or   r   c                   ó6   a € ] tR t^{t o RtV 3R lR ltRtV tR# )ÚDynamicChildz?
A L{Resource} to be created on the fly by L{DynamicChildren}.
c                ó*   <€ V ^8„  d   QhRS[ RS[RR/# )r   ÚpathrJ   r   N)Úbytesr   )r   r   s   "€r   r   ÚDynamicChild.__annotate__€   s"   ø€ ÷ ñ ™Uð ©Xð ¸$ñ r   c                óJ   € \         P                  ! V 4       Wn        W n        R # ©N)r   Ú__init__rg   rJ   ©r%   rg   rJ   s   &&&r   rl   ÚDynamicChild.__init__€   s   € Ü×Ò˜$ÔØŒ	ØŽr   )rg   rJ   N)r\   r]   r^   r_   r`   rl   ra   rb   rc   s   @r   re   re   {   s   ø‡ € ñ÷ö r   re   c                   ó6   a € ] tR t^†t o RtV 3R lR ltRtV tR# )ÚDynamicChildrenz&
A L{Resource} with dynamic children.
c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r   rg   rJ   r   )rh   r   re   )r   r   s   "€r   r   ÚDynamicChildren.__annotate__‹   s"   ø€ ÷ +ñ +™Uð +©Xð +¹,ñ +r   c                ó   € \        W4      # rk   )re   rm   s   &&&r   r:   ÚDynamicChildren.getChild‹   s   € Ü˜DÓ*Ð*r   r   N)r\   r]   r^   r_   r`   r:   ra   rb   rc   s   @r   rp   rp   †   s   ø‡ € ñ÷+ö +r   rp   c                   óH   a € ] tR t^�t o RtV 3R lR ltV 3R lR ltRtV tR# )ÚBytesReturnedRenderablez?
A L{Resource} with minimal capabilities to render a response.
c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   Úresponser   N)rh   )r   r   s   "€r   r   Ú$BytesReturnedRenderable.__annotate__”   s   ø€ ÷ "ñ "¡ð "¨4ñ "r   c                ó>   € \         P                  ! V 4       Wn        R# )zW
@param response: A C{bytes} object giving the value to return from
    C{render_GET}.
N)r   rl   Ú	_response)r%   rx   s   &&r   rl   Ú BytesReturnedRenderable.__init__”   s   € ô
 	×Ò˜$ÔØ!Žr   c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   rJ   r   )r;   rh   )r   r   s   "€r   r   ry   œ   s   ø€ ÷ ñ ¡&ð ©Uñ r   c                ó   € V P                   # )ze
Render a response to a I{GET} request by returning a short byte string
to be written by the server.
©r{   ©r%   rJ   s   &&r   Ú
render_GETÚ"BytesReturnedRenderable.render_GETœ   s   € ð
 �~‰~Ðr   r   N)	r\   r]   r^   r_   r`   rl   r�   ra   rb   rc   s   @r   rv   rv   �   s   ø‡ € ñ÷"ð "÷ö r   rv   c                   óH   a € ] tR t^¤t o RtV 3R lR ltV 3R lR ltRtV tR# )ÚImplicitAllowedMethodszb
A L{Resource} which implicitly defines its allowed methods by defining
renderers to handle them.
c                ó$   <€ V ^8„  d   QhRS[ RR/# ©r   rJ   r   N©r;   )r   r   s   "€r   r   Ú#ImplicitAllowedMethods.__annotate__ª   ó   ø€ ÷ ñ ¡&ð ¨Tñ r   c                ó   € R # rk   r   r€   s   &&r   r�   Ú!ImplicitAllowedMethods.render_GETª   ó   € Ùr   c                ó$   <€ V ^8„  d   QhRS[ RR/# r†   r‡   )r   r   s   "€r   r   rˆ   ­   r‰   r   c                ó   € R # rk   r   r€   s   &&r   Ú
render_PUTÚ!ImplicitAllowedMethods.render_PUT­   rŒ   r   r   N)	r\   r]   r^   r_   r`   r�   r�   ra   rb   rc   s   @r   r„   r„   ¤   s   ø‡ € ñ÷
ð ÷ö r   r„   c                   ó�   a € ] tR t^±t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
RtV tR# )ÚResourceTestsz
Tests for L{Resource}.
c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   ÚResourceTests.__annotate__¶   s   ø€ ÷ 
ñ 
 Tñ 
r   c           	     óÞ   € \        4       p\        4       p\        4       pVP                  RV4       VP                  RV4       V P                  W!P                  R\	        . 4      4      4       R# )z�
L{Resource.putChild} adds a I{static} child to the resource.  That child
is returned from any call to L{Resource.getChildWithDefault} for the
child's path.
ó   fooó   barN)r   ÚputChildr9   ÚgetChildWithDefaultr   ©r%   ÚresourceÚchildÚsiblings   &   r   Útest_staticChildrenÚ!ResourceTests.test_staticChildren¶   s\   € ô “:ˆÜ“
ˆÜ“*ˆØ×Ñ˜& %Ô(Ø×Ñ˜& 'Ô*Ø×ÑØ×/Ñ/°¼ÀRÓ8HÓIö	
r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r”   Å   s   ø€ ÷ 5ñ 5 dñ 5r   c                óò   € Rp\        . 4      p\        4       pVP                  W4      pV P                  V\        4       V P                  VP                  V4       V P                  VP                  V4       R# )z„
L{Resource.getChildWithDefault} delegates to L{Resource.getChild} when
the requested path is not associated with any static child.
r–   N)	r   rp   r™   ÚassertIsInstancere   r!   rg   r9   rJ   )r%   rg   rJ   r›   rœ   s   &    r   Útest_dynamicChildrenÚ"ResourceTests.test_dynamicChildrenÅ   sc   € ð
 ˆÜ˜rÓ"ˆÜ"Ó$ˆØ×,Ñ,¨TÓ;ˆØ×Ñ˜e¤\Ô2Ø×Ñ˜Ÿ™ TÔ*Ø×Ñ˜UŸ]™]¨GÖ4r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r”   Ò   s   ø€ ÷ 	Gñ 	G¨$ñ 	Gr   c                óÊ   € \        4       p\        4       p\        4       pV P                  \        VP                  RV4       V P                  \        VP                  RV4       R# )z^
Test that passing the wrong type to putChild results in a warning,
and a failure in Python 3
r7   N)r   ÚassertRaisesÚ	TypeErrorr˜   rš   s   &   r   Útest_staticChildPathTypeÚ&ResourceTests.test_staticChildPathTypeÒ   sM   € ô
 “:ˆÜ“
ˆÜ“*ˆØ×Ñœ) X×%6Ñ%6¸¸uÔEØ×Ñœ) X×%6Ñ%6¸¸gÖFr   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r”   Ý   s   ø€ ÷ 	=ñ 	= $ñ 	=r   c                ó„   € Rp\        . 4      pRVn        \        V4      pV P                  WP	                  V4      4       R# )zl
When not otherwise overridden, L{Resource.render} treats a I{HEAD}
request as if it were a I{GET} request.
s   insert response hereó   HEADN)r   Úmethodrv   r!   rF   )r%   rL   rJ   r›   s   &   r   Útest_defaultHEADÚResourceTests.test_defaultHEADÝ   s;   € ð
 +ˆÜ˜rÓ"ˆØ ˆŒÜ*¨8Ó4ˆØ×Ñ˜§?¡?°7Ó#;Ö<r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r”   è   s   ø€ ÷ Añ A¨Tñ Ar   c                óð   € . ROp\        4       pWn        \        . 4      pRVn        V P	                  \
        VP                  V4      pV P                  \        V4      \        VP                  4      4       R# )zÒ
The L{UnsupportedMethod} raised by L{Resource.render} for an unsupported
request method has a C{allowedMethods} attribute set to the value of the
C{allowedMethods} attribute of the L{Resource}, if it has one.
ó	   FICTIONALN)ó   GETr­   ó   PUT)	r   ÚallowedMethodsr   r®   r§   r   rF   r!   Úset©r%   rL   r›   rJ   Úexcs   &    r   Útest_explicitAllowedMethodsÚ)ResourceTests.test_explicitAllowedMethodsè   s_   € ò -ˆÜ“:ˆØ"*ÔÜ˜rÓ"ˆØ%ˆŒØ×ÑÔ 1°8·?±?ÀGÓLˆØ×Ñœ˜X›¬¨C×,>Ñ,>Ó(?Ö@r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   r”   ö   s   ø€ ÷ <ñ <¨Tñ <r   c                óÒ   € 0 Rmp\        4       p\        . 4      pRVn        V P                  \        VP
                  V4      pV P                  V\        VP                  4      4       R# )a<  
The L{UnsupportedMethod} raised by L{Resource.render} for an unsupported
request method has a C{allowedMethods} attribute set to a list of the
methods supported by the L{Resource}, as determined by the
I{render_}-prefixed methods which it defines, if C{allowedMethods} is
not explicitly defined by the L{Resource}.
r³   N>   r´   rµ   r­   )	r„   r   r®   r§   r   rF   r!   r·   r¶   r¸   s   &    r   Útest_implicitAllowedMethodsÚ)ResourceTests.test_implicitAllowedMethodsö   sV   € ò -ˆÜ)Ó+ˆÜ˜rÓ"ˆØ%ˆŒØ×ÑÔ 1°8·?±?ÀGÓLˆØ×Ñ˜¤3 s×'9Ñ'9Ó#:Ö;r   r   N)r\   r]   r^   r_   r`   rž   r£   r©   r¯   rº   r¾   ra   rb   rc   s   @r   r’   r’   ±   sJ   ø‡ € ñ÷
ð 
÷5ð 5÷	Gð 	G÷	=ð 	=÷Að A÷<ö <r   r’   c                   óZ   a € ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltR	tV t	R
# )ÚGetChildForRequestTestsi  z"
Tests for L{getChildForRequest}.
c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   Ú$GetChildForRequestTests.__annotate__  s   ø€ ÷ /ñ /¨ñ /r   c                óh   € \        . 4      p\        4       p\        W!4      pV P                  W#4       R# )zr
L{getChildForRequest} returns whatever resource has been reached by the
time the request's C{postpath} is empty.
N)r   r   r   r9   ©r%   rJ   r›   Úresults   &   r   Útest_exhaustedPostPathÚ.GetChildForRequestTests.test_exhaustedPostPath  s-   € ô
 ˜rÓ"ˆÜ“:ˆÜ# HÓ6ˆØ×Ñ˜XÖ.r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   rÃ     s   ø€ ÷ 	/ñ 	/ 4ñ 	/r   c                óz   € \        RR.4      p\        4       pRVn        \        W!4      pV P	                  W#4       R# )zk
L{getChildForRequest} returns the first resource it encounters with a
C{isLeaf} attribute set to C{True}.
r–   r—   TN)r   r   ÚisLeafr   r9   rÅ   s   &   r   Útest_leafResourceÚ)GetChildForRequestTests.test_leafResource  s9   € ô
  ¨Ð/Ó0ˆÜ“:ˆØˆŒÜ# HÓ6ˆØ×Ñ˜XÖ.r   c                ó   <€ V ^8„  d   QhRR/# r   r   )r   r   s   "€r   r   rÃ      s   ø€ ÷ 5ñ 5¨ñ 5r   c                ó$  € \        RR.4      p\        4       p\        4       pRVn        VP                  RV4       V P	                  V\        W!4      4       V P                  VP                  R.4       V P                  VP                  R.4       R# )zk
As path segments from the request are traversed, they are taken from
C{postpath} and put into C{prepath}.
r–   r—   TN)	r   r   rË   r˜   r9   r   r!   ÚprepathÚpostpath)r%   rJ   Úrootrœ   s   &   r   Útest_postPathToPrePathÚ.GetChildForRequestTests.test_postPathToPrePath   sz   € ô
  ¨Ð/Ó0ˆÜ‹zˆÜ“
ˆØˆŒØ�‰�f˜eÔ$Ø×Ñ˜UÔ$6°tÓ$EÔFØ×Ñ˜Ÿ™¨6¨(Ô3Ø×Ñ˜×)Ñ)¨F¨8Ö4r   r   N)
r\   r]   r^   r_   r`   rÇ   rÌ   rÓ   ra   rb   rc   s   @r   rÁ   rÁ     s(   ø‡ € ñ÷/ð /÷	/ð 	/÷5ö 5r   rÁ   N)r`   Útwisted.trial.unittestr   Útwisted.web.errorr   Útwisted.web.http_headersr   Útwisted.web.iwebr   Útwisted.web.resourcer   r   r   r	   r   r
   r1   r   r,   r   Útwisted.web.test.requesthelperr   r   re   rp   rv   r„   r’   rÁ   r   r   r   Ú<module>rÛ      sˆ   ðñõ ,Ý /Ý ,Ý %÷÷ ñ õ 8ô`O�Xô `OôF�8ô ô+�hô +ô˜hô ô*
˜Xô 
ôR<�Hô R<ôj&5˜hö &5r   