σ
P'^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	 d  d l
 m Z d  d l m Z 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 S(   i    (   t   absolute_importN(   t   Exchanget   Queue(   t   Queuest   TaskPublisher(   t   keys(   t   AppCaset   Mockt   test_TaskProducerc           B@  sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C@  sH   |  j  j j |  j  j    } t   | _ |  Wd  QX| j j   d  S(   N(   t   appt   amqpt   TaskProducert
   connectionR   t   releaset   assert_called_with(   t   selft	   publisher(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test__exit__   s
    c         C@  sN   |  j  j j |  j  j    } d | j _ | j   d  | j _ | j   d  S(   Nt   foo(   R	   R
   R   R   t   exchanget   namet   declaret   None(   R   R   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_declare   s
    
c         C@  sQ   |  j  j j t    } t   | j j j _ | j	 d d i  d i d d 6d  S(   Ns	   tasks.addi   t   retry_policyg333333@@t	   frobulate(   i   i   (
   R	   R
   R   R   t   sett   channelR   t   clientt   declared_entitiest   publish_task(   R   t   prod(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_retry_policy   s    c         C@  sf   |  j  j j t    } t   | j j j _ | j	 d d i  d t
 d d |  j | j j j  d  S(   Ns	   tasks.addi   t   retryt   chordi{   (   i   i   (   R	   R
   R   R   R   R   R   R   R   R   t   Falset   assertFalset   ensuret
   call_count(   R   R   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_publish_no_retry$   s    c         C@  s½   |  j  j j t    } t d t d  d  |  j  j j d <t   | j j	 j
 _ t   | _ | j d d i  d t d d |  j | j j d	 d
 d  |  j | j j d	 d d  d  S(   Nt   xxxt   yyyt   zzzt
   some_queues	   tasks.addi   R!   t   queuei   R   t   routing_key(   i   i   (   R	   R
   R   R   R   R   t   queuesR   R   R   R   R   t   publishR   R#   t   assertEqualt	   call_args(   R   R   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_publish_custom_queue*   s    "c      
   C@  s’   |  j  j j t    } t   | j j j _ t   | _	 t
 j
 d d d d d d  } | j d d i  d	 t d
 d d | |  j | j	 j d d d d  d  S(   Niέ  i   i   i   i0   i.   s	   tasks.addi   R!   t	   countdowni
   t   nowi    t   etas   2013-11-26T16:48:56+00:00(   i   i   (   R	   R
   R   R   R   R   R   R   R   R/   t   datetimeR   R#   R0   R1   (   R   R   R4   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_publish_with_countdown6   s    c      
   C@  sΊ   t  j d  |  j j _ |  j j j t    } t   | j	 j
 j _ t   | _ t j d d d d d d  } | j d d i  d
 t d d d | |  j | j j d d d d  d  S(   Nix   iέ  i   i   i   i0   i.   s	   tasks.addi   R!   R3   i   R4   i    R5   s   2013-11-26T18:49:06+02:00(   i   i   (   t   pytzt   FixedOffsetR	   t   conft   CELERY_TIMEZONER
   R   R   R   R   R   R   R   R/   R6   R   R#   R0   R1   (   R   R   R4   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt(   test_publish_with_countdown_and_timezoneB   s    c         C@  s?   |  j  j j t    } |  j | j  |  j | j j  d  S(   N(   R	   R
   R   R   t
   assertTruet   event_dispatcherR$   t   enabled(   R   R   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_event_dispatcherP   s    (
   t   __name__t
   __module__R   R   R    R'   R2   R7   R<   R@   (    (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyR      s   							t   test_TaskConsumerc           B@  s   e  Z d    Z RS(   c      	   C@  s   |  j  j j d t  x } d g |  j  j _ |  j |  j  j j |  j	 t
 d g   |  j |  j  j j | d d g j	 t
 d g   Wd  QXd  S(   Nt   blocks   application/jsont   acceptt   json(   R	   t   poolt   acquiret   TrueR:   t   CELERY_ACCEPT_CONTENTR0   R
   t   TaskConsumerRE   R   (   R   t   conn(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_accept_contentX   s    (   RA   RB   RM   (    (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyRC   V   s   t   test_compat_TaskPublisherc           B@  s   e  Z d    Z d   Z RS(   c         C@  s   t  d d d |  j  } |  j | j t  |  j | j j d  |  j | j j d  t  d d d d d |  j  } |  j | j j d  d  S(   NR   R   R	   t   directt   exchange_typet   topic(   R   R	   t   assertIsInstanceR   R   R0   R   t   type(   R   t   producer(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_compat_exchange_is_stringg   s    c         C@  s8   t  d t d  d |  j  } |  j | j j d  d  S(   NR   R   R	   (   R   R   R	   R0   R   R   (   R   RT   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt    test_compat_exchange_is_Exchangep   s    (   RA   RB   RU   RV   (    (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyRN   e   s   		t   test_PublisherPoolc           B@  s   e  Z d    Z d   Z RS(   c         C@  sΜ   d  |  j j _ y t |  j d  Wn t k
 r6 n Xd  |  j j _ |  j j j } |  j	 | j
 |  j j j
  |  j | j j  | j   } | j   } | j   | j   | j   } | j   } d  S(   Nt   _pool(   R   R	   R:   t   BROKER_POOL_LIMITt   delattrt   AttributeErrorR
   t   _producer_poolt   producer_poolR0   t   limitRG   R$   t	   _resourceR,   RH   R   (   R   RG   t   r1t   r2(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_setup_nolimitw   s    

c         C@  s  d |  j  j _ y t |  j  d  Wn t k
 r6 n Xd  |  j  j _ |  j  j j } |  j	 | j
 |  j  j j
  |  j | j j  | j   } } | j   } } | j   | j   | j   } | j   } |  j | |  |  j | |  | j   | j   d  S(   Ni   RX   (   R	   R:   RY   RZ   R[   R   R
   R\   R]   R0   R^   RG   R=   R_   R,   RH   R   t   assertIs(   R   RG   t   p1R`   t   p2Ra   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt
   test_setup   s&    


(   RA   RB   Rb   Rf   (    (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyRW   u   s   	t   test_Queuesc           B@  sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C@  s5   i  |  j  j j _ |  j |  j  j j j   d  d  S(   Nt    (   R	   R
   R.   t   _consume_fromR0   t   format(   R   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_queues_format’   s    c         C@  s   |  j  t d   i   d  S(   N(   R0   R   R   (   R   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_with_defaults¦   s    c         C@  sa   t    } | j d d d d d |  j d |  |  j | d t  |  j | d j d  d  S(   NR   R   t   exR-   t   rk(   R   t   addt   assertInRR   R   R0   R-   (   R   t   q(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_add©   s
    	c         C@  sb  t  d d  d t  } | j d  |  j | d j  | j d d i d d 6|  j | d j i d d 6 t  d d d t  } | j t d	   |  j | d	 j i d d
 6 t d d i d d 6} | j |  |  j | d j i d d
 6d d 6 t  d d d d g d t  } | j t d	   |  j | d	 j i d d
 6d d d g d 6 d  S(   Nt	   ha_policyt   create_missingt   xyzt   xyxt   queue_argumentst   bars   x-foot   allR   s   x-ha-policyt   xyx2t   barit   At   Bt   Ct   nodess   x-ha-policy-params(   R   R   R#   Ro   t   assertIsNoneRw   R0   R   (   R   t   qnRq   t   qqt   q2(    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_with_ha_policy°   s$    c         C@  sO   t    } | j d d g  | j d  |  j t | j  d d d g  d  S(   NR   Rx   t   baz(   R   t   selectt
   select_addt   assertItemsEqualR   Ri   (   R   Rq   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_select_addΚ   s    	c         C@  sI   t    } | j d d g  | j d  |  j t | j  d g  d  S(   NR   Rx   (   R   R   t   deselectR   R   Ri   (   R   Rq   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_deselectΠ   s    	c         C@  s>   t  d d  } | j d  |  j | d j i d d 6 d  S(   NRs   Ry   Rx   s   x-ha-policy(   R   Ro   R0   Rw   (   R   Rq   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_with_ha_policy_compatΦ   s    c         C@  sL   t  d d  } t d |  } | j t d   |  j | d j |  d  S(   Nt   ffft   fanoutt   default_exchangeR   (   R   R   Ro   R   R0   R   (   R   Rm   Rq   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   test_add_default_exchangeΫ   s    c         C@  s>   t    } | j t d d d  |  j | d | d  d  S(   NR   t   aliast   barfoo(   R   Ro   R   Rc   (   R   Rq   (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt
   test_aliasα   s    	(   RA   RB   Rk   Rl   Rr   R   R   R   R   R   R   (    (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyRg       s   								(   t
   __future__R    R6   R8   t   kombuR   R   t   celery.app.amqpR   R   t   celery.fiveR   t   celery.tests.caseR   R   R   RC   RN   RW   Rg   (    (    (    s<   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/app/test_amqp.pyt   <module>   s   H+