Ñò
ïLc           @€  sS  d  d k  l Z d  d k Z d  d k l Z d  d k Z e i i e ƒ Z d  d k l	 Z	 d  d k
 l Z d  d k l Z d  d k l Z l Z l Z e ƒ  d „  Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d S(   iÿÿÿÿ(   t   with_statementN(   t   StringIO(   t   RequestParser(   t   HttpConnection(   t   Resource(   t   HOSTt   PORTt   run_server_testc         C€  ss   t  ƒ  } t |  ƒ i i ƒ  } zJ | ~ } x6 | D]. } | i d ƒ i d d ƒ } | i | ƒ q3 W| SWd  QXd  S(   Ns   
s   \r\ns   
(   R   t   opent   __exit__t	   __enter__t   rstript   replacet   write(   t   fnamet   buft   _[1]t   handlet   line(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   data_source   s    	# t   requestc           B€  s   e  Z d  „  Z d „  Z RS(   c         C€  s   t  i i t d | ƒ |  _ d  S(   Nt   requests(   t   ost   patht   joint   dirnameR   (   t   selft   name(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   __init__    s    c         €  s"   ‡  ‡ f d †  } ˆ i  | _  | S(   Nc          €  s&   t  ˆ  i ƒ }  ˆ |  t |  ƒ ƒ d  S(   N(   R   R   R   (   t   src(   R   t   func(    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   run$   s    (   t	   func_name(   R   R   R   (    (   R   R   s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   __call__#   s    (   t   __name__t
   __module__R   R!   (    (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR      s   	t
   FakeSocketc           B€  sM   e  Z d  „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d d „ Z	 RS(	   c         C€  sQ   t  i ƒ  |  _ | o7 |  i i | i ƒ  ƒ |  i i ƒ  |  i i d ƒ n d  S(   Ni    (   t   tempfilet   TemporaryFilet   tmpR   t   getvaluet   flusht   seek(   R   t   data(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR   -   s
    c         C€  s   |  i  i ƒ  S(   N(   R'   t   fileno(   R   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR,   4   s    c         C€  s
   |  i  i S(   N(   R'   t   len(   R   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR-   7   s    c         C€  s   |  i  i ƒ  S(   N(   R'   t   read(   R   t   length(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   recv:   s    c         C€  sI   |  i  i | ƒ } t | ƒ } x$ t | ƒ D] \ } } | | | <q+ W| S(   N(   R'   R.   R-   t	   enumerate(   R   R   R/   t
   tmp_buffert   vt   it   c(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt	   recv_into=   s     c         C€  s!   |  i  i | ƒ |  i  i ƒ  d  S(   N(   R'   R   R)   (   R   R+   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   sendD   s    i    c         C€  s   |  i  i | | ƒ d  S(   N(   R'   R*   (   R   t   offsett   whence(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR*   H   s    N(
   R"   R#   R   R,   R-   t   NoneR0   R6   R7   R*   (    (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR$   +   s   					t   client_requestc           B€  s   e  Z e d  „ Z d „  Z RS(   c         C€  sP   | |  _  | i d ƒ p | i d ƒ o | |  _ n d t t | f |  _ d  S(   Ns   http://s   https://s   http://%s:%s%s(   t   poolt
   startswitht   urlR   R   (   R   R   R<   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR   M   s    	 c         €  s"   ‡ ‡  f d †  } ˆ i  | _  | S(   Nc          €  sF   ˆ i  o t ƒ  }  n d  }  t d d  d d ƒ } ˆ  ˆ i | ƒ d  S(   Nt   pool_instancet   timeoutg      à?(   R<   t   ConnectionPoolR:   R   R>   (   R?   t   cli(   R   R   (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR   U   s
    
(   R    (   R   R   R   (    (   R   R   s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR!   T   s    (   R"   R#   t   FalseR   R!   (    (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR;   K   s   t   resource_requestc           B€  s   e  Z d d  „ Z d „  Z RS(   c         C€  s1   | d  j	 o | |  _ n d t t f |  _ d  S(   Ns   http://%s:%s(   R:   R>   R   R   (   R   R>   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR   a   s    c         €  s"   ‡  ‡ f d †  } ˆ i  | _  | S(   Nc          €  s   t  ˆ  i ƒ }  ˆ |  ƒ d  S(   N(   R   R>   (   t   res(   R   R   (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR   h   s    (   R    (   R   R   R   (    (   R   R   s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyR!   g   s    N(   R"   R#   R:   R   R!   (    (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyRD   _   s   c         C€  s%   |  | j p t  d |  | f ‚ d  S(   Ns   %r != %r(   t   AssertionError(   t   at   b(    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   eqo   s    c         C€  s%   |  | j p t  d |  | f ‚ d  S(   Ns   %r == %r(   RF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   ner   s    c         C€  s%   |  | j  p t  d |  | f ‚ d  S(   Ns   %r >= %r(   RF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   ltu   s    c         C€  s%   |  | j p t  d |  | f ‚ d  S(   Ns   %r <= %r(   RF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   gtx   s    c         C€  s%   |  | j p t  d |  | f ‚ d  S(   Ns   %r is not in %r(   RF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   isin{   s    c         C€  s%   |  | j p t  d |  | f ‚ d  S(   Ns   %r is in %r(   RF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   isnotin~   s    c         C€  s(   t  |  | ƒ p t d |  | f ‚ d  S(   Ns   %r has no attribute %r(   t   hasattrRF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   has   s    c         C€  s)   t  |  | ƒ p t d |  | f ‚ d  S(   Ns   %r has an attribute %r(   RO   RF   (   RG   RH   (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   hasnot„   s    c         O€  sV   y | | | Ž  Wn |  j
 o n- Xt  | d d ƒ } t d | |  i f ƒ ‚ d  S(   NR    s   <builtin_function>s   Function %s did not raise %s(   t   getattrRF   R"   (   t   exctypeR   t   argst   kwargsR    (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   raises‡   s    (!   t
   __future__R    R   R   R%   R   R   t   __file__t   restkit.http.parserR   t   restkit.clientR   t   restkit.resourceR   t   _server_testR   R   R   R   t   objectR   R$   R;   RD   RI   RJ   RK   RL   RM   RN   RP   RQ   RV   (    (    (    s9   /Users/benoitc/Work/couchdbkit_env/src/restkit/tests/t.pyt   <module>   s.   	 								