î
¾?T´  ã               @   sˆ   d  d l  Z d  d l j j Z d  d l m Z d d l m	 Z	 Gd d „  d e ƒ Z
 d d „  Z d	 d
 „  Z d d „  Z d d „  Z d S)é    N)Ú
Controlleré   )Úurlopenc               @   s4   e  Z d  Z d d „  Z d d „  Z d d „  Z d S)ÚRootc             C   s   d S)NzHello World!© )Úselfr   r   ú6/home/prologic/work/circuits/tests/web/test_headers.pyÚindex
   s    z
Root.indexc             C   s   d |  j  j d <d S)Nz
text/plainzContent-TypezHello World!)ÚresponseÚheaders)r   r   r   r   Úfoo   s    zRoot.fooc             C   s   d S)NÚ r   )r   r   r   r   Úempty   s    z
Root.emptyN)Ú__name__Ú
__module__Ú__qualname__r	   r   r   r   r   r   r   r      s   r   c             C   s   t  |  j j j ƒ } | j ƒ  } d } | | k } | sÎ t j d | f d | | f ƒ i t j | ƒ d 6d t j	 ƒ  k s‹ t j
 | ƒ rš t j | ƒ n d d 6} d i | d	 6} t t j | ƒ ƒ ‚ n  t } } | j d
 } d } | | k } | s’t j d | f d | | f ƒ i t j | ƒ d 6d t j	 ƒ  k sOt j
 | ƒ r^t j | ƒ n d d 6} d i | d	 6} t t j | ƒ ƒ ‚ n  t } } d  S)Ns   Hello World!ú==ú%(py0)s == %(py3)sÚpy3ÚsÚpy0r   úassert %(py5)sÚpy5zContent-Typeztext/html; charset=utf-8Úcontent_type)r   )r   r   )r   )r   r   )r   ÚserverÚhttpÚbaseÚreadÚ
@pytest_arÚ_call_reprcompareÚ	_safereprÚ@py_builtinsÚlocalsÚ_should_repr_global_nameÚAssertionErrorÚ_format_explanationÚNoner   )ÚwebappÚfr   Ú@py_assert2Ú@py_assert1Ú@py_format4Ú@py_format6r   r   r   r   Útest_default   s"       l   
   l   r-   c             C   s©  t  d j |  j j j ƒ ƒ } | j ƒ  } d } | | k } | s× t j d | f d | | f ƒ i t j | ƒ d 6d t	 j
 ƒ  k s” t j | ƒ r£ t j | ƒ n d d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  t } } | j d } d } | | k } | s›t j d | f d | | f ƒ i t j | ƒ d 6d t	 j
 ƒ  k sXt j | ƒ rgt j | ƒ n d d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  t } } d  S)Nz	{0:s}/foos   Hello World!r   ú%(py0)s == %(py3)sr   r   r   r   úassert %(py5)sr   zContent-Typez
text/plainr   )r   )r.   r/   )r   )r.   r/   )r   Úformatr   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r   )r'   r(   r   r)   r*   r+   r,   r   r   r   r   Útest_explicit   s"       l   
   l   r1   c             C   s©  t  d j |  j j j ƒ ƒ } | j ƒ  } d } | | k } | s× t j d | f d | | f ƒ i t j | ƒ d 6d t	 j
 ƒ  k s” t j | ƒ r£ t j | ƒ n d d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  t } } | j d } d } | | k } | s›t j d | f d | | f ƒ i t j | ƒ d 6d t	 j
 ƒ  k sXt j | ƒ rgt j | ƒ n d d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  t } } d  S)Nz{0:s}/static/test.csss	   body { }
r   ú%(py0)s == %(py3)sr   r   r   r   úassert %(py5)sr   zContent-Typeztext/cssr   )r   )r2   r3   )r   )r2   r3   )r   r0   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r   )r'   r(   r   r)   r*   r+   r,   r   r   r   r   Útest_static'   s"       l   
   l   r4   c             C   s   t  d j |  j j j ƒ ƒ } | j ƒ  } d } | | k } | s× t j d | f d | | f ƒ i t j | ƒ d 6d t	 j
 ƒ  k s” t j | ƒ r£ t j | ƒ n d d 6} d i | d
 6} t t j | ƒ ƒ ‚ n  t } } | j d } t | ƒ } d } | | k }	 |	 sît j d |	 f d | | f ƒ i d t	 j
 ƒ  k sTt j | ƒ rct j | ƒ n d d 6t j | ƒ d 6t j | ƒ d 6d t	 j
 ƒ  k s«t j t ƒ rºt j t ƒ n d d 6}
 d i |
 d 6} t t j | ƒ ƒ ‚ n  t } }	 } d  S)Nz{0:s}/emptyó    r   ú%(py0)s == %(py3)sr   r   r   r   úassert %(py5)sr   zContent-Lengthr   ú0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sÚcontent_lengthÚpy1Úpy6Úintúassert %(py8)sÚpy8)r   )r6   r7   )r   )r8   r=   )r   r0   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r   r<   )r'   r(   r   r)   r*   r+   r,   r9   Ú@py_assert5Ú@py_assert4Ú@py_format7Ú@py_format9r   r   r   Ú
test_empty0   s$       l   
    ³   rC   )Úbuiltinsr!   Ú_pytest.assertion.rewriteÚ	assertionÚrewriter   Úcircuits.webr   Úhelpersr   r   r-   r1   r4   rC   r   r   r   r   Ú<module>   s     			