+
    Dfj                         R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHt  ! R	 R
]4      t ! R R]4      tR# )z"
Tests for L{twisted.web.script}.
N)defer)FilePath)TestCase)	NOT_FOUND)PythonScriptResourceScriptDirectory)_render)DummyRequestc                   Z   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RtV t	R	# )
ResourceScriptDirectoryTestsz'
Tests for L{ResourceScriptDirectory}.
c                B   < V ^8  d   QhRS[ P                  R,          /#    returnNr   Deferred)format__classdict__s   ">/usr/lib/python3/dist-packages/twisted/web/test/test_script.py__annotate__)ResourceScriptDirectoryTests.__annotate__        ) )U^^D%9 )    c                   a a \        S P                  4       4      p\        R.4      o\        VS4      pR VV 3R llpVP	                  V4      # )zP
L{ResourceScriptDirectory.render} sets the HTTP response code to I{NOT
FOUND}.
r   c                (    V ^8  d   QhR\         RR/# r   ignoredr   Nobject)r   s   "r   r   FResourceScriptDirectoryTests.test_renderNotFound.<locals>.__annotate__!        	> 	> 	>4 	>r   c                 H   < SP                  SP                  \        4       R # NassertEqualresponseCoder   r   requestselfs   &r   
cbRenderedDResourceScriptDirectoryTests.test_renderNotFound.<locals>.cbRendered!       W119=r   )r   mktempr	   r   addCallbackr(   resourcedr)   r'   s   f   @r   test_renderNotFound0ResourceScriptDirectoryTests.test_renderNotFound   sH    
 +4;;=9u%Hg&	> 	> }}Z((r   c                B   < V ^8  d   QhRS[ P                  R,          /# r   r   )r   r   s   "r   r   r   &   s     ) )ENN4$8 )r   c                   a a S P                  4       p\        P                  ! V4       \        V4      p\	        R.4      oVP                  RS4      p\        VS4      pR VV 3R llpVP                  V4      # )z
L{ResourceScriptDirectory.getChild} returns a resource which renders an
response with the HTTP I{NOT FOUND} status code if the indicated child
does not exist as an entry in the directory used to initialized the
L{ResourceScriptDirectory}.
s   foofooc                (    V ^8  d   QhR\         RR/# r   r   )r   s   "r   r   EResourceScriptDirectoryTests.test_notFoundChild.<locals>.__annotate__4   r    r   c                 H   < SP                  SP                  \        4       R # r"   r#   r&   s   &r   r)   CResourceScriptDirectoryTests.test_notFoundChild.<locals>.cbRendered4   r+   r   )r,   osmakedirsr   r	   getChildr   r-   )r(   pathr/   childr0   r)   r'   s   f     @r   test_notFoundChild/ResourceScriptDirectoryTests.test_notFoundChild&   sk     {{}
D*40x(!!%1E7#	> 	> }}Z((r   c                B   < V ^8  d   QhRS[ P                  R,          /# r   r   )r   r   s   "r   r   r   9   s     ) )U^^D1 )r   c                T  a a \        S P                  4       4      pVP                  4        VP                  R4      P	                  R4       \        VP                  4       4      p\        R.4      oVP                  RS4      p\        VS4      pR VV 3R llpVP                  V4      # )
L{ResourceScriptDirectory.getChild} returns a resource which renders a
response with the HTTP 200 status code and the content of the rpy's
C{request} global.
ztest.rpys   
from twisted.web.resource import Resource
class TestResource(Resource):
    isLeaf = True
    def render_GET(self, request):
        return b'ok'
resource = TestResource()r   s   test.rpyc                (    V ^8  d   QhR\         RR/# r   r   )r   s   "r   r   >ResourceScriptDirectoryTests.test_render.<locals>.__annotate__O   s     	? 	? 	?4 	?r   c                 ^   < SP                  R P                  SP                  4      R4       R# )r   s   okN)r$   joinwrittenr&   s   &r   r)   <ResourceScriptDirectoryTests.test_render.<locals>.cbRenderedO   s     SXXgoo6>r   )r   r,   r;   r>   
setContentr   _asBytesPathr	   r<   r   r-   )r(   tmpr/   r>   r0   r)   r'   s   f     @r   test_render(ResourceScriptDirectoryTests.test_render9   s     t{{}%		*((	
 +3+;+;+=>u%!!+w7E7#	? 	? }}Z((r    N)
__name__
__module____qualname____firstlineno____doc__r1   r?   rM   __static_attributes____classdictcell__r   s   @r   r   r      s(     ) )) )&) )r   r   c                   H   a  ] tR t^Ut o RtV 3R lR ltV 3R lR ltRtV tR# )PythonScriptTestsz
Tests for L{PythonScript}.
c                B   < V ^8  d   QhRS[ P                  R,          /# r   r   )r   r   s   "r   r   PythonScriptTests.__annotate__Z   r   r   c                   a a \        S P                  4       R4      p\        R.4      o\        VS4      pR VV 3R llpVP	                  V4      # )z
If the source file a L{PythonScript} is initialized with doesn't exist,
L{PythonScript.render} sets the HTTP response code to I{NOT FOUND}.
Nr   c                (    V ^8  d   QhR\         RR/# r   r   )r   s   "r   r   ;PythonScriptTests.test_notFoundRender.<locals>.__annotate__c   r    r   c                 H   < SP                  SP                  \        4       R # r"   r#   r&   s   &r   r)   9PythonScriptTests.test_notFoundRender.<locals>.cbRenderedc   r+   r   )r   r,   r	   r   r-   r.   s   f   @r   test_notFoundRender%PythonScriptTests.test_notFoundRenderZ   sJ    
  t4u%Hg&	> 	> }}Z((r   c                B   < V ^8  d   QhRS[ P                  R,          /# r   r   )r   r   s   "r   r   r[   h   s     ) )ennT&: )r   c                6  a a \        S P                  4       4      pVP                  4        VP                  R4      pVP	                  R4       \        VP                  4       R4      p\        R.4      o\        VS4      pR VV 3R llpVP                  V4      # )rC   ztest.epys   raise Exception("nooo")Nr   c                (    V ^8  d   QhR\         RR/# r   r   )r   s   "r   r   <PythonScriptTests.test_renderException.<locals>.__annotate__v   r    r   c                 ^   < SP                  R RP                  SP                  4      4       R# )s   nooor   N)assertInrG   rH   r&   s   &r   r)   :PythonScriptTests.test_renderException.<locals>.cbRenderedv   s    MM'388GOO#<=r   )
r   r,   r;   r>   rJ   r   rK   r	   r   r-   )r(   rL   r>   r/   r0   r)   r'   s   f     @r   test_renderException&PythonScriptTests.test_renderExceptionh   s     t{{}%		*%34 2 2 4d;u%Hg&	> 	> }}Z((r   rO   N)	rP   rQ   rR   rS   rT   ra   rj   rU   rV   rW   s   @r   rY   rY   U   s     ) )) )r   rY   )rT   r:   twisted.internetr   twisted.python.filepathr   twisted.trial.unittestr   twisted.web.httpr   twisted.web.scriptr   r   twisted.web.test._utilr   twisted.web.test.requesthelperr	   r   rY   rO   r   r   <module>rs      s=    
 " , + & D * 7?)8 ?)D$) $)r   