AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/web/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/web/test/__pycache__/test_resource.cpython-310.pyc
o

�b�#�@s�dZddlmZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZddlmZGdd�de�ZGd	d
�d
e
�ZGdd�de
�ZGd
d�de
�ZGdd�de
�ZGdd�de�ZGdd�de�ZdS)z$
Tests for L{twisted.web.resource}.
�)�TestCase)�UnsupportedMethod)�Headers)�	FORBIDDEN�	NOT_FOUND�	ErrorPage�ForbiddenResource�
NoResource�Resource�getChildForRequest)�DummyRequestc@sDeZdZdZeZeZeZ	dd�Z
dd�Zdd�Zdd	�Z
d
d�ZdS)
�ErrorPageTestszJ
    Tests for L{ErrorPage}, L{NoResource}, and L{ForbiddenResource}.
    cCs(|�ddd�}|�|�dt��|�dS)zj
        The C{getChild} method of L{ErrorPage} returns the L{ErrorPage} it is
        called on.
        �A�foo�barsnameN)�	errorPage�assertIdentical�getChild�object)�self�page�r�@/usr/lib/python3/dist-packages/twisted/web/test/test_resource.py�
test_getChild szErrorPageTests.test_getChildcCs`tdg�}d}|||||f}|�|�|�|�d��|�|j|�|�|jtddgi��dS)N�zg
<html>
  <head><title>%s - %s</title></head>
  <body>
    <h1>%s</h1>
    <p>%s</p>
  </body>
</html>
zutf-8scontent-typestext/html; charset=utf-8)r�assertEqual�render�encode�responseCode�responseHeadersr)rr�code�brief�detail�request�template�expectedrrr�_pageRenderingTest(s
�
�z!ErrorPageTests._pageRenderingTestcCs.d}d}d}|�|||�}|�||||�dS)a
        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.
        rzbrief description textzmuch longer text might go hereN)rr&)rr r!r"rrrr�test_errorPageRendering<s
z&ErrorPageTests.test_errorPageRenderingcC�"d}|�|�}|�|td|�dS)z@
        L{NoResource} sets the HTTP I{NOT FOUND} code.
        zlong messagezNo Such ResourceN)�
noResourcer&r�rr"rrrr�test_noResourceRenderingI�
z'ErrorPageTests.test_noResourceRenderingcCr()zG
        L{ForbiddenResource} sets the HTTP I{FORBIDDEN} code.
        zlonger messagezForbidden ResourceN)�forbiddenResourcer&rr*rrr�test_forbiddenResourceRenderingQr,z.ErrorPageTests.test_forbiddenResourceRenderingN)�__name__�
__module__�__qualname__�__doc__rrr	r)rr-rr&r'r+r.rrrrr
s
r
c@�eZdZdZdd�ZdS)�DynamicChildzG
    A L{Resource} to be created on the fly by L{DynamicChildren}.
    cCst�|�||_||_dS�N)r
�__init__�pathr#�rr7r#rrrr6_s

zDynamicChild.__init__N)r/r0r1r2r6rrrrr4Z�r4c@r3)�DynamicChildrenz.
    A L{Resource} with dynamic children.
    cCs
t||�Sr5)r4r8rrrrjs
zDynamicChildren.getChildN)r/r0r1r2rrrrrr:er9r:c@� eZdZdZdd�Zdd�ZdS)�BytesReturnedRenderablezG
    A L{Resource} with minimal capabilities to render a response.
    cCst�|�||_dS)zo
        @param response: A C{bytes} object giving the value to return from
            C{render_GET}.
        N)r
r6�	_response)r�responserrrr6ss

z BytesReturnedRenderable.__init__cCs|jS)z}
        Render a response to a I{GET} request by returning a short byte string
        to be written by the server.
        )r=�rr#rrr�
render_GET{sz"BytesReturnedRenderable.render_GETN)r/r0r1r2r6r@rrrrr<nsr<c@r;)�ImplicitAllowedMethodszn
    A L{Resource} which implicitly defines its allowed methods by defining
    renderers to handle them.
    cC�dSr5rr?rrrr@��z!ImplicitAllowedMethods.render_GETcCrBr5rr?rrr�
render_PUT�rCz!ImplicitAllowedMethods.render_PUTN)r/r0r1r2r@rDrrrrrA�srAc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
ResourceTestsz 
    Tests for L{Resource}.
    cCsFt�}t�}t�}|�d|�|�d|�|�||�dtg���dS)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
�putChildr�getChildWithDefaultr)r�resource�child�siblingrrr�test_staticChildren�s�z!ResourceTests.test_staticChildrencCsJd}tg�}t�}|�||�}|�|t�|�|j|�|�|j|�dS)z�
        L{Resource.getChildWithDefault} delegates to L{Resource.getChild} when
        the requested path is not associated with any static child.
        rFN)	rr:rI�assertIsInstancer4rr7rr#)rr7r#rJrKrrr�test_dynamicChildren�sz"ResourceTests.test_dynamicChildrencCs�t�}t�}t�}|�d|�|�|jg�}|�t|�d�|�d|dd�|�|�dt	g��t
�|�d|�|�|jg�}|�t|�d�|�d|dd�dS)zv
        Test that passing the wrong type to putChild results in a warning,
        and a failure in Python 3
        r�zPath segment must be bytesr�messagerFN)r
rH�
flushWarnings�test_staticChildPathTyper�len�assertInrNrIrr)rrJrKrL�warningsrrrrS�s�z&ResourceTests.test_staticChildPathTypecCs0d}tg�}d|_t|�}|�||�|��dS)z�
        When not otherwise overridden, L{Resource.render} treats a I{HEAD}
        request as if it were a I{GET} request.
        sinsert response here�HEADN)r�methodr<rr)rr%r#rJrrr�test_defaultHEAD�s
zResourceTests.test_defaultHEADcCsLgd�}t�}||_tg�}d|_|�t|j|�}|�t|�t|j��dS)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.
        )�GETrW�PUT�	FICTIONALN)	r
�allowedMethodsrrX�assertRaisesrrr�set�rr%rJr#�excrrr�test_explicitAllowedMethods�sz)ResourceTests.test_explicitAllowedMethodscCsBhd�}t�}tg�}d|_|�t|j|�}|�|t|j��dS)al
        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}.
        >rZr[rWr\N)	rArrXr^rrrr_r]r`rrr�test_implicitAllowedMethods�sz)ResourceTests.test_implicitAllowedMethodsN)
