ó
O'—^c           @@  sr   d  d l  m Z d  d l m Z d  d l m Z m Z m Z m Z d e	 f d „  ƒ  YZ
 d e f d „  ƒ  YZ d S(	   i    (   t   absolute_import(   t
   Connection(   t   Caset   SkipTestt   Mockt   skip_if_not_modulet   MockConnectionc           B@  s   e  Z d  „  Z RS(   c         C@  s   | |  | <d  S(   N(    (   t   selft   keyt   value(    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   __setattr__
   s    (   t   __name__t
   __module__R
   (    (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyR      s   t   test_mongodbc           B@  s   e  Z d  „  Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z	 RS(   c         @  sa   d d l  m } d | j f d „  ƒ  Y‰  d | j f ‡  f d †  ƒ  Y} t | d | | j ƒ  S(   Ni    (   t   mongodbt   _Channelc           B@  s   e  Z d  „  Z RS(   c         S@  s   t  d d ƒ |  _ d  S(   Nt   namet   client(   R   t   _client(   R   (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   _create_client   s    (   R   R   R   (    (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyR      s   t	   Transportc           @  s   e  Z e Z ˆ  Z RS(    (   R   R   R   R   t   Channel(    (   R   (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyR      s   t	   transport(   t   kombu.transportR   R   R   R   t   connect(   R   t   urlt   kwargsR   R   (    (   R   sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   _get_connection   s    t   pymongoc         C@  sU   d } |  j  | ƒ } | j d j ƒ  \ } } } |  j | d ƒ |  j | d ƒ d  S(   Ns
   mongodb://i    t   kombu_defaults   mongodb://127.0.0.1(   R   t   channelst
   _parse_urit   assertEqual(   R   R   t   ct   hostnamet   dbnamet   options(    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   test_defaults   s
    c         C@  sE   d } |  j  | ƒ } | j d j ƒ  \ } } } |  j | d ƒ d  S(   Ns   mongodb://localhosti    R   (   R   R   R   R    (   R   R   R!   R"   R#   R$   (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   test_custom_host(   s    c         C@  sE   d } |  j  | ƒ } | j d j ƒ  \ } } } |  j | d ƒ d  S(   Ns   mongodb://localhost/dbnamei    R#   (   R   R   R   R    (   R   R   R!   R"   R#   R$   (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   test_custom_database0   s    c         C@  sa   d } |  j  | d d d d ƒ} | j d j ƒ  \ } } } |  j | d ƒ |  j | d ƒ d  S(	   Ns   mongodb://localhost/dbnamet   useridt   foot   passwordt   bari    s"   mongodb://foo:bar@localhost/dbnameR#   (   R   R   R   R    (   R   R   R!   R"   R#   R$   (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   test_custom_credentials8   s
    c         C@  sF   d } |  j  | ƒ } | j d j ƒ  \ } } } |  j | d ƒ d  S(   Ns6   mongodb://localhost,localhost2:29017/dbname?fsync=truei    t   fsync(   R   R   R   t
   assertTrue(   R   R   R!   R"   R#   R$   (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   test_optionsA   s    c         C@  si  d d l  m } t d ƒ ‚ d } |  j | ƒ } | j d j } | j j } t | ƒ d k rˆ |  j	 d | k ƒ |  j
 | j d ƒ n  d	 } |  j | ƒ } | j d j } d
 } |  j ƒ  } | j d j } |  j
 | j d ƒ d } |  j | ƒ } | j d j } d } |  j | ƒ } | j d j } d } |  j | ƒ } |  j | ƒ  | j d j Wd  QXd  S(   Ni    (   t   ConfigurationErrors2   Test is functional: it actually connects to mongods*   mongodb://localhost,localhost:29017/dbnamei   t	   localhostiYq  R#   s1   mongodb://localhost:27017,localhost2:29017/dbnames/   mongodb://adminusername:adminpassword@localhostR   s   mongodb://localhosts,   mongodb://username:password@localhost/dbnames0   mongodb://nousername:nopassword@localhost/dbname(   R1   iYq  (   t   pymongo.errorsR0   R   R   R   R   t
   connectiont   nodest   lenR.   R    R   t   assertRaises(   R   R0   R   R!   R   R4   (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   test_real_connectionsJ   s6    	(
   R   R   R   R   R%   R&   R'   R,   R/   R7   (    (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyR      s   	
		N(   t
   __future__R    t   kombuR   t   kombu.tests.caseR   R   R   R   t   dictR   R   (    (    (    sD   /tmp/pip-unpacked-wheel-UAnTfW/kombu/tests/transport/test_mongodb.pyt   <module>   s   "