Ë
    oj@  ã                   óŠ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZ ddlmZ d	ed
efd„Z G d„ de«      Zy)z
Test L{twisted.web.pages}
é    )Úcast)ÚSynchronousTestCase)ÚHeaders)ÚIRequest)Ú	errorPageÚ	forbiddenÚnotFound)Ú	IResource)ÚDummyRequestÚresourceÚreturnc                 ó\   — t        dg«      }| j                  t        t        |«      «       |S )z¬
    Render a response using the given resource.

    @param resource: The resource to use to handle the request.

    @returns: The request that the resource handled,
    ó    )r   Úrenderr   r   )r   Úrequests     ú=/usr/lib/python3/dist-packages/twisted/web/test/test_pages.pyÚ_renderr      s*   € ô ˜C˜5Ó!€Gð ‡O�O”Dœ 7Ó+Ô,Ø€Nr   c                   óL   — e Zd ZdZdZdedededdfd„Zdd„Z	dd	„Z
dd
„Zdd„Zy)ÚErrorPageTestszu
    Test L{twisted.web.pages._ErrorPage} and its public aliases L{errorPage},
    L{notFound} and L{forbidden}.
    Nr   ÚcodeÚbodyr   c                 ó  — | j                  |j                  |«       | j                  |j                  t        ddgi«      «       | j                  dj	                  |j
                  «      j                  d«      |j                  d«      «       y )Ns   content-types   text/html; charset=utf-8r   zlatin-1)ÚassertEqualÚresponseCodeÚresponseHeadersr   ÚjoinÚwrittenÚdecode)Úselfr   r   r   s       r   ÚassertResponsezErrorPageTests.assertResponse*   sy   € Ø×Ñ˜×-Ñ-¨tÔ4Ø×ÑØ×#Ñ#Ü�_Ð'BÐ&CÐDÓEô	
ð 	×Ñð �H‰H�W—_‘_Ó%×,Ñ,¨YÓ7Ø�K‰K˜	Ó"õ		
r   c           	      óR   — | j                  t        t        ddd«      «      dd«       y)zS
        The I{brief} and I{detail} parameters are HTML-escaped on render.
        i�  zA & Bz<script>alert('oops!')sŠ   <!DOCTYPE html>
<html><head><title>400 - A &amp; B</title></head><body><h1>A &amp; B</h1><p>&lt;script&gt;alert('oops!')</p></body></html>N)r    r   r   ©r   s    r   Útest_escapesHTMLzErrorPageTests.test_escapesHTML7   s,   € ð 	×ÑÜ”I˜c 7Ð,DÓEÓFØð&õ			
r   c                 ó’   — t        ddd«      }| j                  |j                  dt        t        t        dg«      «      «      |«       y)z„
        The C{getChild} method of the resource returned by L{errorPage} returns
        the L{_ErrorPage} it is called on.
        é”  ÚfooÚbars   namer   N)r   ÚassertIsÚgetChildr   r   r   )r   Úpages     r   Útest_getChildzErrorPageTests.test_getChildF   s=   € ô
 ˜˜e UÓ+ˆØ�‰Ø�M‰M˜'¤4¬´,À¸uÓ2EÓ#FÓGØõ	
r   c                 óL   — | j                  t        t        «       «      dd«       y)zq
        The default arguments to L{twisted.web.pages.notFound} produce
        a reasonable error page.
        r%   s¡   <!DOCTYPE html>
<html><head><title>404 - No Such Resource</title></head><body><h1>No Such Resource</h1><p>Sorry. No luck finding that resource.</p></body></html>N)r    r   r	   r"   s    r   Útest_notFoundDefaultsz$ErrorPageTests.test_notFoundDefaultsQ   s$   € ð
 	×ÑÜ”H“JÓØð"õ	
	
r   c                 óL   — | j                  t        t        «       «      dd«       y)zr
        The default arguments to L{twisted.web.pages.forbidden} produce
        a reasonable error page.
        i“  s�   <!DOCTYPE html>
<html><head><title>403 - Forbidden Resource</title></head><body><h1>Forbidden Resource</h1><p>Sorry, resource is forbidden.</p></body></html>N)r    r   r   r"   s    r   Útest_forbiddenDefaultsz%ErrorPageTests.test_forbiddenDefaultsb   s$   € ð
 	×ÑÜ”I“KÓ Øð"õ	
	
r   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚmaxDiffr   ÚintÚbytesr    r#   r+   r-   r/   © r   r   r   r   "   sC   „ ñð
 €Gð
 lð 
¸#ð 
ÀUð 
Ètó 
ó
ó	
ó
ô"
r   r   N)r3   Útypingr   Útwisted.trial.unittestr   Útwisted.web.http_headersr   Útwisted.web.iwebr   Útwisted.web.pagesr   r   r	   Útwisted.web.resourcer
   Útwisted.web.test.requesthelperr   r   r   r7   r   r   ú<module>r?      sF   ðñõ å 6Ý ,Ý %ß <Ñ <Ý *Ý 7ð�ið  Ló ô O
Ð(õ O
r   