Ñò
–º\Qc        
   @   s‰   d  d k  Z  d  d k l Z d  d k l Z d  d k l Z d  d k l Z d  d k l	 Z	 d  d k l
 Z
 d e  i f d	 „  ƒ  YZ d S(
   iÿÿÿÿN(   t   Request(   t   Response(   t   wsgify(   t   bytes_(   t   text_(   t   PY3t   DecoratorTestsc           B   sÅ   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s6   t  | t ƒ o t i | ƒ } n | i | ƒ } | S(   N(   t
   isinstancet   strR    t   blankt   get_response(   t   selft   appt   reqt   resp(    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   _testit
   s    c            s‡   d ‰  t  ‡  f d †  ƒ } |  i | d ƒ } |  i | i t ˆ  d ƒ ƒ |  i | i d ƒ |  i | i d ƒ |  i | i d ƒ d  S(   Ns   hey, this is a test: %sc            s   t  ˆ  |  i ƒ S(   N(   R   t   url(   R   (   t   resp_str(    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_app   s    s   /a urls   http://localhost/a%20urli-   s	   text/htmls   UTF-8(   R   R   t   assertEqualt   bodyR   t   content_lengtht   content_typet   charset(   R   R   R   (    (   R   s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify   s    c         C   s    |  i  d t t ƒ  ƒ j ƒ d  S(   Ns	   wsgify at(   t
   assertTruet   reprR   (   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_empty_repr   s    c         C   sƒ   d } t  d | f ƒ d „  ƒ } |  i | d ƒ } |  i | i | ƒ |  i | i d ƒ |  i | i d ƒ |  i | i d ƒ d  S(   Ns   hey hey my myt   argsc         S   s   | S(   N(    (   R   t   strarg(    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   !   s    s   /a urli   s	   text/htmls   UTF-8(   R   R   R   R   R   R   R   (   R   R   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_args   s    c         C   sŒ   d } t  d t d | ƒ ƒ d d „ ƒ } |  i | d ƒ } |  i | i | ƒ |  i | i d ƒ |  i | i d ƒ |  i | i d	 ƒ d  S(
   Ns   hey hey my myt   kwargsR   t    c         S   s   | S(   N(    (   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   ,   s    s   /a urli   s	   text/htmls   UTF-8(   R   t   dictR   R   R   R   R   R   (   R   R   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_kwargs*   s    c            sz   d d k  l ‰  t ‡  f d †  ƒ } |  i | d ƒ } |  i | i i d ƒ ƒ |  i | i d ƒ |  i | i	 d ƒ d  S(   Niÿÿÿÿ(   t   HTTPBadRequestc            s
   ˆ  ‚ d  S(   N(    (   R   (   R#   (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   7   s    s   /a urls   400 Bad Requests
   text/plains   UTF-8(
   t	   webob.excR#   R   R   R   R   t
   startswithR   R   R   (   R   R   R   (    (   R#   s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_raise_httpexception5   s    c         C   sj   d t  f d „  ƒ  Y} t | ƒ  ƒ } |  i | d ƒ } |  i | i d ƒ |  i | i | ƒ | j ƒ d  S(   Nt   TestAppc           B   s   e  Z d  „  Z RS(   c         S   s   d S(   Ns   nothing to see here(    (   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   __call__C   s    (   t   __name__t
   __module__R(   (    (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR'   B   s   s   /a urls   nothing to see here(   t   objectR   R   R   R   R   t   __get__(   R   R'   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_no___get__?   s
    c         C   s>   d „  } t  | ƒ } |  i | d ƒ } |  i | i d ƒ d  S(   Nc         S   s
   t  d ƒ S(   Ns	   some text(   R   (   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   K   s    s   /a urls	   some text(   R   R   R   R   (   R   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_app_returns_unicodeJ   s    	c         C   s/   t  d  d d ƒ} |  i t |  i | d ƒ d  S(   NR   i   s   /a url(   i   (   R   t   Nonet   assertRaisest	   TypeErrorR   (   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_args_no_funcQ   s    c         C   sQ   t  d „  ƒ } t ƒ  } |  i t | | d d ƒ |  i t | | d d d ƒd  S(   Nc         S   s   d S(   Ns!   What have you done for me lately?(    (   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   V   s    i   i   t   keyt   word(   R   R!   R0   R1   (   R   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_wrong_sigU   s    	c         C   s^   t  d „  ƒ } |  i | d ƒ } |  i | i d ƒ |  i | i d ƒ |  i | i d ƒ d  S(   Nc         S   s   d  S(   N(    (   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   ^   s    s   /a urlR    s	   text/htmli    (   R   R   R   R   R   R   (   R   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_none_response]   s
    c            sA   d ‰  t  ‡  f d †  ƒ } | i d ƒ } |  i | i ˆ  ƒ d  S(   Ns    What'choo talkin' about, Willis?c            s
   t  ˆ  ƒ S(   N(   R   (   R   (   R   (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   h   s    s	   /url/path(   R   t   getR   R   (   R   R   R   (    (   R   s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_getf   s    c         C   se   t  d d d d ƒ } t d „  ƒ } | i d | ƒ } |  i | i t d | d | d f ƒ ƒ d  S(   Nt   speakert   Robint   wordss   Holy test coverage, Batman!c         S   s"   t  d |  i d |  i d f ƒ S(   Ns   %s: %sR9   R;   (   R   t   POST(   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   q   s    s	   /url/paths   %s: %s(   R!   R   t   postR   R   R   (   R   t	   post_dictR   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_postn   s    	c            ss   d } t  ‡  f d †  ƒ } | i d d d d | ƒ} ˆ  i | i | ƒ ˆ  i | i d ƒ ˆ  i | i d ƒ d  S(	   Ns
   Nice body!c            s    ˆ  i  |  i d ƒ t |  i ƒ S(   Nt   PUT(   R   t   methodR   R   (   R   (   R   (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   {   s    s	   /url/pathRA   R@   R   i
   s	   text/html(   R   t   requestR   R   R   R   (   R   R   R   R   (    (   R   s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_request_methody   s    	c         C   s/   d „  } t  | ƒ } |  i | i | j ƒ d  S(   Nc         S   s
   t  d ƒ S(   Nt   whoa(   R   (   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   †   s    (   R   R   t   undecorated(   R   R   t   wrapped_test_app(    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_undecorated…   s    	c            s¦   d ‰  d t  f d „  ƒ  Y} t d | ƒ ‡  f d †  ƒ } |  i | d ƒ } |  i | i t ˆ  d ƒ ƒ |  i | i d ƒ |  i | i d	 ƒ |  i | i d
 ƒ d  S(   Ns   hey, this is a test: %st	   MyRequestc           B   s   e  Z RS(    (   R)   R*   (    (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyRH      s   t   RequestClassc            s   t  ˆ  |  i ƒ S(   N(   R   R   (   R   (   R   (    s-   /home/chrism/projects/webob/tests/test_dec.pyR      s    s   /a urls   http://localhost/a%20urli-   s	   text/htmls   UTF-8(	   R    R   R   R   R   R   R   R   R   (   R   RH   R   R   (    (   R   s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_wsgify_custom_request‹   s    c            sö   d ‰  t  i d „  ƒ } d d k l } |  i | i | j ƒ t | ƒ } |  i d | j ƒ t  ‡  f d †  ƒ } | | d d d	 d
 ƒ} |  i | d ƒ } |  i | i	 t
 ˆ  d ƒ ƒ |  i | i d ƒ |  i | i d ƒ |  i | i d ƒ d  S(   Ns   These are the vars: %sc         [   s   |  i  i | ƒ | |  ƒ S(   N(   t   urlvarst   update(   R   R   t   vars(    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt
   set_urlvar›   s    iÿÿÿÿ(   t   _MiddlewareFactoryRN   c            s   ˆ  t  |  i i ƒ  ƒ S(   N(   t   sortedRK   t   items(   R   (   R   (    s-   /home/chrism/projects/webob/tests/test_dec.pyt	   show_vars£   s    t   ai   t   bi   s   /paths   [('a', 1), ('b', 2)]s	   text/htmls   UTF-8i(   (   R   t
   middlewaret	   webob.decRO   R   t	   __class__R   R   R   R   R   R   R   R   (   R   RN   RO   t   rRR   t
   show_vars2R   (    (   R   s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_middleware™   s    c         C   s«   t  d „  ƒ } t  i d  | d d ƒ} d d k l } |  i | i | j ƒ |  i | i t	 d d ƒ ƒ | d „  ƒ } |  i | i t  j ƒ |  i d t
 | ƒ j ƒ d  S(   Nc         S   s
   t  d ƒ S(   Ns	   Say wha!?(   R   (   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   ®   s    t   somet   thingiÿÿÿÿ(   t   _UnboundMiddlewarec         [   s
   | |  ƒ S(   N(    (   R   R   t   kw(    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   middleµ   s    R   (   R   RU   R/   RV   R]   R   RW   R   R^   R!   R   (   R   R   t   unboundR]   R_   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_unbound_middleware­   s    c         C   sR   t  i d  d  ƒ } d d k l } |  i | i | j ƒ |  i | i t	 ƒ  ƒ d  S(   Niÿÿÿÿ(   R]   (
   R   RU   R/   RV   R]   R   RW   R   R^   R!   (   R   R`   R]   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_unbound_middleware_no_app»   s    c         C   s­   d t  f d „  ƒ  Y} | ƒ  } t d ƒ | d <t d ƒ | d <t i d ƒ i t | ƒ ƒ } |  i | i d ƒ |  i | i d	 ƒ |  i | i	 d
 ƒ |  i | i
 d ƒ d  S(   Nt   HostMapc           B   s   e  Z e d  „  ƒ Z RS(   c         S   s   |  | i  i d ƒ d S(   Nt   :i    (   t   hostt   split(   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR(   Ã   s    (   R)   R*   R   R(   (    (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyRc   Â   s   t   1s   example.comt   2s	   other.coms   http://example.com/s	   text/htmls   UTF-8i   (   R!   R   R    R	   R
   R   R   R   R   R   R   (   R   Rc   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_classappÁ   s    	c         C   sD   t  i d „  ƒ } | t ƒ  ƒ } |  i | t i d ƒ ƒ d ƒ d  S(   Nc         S   s   d S(   Nt   foo(    (   R   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   mwÐ   s    t   /Rj   (   R   RU   R   R   R    R	   (   R   Rk   R   (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   test_middleware_direct_callÏ   s    (   R)   R*   R   R   R   R   R"   R&   R-   R.   R2   R5   R6   R8   R?   RC   RG   RJ   RZ   Ra   Rb   Ri   Rm   (    (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyR   	   s*   						
															(   t   unittestt   webob.requestR    t   webob.responseR   RV   R   t   webob.compatR   R   R   t   TestCaseR   (    (    (    s-   /home/chrism/projects/webob/tests/test_dec.pyt   <module>   s   