r/r0r1r2rMrOrSrYrbrcrrrrrE�s
rEc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�GetChildForRequestTestsz*
    Tests for L{getChildForRequest}.
    cCs(tg�}t�}t||�}|�||�dS)z�
        L{getChildForRequest} returns whatever resource has been reached by the
        time the request's C{postpath} is empty.
        N)rr
rr�rr#rJ�resultrrr�test_exhaustedPostPath�s
z.GetChildForRequestTests.test_exhaustedPostPathcCs2tddg�}t�}d|_t||�}|�||�dS)z�
        L{getChildForRequest} returns the first resource it encounters with a
        C{isLeaf} attribute set to C{True}.
        rFrGTN)rr
�isLeafrrrerrr�test_leafResource�s

z)GetChildForRequestTests.test_leafResourcecCs`tddg�}t�}t�}d|_|�d|�|�|t||��|�|jdg�|�|jdg�dS)z�
        As path segments from the request are traversed, they are taken from
        C{postpath} and put into C{prepath}.
        rFrGTN)	rr
rhrHrrr�prepath�postpath)rr#�rootrKrrr�test_postPathToPrePath
sz.GetChildForRequestTests.test_postPathToPrePathN)r/r0r1r2rgrirmrrrrrd�s

rdN)r2�twisted.trial.unittestr�twisted.web.errorr�twisted.web.http_headersr�twisted.web.resourcerrrrr	r
r�twisted.web.test.requesthelperrr
r4r:r<rArErdrrrr�<module>s$	C	
`

Anon7 - 2022
AnonSec Team