
O'^c           @@  s\  d  d l  m Z d  d l Z d  d l Z d  d l m Z m Z d  d l m Z m Z m	 Z	 m
 Z
 d  d l m Z d  d l m Z m Z d d l m Z m Z m Z m Z m Z d d	 l m Z d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d S(   i    (   t   absolute_importN(   t   copyt   deepcopy(   t
   Connectiont   Consumert   Producert	   parse_url(   t   Resource(   t   itemst   rangei   (   t   Caset   Mockt   SkipTestt   patcht   skip_if_not_module(   t	   Transportt   test_connection_utilsc           B@  sn   e  Z d    Z d   Z d   Z d   Z e d  d    Z d   Z d   Z	 d   Z
 d	   Z d
   Z RS(   c         C@  sI   d |  _  d |  _ i d d 6d d 6d d 6d	 d
 6d d 6d d 6|  _ d  S(   Ns(   amqp://user:pass@localhost:5672/my/vhosts&   amqp://user:**@localhost:5672/my/vhostt   amqpt	   transportt   usert   useridt   passt   passwordt	   localhostt   hostnamei(  t   ports   my/vhostt   virtual_host(   t   urlt   nopasst   expected(   t   self(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   setUp   s    		c         C@  s&   t  |  j  } |  j | |  j  d  S(   N(   R   R   t   assertDictEqualR   (   R   t   result(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_parse_url   s    c         C@  s   t  |  j  } | j   } x1 |  j j   D]  \ } } |  j | | |  q+ W|  j | j   |  j  |  j | j d t  |  j  d  S(   Nt   include_password(	   R   R   t   infoR   R   t   assertEqualt   as_uriR   t   True(   R   t   connR$   t   kt   v(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_parse_generated_as_uri"   s    c         C@  s&   t  d  } |  j | j   d  d  S(   Ns*   redis+socket:///var/spool/x/y/z/redis.sock(   R   R%   R&   (   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_as_uri_when_prefix+   s    t   pymongoc         C@  s#   t  d  } |  j | j    d  S(   Ns   mongodb://localhost(   R   t
   assertTrueR&   (   R   t   x(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_as_uri_when_mongodb1   s    c         C@  s'   |  j  t   t d  j Wd  QXd  S(   Ns   bogus://localhost:7421(   t   assertRaisest   KeyErrorR   R   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_bogus_scheme6   s    c         K@  sA   | j    } x. t |  D]  \ } } |  j | | |  q Wd  S(   N(   R$   R   R%   (   R   R(   t   fieldsR$   t   fieldR   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   assert_info:   s    c         C@  s  |  j  t d  d d d d d d d d	 d
 d |  j  t d  d d d d d d d d	 d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d	 d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d d
 d |  j  t d  d d d d d d d d d
 d d  S(   Ns!   amqp://user:pass@host:10000/vhostR   R   R   R   R   t   hostR   i'  R   t   vhosts-   amqp://user%61:%61pass@ho%61st:10000/v%2fhostt   userat   apasst   hoasts   v/hosts   amqp://t   guestR   i(  t   /s
   amqp://:@/s   amqp://user@/s   amqp://user:pass@/s   amqp://hosts   amqp://:10000s   amqp:///vhosts   amqp://host/s   amqp://host/%2f(   R6   R   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_rabbitmq_example_urls?   sX    c         C@  sA   t  d   |  j t d  d d d d d d d d	 d
 d d  S(   Ns   urllib can't parse ipv6 urlss   amqp://[::1]R   R<   R   R   s   [::1]R   i(  R   R=   (   R   R6   R   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_url_IPV6   s
    c         C@  s>   t  |  j d d g } t |  } |  j | j d g  d  S(   Nt
   alternatess   amqp://host(   R   R   R   R%   t   alt(   R   R(   t   clone(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_connection_copy   s    (   t   __name__t
   __module__R   R"   R+   R,   R   R0   R3   R6   R>   R?   RC   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR      s   								E		t   test_Connectionc           B@  sg  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 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@  s   t  d d d t  |  _ d  S(   NR   i(  R   (   R   R   R(   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR      s    c         C@  s   |  j  } | j   |  j | j j  |  j | j d  | j   } |  j | j  |  j | j	   d  | j } | j
   |  j | j  |  j | j t  d  S(   Ns   localhost:5672t   event(   R(   t   connectR.   t
   connectiont	   connectedR%   R7   t   channelt   opent   drain_eventst   closet   assertFalset   assertIsInstanceR   R   (   R   R(   RK   t   _connection(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_establish_connection   s    	
	
c         C@  sz   t  d  } |  j | j d  |  j | j d d g  t  d d g  } |  j | j d  |  j | j d d g  d  S(   Ns   amqp://foo;amqp://bart   foos
   amqp://foos
   amqp://bar(   R   R%   R   t   assertListEqualRA   (   R   t   conn1t   conn2(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_multiple_urls   s    c         C@  s   t  d  } t d d  } | _ t d d  } | _ t d d  } | _ t d d  | _ t d d  } | _ | j   |  j | j	  | j
 |  | j j j
   |  j | j  |  j | j  |  j | j  d  S(   Ns	   memory://t   nameR   s   transport._collects   connection._closet   decl_entitiesRQ   (   R   R   t
   _transportt   _collectt   _closet   declared_entitiesRQ   t   collectRO   t   calledt   assert_called_witht   cleart   assertIsNonet   client(   R   RI   t   transR[   R\   t   uconn(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_collect   s    
c         C@  sX   t  d  } d  | _ t   | _ | j   | j j   t j   | j _	 | j   d  S(   Ns	   memory://(
   R   t   NoneRZ   R   R\   R^   R`   t   sockett   timeoutt   side_effect(   R   RI   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_collect_no_transport   s    	
c         @  s   t  d    t d d  }   _ t d d  }   _ t d d  } | _   f d   } | | _   j   | j |  |  j   j  d  S(   Ns	   memory://RX   s
   conn._connR   s   transport._collectc         @  s   d    _ d  S(   N(   Rg   RZ   (   R(   (   RI   (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   se   s    (	   R   R   RQ   RZ   R[   Rj   R^   R`   Rb   (   R   Re   Rd   R^   Rl   (    (   RI   s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_collect_transport_gone   s    	
c         C@  s2  t  d d  } t d   } | | _ t | _ t d  e } t d  } |  j | j d  |  j | j	  |  j | j
 d  |  j | j   j d   Wd  QXt d  O } t d d d } |  j | j d  |  j | j	  |  j | j
 d  Wd  QXWd  QXt d	  } |  j | j   j d
   d  S(   NRX   R   s"   kombu.connection.get_transport_clss   kombu.connection.parse_urls   foo+mysql://some_hostRS   s   mysql://some_hosts   foo+s   pyamqp+sqlite://some_hosts   pyamqp+(   R   R   t   return_valueR'   t   can_parse_urlR   R%   t   transport_clsRO   R_   R   R.   R&   t
   startswith(   R   R   t   gtcR   t   c(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_uri_passthrough   s"    		"c         C@  sN   t  d  < } t d t  } | j t   d  |  j | j j  Wd  QXd  S(   Ns   kombu.connection.loggerR   i   (   R   R   R   t   _default_ensure_callbackR2   R.   t   errorR_   (   R   t   loggerRs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_default_ensure_callback   s    c      
   C@  s  t  d  } t d  } | j   |  j | j  | j d } | d } t d d d d d g  } |  j | t   | d  d  |  j | t   | d  d  |  j | t   | d  d  |  j | t   | d  d  |  j | t   | d  d  |  j | t   | d  d  |  j | t   | d	  d  |  j | t   | d
  d  t	   } | j d |  | j d } | d } |  j | t   | d  d  |  j | j  Wd  QXd  S(   Ns   amqp://A;amqp://Bs    kombu.connection.retry_over_timei    i   i   i   i   i   i   i   t   errback(
   R   R   t   ensure_connectionR.   R_   t	   call_argst   iterR%   R2   R   (   R   Rs   t   rott   argst   cbt	   intervalsRy   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_ensure_connection_on_error   s*    

	
c         C@  s/   t  d t  } t | j _ |  j | j  d  S(   NR   (   R   R   t   FalseR   t   supports_heartbeatsRO   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_supports_heartbeats  s    c         C@  s/   t  d t  } t | j _ |  j | j  d  S(   NR   (   R   R   R   R   t   supports_evRO   t
   is_evented(   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_is_evented  s    c         C@  sH   t  d t  } t d d  } | j |  | j j j | j |  d  S(   NR   RX   t   loop(   R   R   t   register_with_event_loopR   R`   RI   (   R   Rs   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_register_with_event_loop  s
    c         C@  s,   t  d t  } |  j | j | j j  d  S(   NR   (   R   R   t   assertIst   managerR   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_manager  s    c         C@  s2   t  d  } |  j t |  j   | j    d  S(   Ns   amqp://example.com(   R   R%   R   R$   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt	   test_copy  s    c         C@  sB   t  d  } |  j | j  t |  } |  j | j | j  d  S(   Ns)   amqp://A.example.com;amqp://B.example.com(   R   R.   RA   R   R%   (   R   Rs   t   d(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_copy_multiples"  s    c         C@  so   t  d  } t | _ | j d  |  j | j  |  j | j d  |  j | j d  |  j | j d  d  S(   Ns
   amqp://foos   redis://example.com//3s   example.comt   rediss   /3(	   R   R'   t   _closedt   switchRO   R%   R   Rp   R   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_switch(  s    	c         C@  sc   t  d  } | j   |  j | j  |  j | j d  |  j | j d  |  j | j d  d  S(   Ns!   amqp://foo;redis://example.com//3s   example.comR   s   /3(   R   t   maybe_switch_nextRO   R   R%   R   Rp   R   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_maybe_switch_next1  s    
c         C@  sP   t  d  } | j   |  j | j  |  j | j d  |  j | j d  d  S(   Ns
   amqp://fooRS   t   librabbitmqt   pyamqpR   (   R   R   R   (   R   R   RO   R   R%   R   t   assertInRp   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_maybe_switch_next_no_cycle9  s
    
c         C@  sK   t  d t  } t   | j _ | j d  | j j j | j d d d  S(   NR   i   t   rate(   R   R   R   R   t   heartbeat_checkR`   RI   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_heartbeat_check@  s    c         C@  s<   t  d  } |  j | j d   |  j | j d   d  S(   Ns   amqp://i    i   (   R   R.   t   completes_cycle(   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_completes_cycle_no_cycleF  s    c         C@  sR   t  d  } |  j | j d   |  j | j d   |  j | j d   d  S(   Ns   amqp://a;amqp://b;amqp://ci    i   i   (   R   RO   R   R.   (   R   Rs   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_completes_cycleK  s    c         C@  sj   |  j  } | j   } |  j | |  | j   |  j | j j  | j   |  j | j  | j	   d  S(   N(
   R(   t	   __enter__R   RH   R.   RI   RJ   t   __exit__Rb   RN   (   R   R(   t   context(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test__enter____exit__Q  s    	

c         @  si   d t  f d     Y  d t f   f d     Y} t d |  } | j   | j   |  j | j  d  S(   Nt   _CustomErrorc           B@  s   e  Z RS(    (   RD   RE   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR   ]  s   t   MyTransportc           @  s    e  Z   f Z   f d    Z RS(   c         @  s     d   d  S(   NRS   (    (   R   RI   (   R   (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   close_connectionc  s    (   RD   RE   t   connection_errorsR   (    (   R   (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR   `  s   	R   (   t	   ExceptionR   R   RH   RN   R.   R   (   R   R   R(   (    (   R   s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_close_survives_connerror[  s    

c         C@  s3   |  j  } t   | _ | j   | j j j   d  S(   N(   R(   R   t   _default_channelR\   RN   R`   (   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_close_when_default_channelk  s    	
c         C@  s^   d t  f d     Y} | d  } t   | _ t   | j j _ | j   | j j j   d  S(   Nt   Connc           B@  s   e  Z e d     Z RS(   c         S@  s   t  f S(   N(   R2   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR   u  s    (   RD   RE   t   propertyR   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR   s  s   s	   memory://(   R   R   R   R2   RN   Rj   R\   R`   (   R   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt,   test_close_when_default_channel_close_raisesq  s    
c         C@  sJ   |  j  } t   } | _ | j t    | j j   |  j | j  d  S(   N(   R(   R   R   t   reviveRN   R`   Rb   (   R   R(   t   defchan(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt    test_revive_when_default_channel  s
    	c         C@  s   |  j  |  j j    d  S(   N(   R.   R(   Rz   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_ensure_connection  s    c         C@  s5   d   } |  j  j d  |  } |  j |   d  d  S(   Nc           S@  s   d S(   Nt   foobar(    (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   publish  s    R   (   R(   t   ensureRg   R%   (   R   R   t   ensured(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_ensure_success  s    	c         @  s[   d t  f d     Y    f d   } |  j j d  |  } |  j     |   Wd  QXd  S(   NR   c           B@  s   e  Z RS(    (   RD   RE   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   c           @  s     d   d  S(   Nt   bar(    (    (   R   (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s    (   R   R(   R   Rg   R1   (   R   R   R   (    (   R   s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_ensure_failure  s
    c         @  sp   d t  f d     Y    f d   }   f |  j j _ |  j j |  j |  } |  j     |   Wd  QXd  S(   Nt   _ConnectionErrorc           B@  s   e  Z RS(    (   RD   RE   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   c           @  s     d   d  S(   Ns   failed connection(    (    (   R   (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s    (   R   R(   R   R   R   R1   (   R   R   R   (    (   R   s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_ensure_connection_failure  s    c         @  s`   t      t f |  j j _   f d   } |   _ |  j j    } |   |  j   j  d  S(   Nc          @  s   d    _ t d   d  S(   NRS   (   Rg   Rj   R2   (   R~   t   kwargs(   t   myfun(    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   on_call  s    	(	   R   R2   R(   R   R   Rj   t	   autoretryR.   R_   (   R   R   t   insured(    (   R   s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_autoretry  s    		c         C@  sf   |  j  } | j d  } |  j | j | j  | j   } | j d d | } |  j | j |  d  S(   NRS   RK   (   R(   t   SimpleQueueR   RK   t   default_channel(   R   R(   t   qt   chant   q2(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_SimpleQueue  s    	c         C@  sf   |  j  } | j d  } |  j | j | j  | j   } | j d d | } |  j | j |  d  S(   NRS   RK   (   R(   t   SimpleBufferR   RK   R   (   R   R(   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_SimpleBuffer  s    	c         C@  s?   |  j  } |  j | j   t  |  j | j | j  t  d  S(   N(   R(   RP   R   R   (   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_Producer  s    	c         C@  sN   |  j  } |  j | j d g   t  |  j | j d g  d | j  t  d  S(   Nt   queuesRK   (   R(   RP   R   R   (   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_Consumer  s    	c         C@  s   |  j  t |  j   d  S(   N(   R.   t   reprR(   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test__repr__  s    c         C@  s>   t  j t  j |  j   } |  j | j   |  j j    d  S(   N(   t   picklet   loadst   dumpsR(   R    R$   (   R   R/   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test__reduce__  s    c         C@  sB   d t  f d     Y} t d |  } |  j | j t t f  d  S(   NR   c           B@  s   e  Z e e f Z RS(    (   RD   RE   R2   t
   ValueErrort   channel_errors(    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   R   (   R   R   t   assertTupleEqualR   R2   R   (   R   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_channel_errors  s    c         C@  sB   d t  f d     Y} t d |  } |  j | j t t f  d  S(   NR   c           B@  s   e  Z e e f Z RS(    (   RD   RE   R2   R   R   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   R   (   R   R   R   R   R2   R   (   R   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_connection_errors  s    ()   RD   RE   R   RR   RW   Rf   Rk   Rm   Rt   Rx   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   R   R   R   R   R   R   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyRF      sN   						
																		
																t&   test_Connection_with_transport_optionsc           B@  s.   e  Z i d  d 6e d 6Z d   Z d   Z RS(   i  t   pool_recyclert   echoc         C@  s%   t  d d d t d |  j  |  _ d  S(   NR   i(  R   t   transport_options(   R   R   R   R(   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s    c         C@  s#   |  j  } |  j | j |  j  d  S(   N(   R(   R%   R   (   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyRR     s    	(   RD   RE   R'   R   R   RR   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   	t	   xResourcec           B@  s   e  Z d    Z RS(   c         C@  s   d  S(   N(    (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   setup  s    (   RD   RE   R   (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   t   ResourceCasec           B@  sz   e  Z 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 RS(   c         C@  s   t  d   d  S(   Ns   subclass responsibility(   t   NotImplementedError(   R   t   limitt   preload(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   create_resource  s    c         C@  s6   |  j  | j j   |  |  j  t | j  |  d  S(   N(   R%   t	   _resourcet   qsizet   lent   _dirty(   R   t   Pt   availt   dirty(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   assertState  s    c         C@  s-   |  j  r) |  j t   t   Wd  QXn  d  S(   N(   t   abstractR1   R   R   (   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt
   test_setup  s    	c         C@  s   |  j  r d  S|  j d d  } |  j | d d  g  t d  D] } | j   ^ q? } |  j | d d  |  j | j   | j   Wd  QX| j   j   |  j | d d  g  | D] } | j   ^ q |  j | d d  d  S(   Ni
   i    i   i	   (	   R   R   R   R	   t   acquireR1   t   LimitExceededt   popt   release(   R   R   t   _t   chansR   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_acquire__release  s    	%c         C@  s   |  j  r d  S|  j d d  } |  j t | j j  d  t   | _ t   | j _	 |  j
 t   | j d t  Wd  QX|  j t | j j  d  d  S(   Ni
   i    t   block(   R   R   R%   R   R   t   queueR   t   preparet   IOErrorRj   R1   R   R'   (   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_acquire_prepare_raises  s    	c         C@  s3   |  j  r d  S|  j d  d  } | j   j   d  S(   Ni    (   R   R   Rg   R   R   (   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_acquire_no_limit'  s    	c         C@  sw   |  j  r d  S|  j d d  } | j   } t   | _ t   | _ | j |  | j j j |  | j j |  d  S(   Ni
   i    (	   R   R   R   R   R   t   close_resourcet   replacet   discardR`   (   R   R   t   r(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_replace_when_limit-  s    	c         C@  sz   |  j  r d  S|  j d  d  } | j   } t   | _ t   | _ | j |  |  j | j j	 j
  | j j |  d  S(   Ni    (   R   R   Rg   R   R   R   R   R   RO   R   R_   R`   (   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_replace_no_limit9  s    	c         C@  s3   |  j  s d  St   } |  j | j d  d  d  S(   Ni
   (   R   R   R%   R   (   R   R/   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_interface_prepareE  s    		c         C@  sf   |  j  r d  S|  j d d  } t   } | _ t d  | _ | j   |  j | j  | j	   d  S(   Ni
   R/   (
   R   R   R   t   collect_resourcet   AttributeErrorRj   R   R.   R   t   force_close_all(   R   R   t   cr(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt+   test_force_close_all_handles_AttributeErrorK  s    	
c         C@  sa   |  j  r d  S|  j d d  } t   | _ t   } | _ d  | _ t | j j	 _
 | j   d  S(   Ni
   (   R   R   R   R   R   Rg   t   mutext
   IndexErrorR   R   Rj   R  (   R   R   t   m(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_force_close_all_no_mutexW  s    		c         C@  s`   |  j  r d  S|  j d  d   } g  | j j (|  j | j j  | j   |  j | j j  d  S(   N(   R   R   Rg   R   R   RO   t   _add_when_emptyR.   (   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_add_when_emptyc  s    	
(   RD   RE   R'   R   R   R   R   R   R   R   R   R   R  R  R
  R  (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s   											t   test_ConnectionPoolc           B@  sM   e  Z e Z d    Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   c         C@  s   t  d d d t  j | |  S(   NR   i(  R   (   R   R   t   Pool(   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR   p  s    c         C@  sa   |  j  d d  } | j j } |  j | d j  |  j | d j  |  j | d   j  d  S(   Ni
   i   i    i   (   R   R   R   t   assertIsNotNoneRQ   Rb   (   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR   s  s
    c      	   C@  s   |  j  d d  } | j   } | j   t   | _ t   | j _ t   | _ |  j t  $ | j    t sx t	  Wd  QXWd  QX| j j
 |  d  S(   Ni   i    (   R   R   R   R   R   t   MemoryErrorRj   R1   R   t   AssertionErrorR`   (   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_acquire_raises_evaluatedz  s    
c         C@  s;   |  j  d d  } t   } t   | j _ | j |  d  S(   Ni
   i   (   R   R   R  t   _debugRj   t   release_resource(   R   R   t   R(    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_release_no__debug  s    	c         C@  s9   |  j  d  d   } |  j | j j  |  j | j  d  S(   N(   R   Rg   RO   R   R   Rb   R   (   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_setup_no_limit  s    c         C@  s;   |  j  d  d   } t d  } |  j | j |  |  d  S(   Ns	   memory://(   R   Rg   R   R   R   (   R   R   R(   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_prepare_not_callable  s    c         C@  sD   |  j  d d  } | j     \ } } |  j | | j  Wd  QXd  S(   Ni
   i    (   R   t   acquire_channelR   R   (   R   R   R(   RK   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   test_acquire_channel  s    (   RD   RE   R   R   R   R   R  R  R  R  R  (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR  m  s   						t   test_ChannelPoolc           B@  s2   e  Z e Z d    Z d   Z d   Z d   Z RS(   c         C@  s   t  d d d t  j | |  S(   NR   i(  R   (   R   R   t   ChannelPool(   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s    c         C@  sq   |  j  d d  } | j j } |  j | d j  |  j | d j  |  j t   t | d d  Wd  QXd  S(   Ni
   i   i    i   t   basic_consume(   R   R   R   R.   R  R1   R  t   getattr(   R   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR     s    c         C@  s9   |  j  d  d   } |  j | j j  |  j | j  d  S(   N(   R   Rg   RO   R   R   Rb   R   (   R   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR    s    c         C@  sD   |  j  d d  } t d  } | j } |  j | j |  |  d  S(   Ni
   i    s	   memory://(   R   R   R   R   R   (   R   R   R(   R   (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR    s    	(   RD   RE   R   R   R   R   R  R  (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyR    s
   			(   t
   __future__R    R   Rh   R   R   t   kombuR   R   R   R   t   kombu.connectionR   t
   kombu.fiveR   R	   t   caseR
   R   R   R   R   t   mocksR   R   RF   R   R   R   R  R  (    (    (    s=   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/test_connection.pyt   <module>   s    "( Yo0