[Python-modules-commits] [kombu] 01/08: Import kombu_3.0.27.orig.tar.gz

Michael Fladischer fladi at moszumanska.debian.org
Mon Oct 12 10:45:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

fladi pushed a commit to annotated tag debian/3.0.27-1
in repository kombu.

commit b8b31aa3b85e7eee198c73f2db20fd8cf714a484
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date:   Sun Oct 11 12:31:41 2015 +0200

    Import kombu_3.0.27.orig.tar.gz
---
 AUTHORS                                           |   2 +
 Changelog                                         |  51 +++-
 PKG-INFO                                          |   4 +-
 README.rst                                        |   2 +-
 docs/_ext/applyxrefs.py                           |   2 -
 docs/changelog.rst                                |  51 +++-
 docs/conf.py                                      |   4 +-
 docs/introduction.rst                             |   2 +-
 docs/userguide/serialization.rst                  |   4 +-
 examples/experimental/async_consume.py            |   2 +-
 extra/release/bump_version.py                     |   5 +-
 funtests/tests/test_SLMQ.py                       |   4 +-
 funtests/tests/test_SQS.py                        |   5 +-
 funtests/tests/test_qpid.py                       |   3 +-
 kombu.egg-info/PKG-INFO                           |   4 +-
 kombu.egg-info/requires.txt                       |   2 +-
 kombu/__init__.py                                 |  10 +-
 kombu/abstract.py                                 |   7 +-
 kombu/clocks.py                                   |  12 +-
 kombu/five.py                                     |   2 +-
 kombu/messaging.py                                |   6 +-
 kombu/mixins.py                                   |  14 +-
 kombu/serialization.py                            |   4 +-
 kombu/tests/test_messaging.py                     |  10 +
 kombu/tests/transport/test_SQS.py                 |  22 +-
 kombu/tests/transport/test_mongodb.py             |  20 +-
 kombu/tests/transport/test_qpid.py                | 182 ++++++++------
 kombu/tests/transport/test_redis.py               |  14 +-
 kombu/tests/utils/test_utils.py                   |  10 +-
 kombu/transport/amqplib.py                        |  33 ++-
 kombu/transport/base.py                           |   4 +-
 kombu/transport/django/__init__.py                |  18 +-
 kombu/transport/django/migrations/0001_initial.py | 114 ++++-----
 kombu/transport/qpid.py                           | 280 +++++++++++++---------
 kombu/transport/redis.py                          |  21 +-
 kombu/utils/amq_manager.py                        |   4 +-
 kombu/utils/eventio.py                            |  23 +-
 requirements/default.txt                          |   2 +-
 setup.py                                          |  16 +-
 39 files changed, 618 insertions(+), 357 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 387d7f4..81b70f1 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -39,6 +39,7 @@ Dmitry Malinovsky <dmalinovsky at thumbtack.net>
 Dustin J. Mitchell <dustin at mozilla.com>
 Ephemera <obliviscence+git at gmail.com>
 Eric Reynolds <ereynolds at opendns.com>
+Eric Wang <eric1990 at gmail.com>
 Fabrice Rabaute <fabrice at expa.com>
 Felix Schwarz <felix.schwarz at oss.schwarz.eu>
 Fernando Jorge Mota <f.j.mota13 at gmail.com>
@@ -56,6 +57,7 @@ James Turk <james.p.turk at gmail.com>
 Jason Cater <jason at ncsfulfillment.com>
 Jasper Bryant-Greene <jbg at rf.net.nz>
 Jeff Balogh <me at jeffbalogh.org>
+Jeff Ortel <jortel at redhat.com>
 Jesper Thomschütz <jesper at jespersaur.com>
 Jesse Dhillon <jesse at deva0.net>
 John Shuping <jshuping at acm.org>
diff --git a/Changelog b/Changelog
index 9f063fa..afa6f32 100644
--- a/Changelog
+++ b/Changelog
@@ -4,7 +4,56 @@
  Change history
 ================
 
-.. _version-3.0.26"
+.. _version-3.0.27:
+
+3.0.27
+======
+:release-date: 2015-10-09 3:10 PM PDT
+:release-by: Ask Solem
+
+- Now depends on :mod:`amqp` 1.4.7.
+
+- Fixed libSystem import error on some OS X 10.11 (El Capitan) installations.
+
+    Fix contributed by Eric Wang.
+
+- Now compatible with Django 1.9.
+
+- Django: Adds migrations for the database transport.
+
+- Redis: Now depends on py-redis 2.10.0 or later (Issue #468).
+
+- QPid: Can now connect as localhost (Issue #519).
+
+    Fix contributed by Brian Bouterse.
+
+- QPid: Adds support for ``login_method`` (Issue #502, Issue #499).
+
+    Contributed by Brian Bouterse.
+
+- QPid: Now reads SASL mechanism from broker string (Issue #498).
+
+    Fix contributed by Brian Bouterse.
+
+- QPid: Monitor thread now properly terminated on session close (Issue #485).
+
+    Fix contributed by Brian Bouterse.
+
+- QPid: Fixed file descriptor leak (Issue #476).
+
+    Fix contributed by Jeff Ortel
+
+- Docs: Fixed wrong order for entrypoint arguments (Issue #473).
+
+- ConsumerMixin: Connection error logs now include traceback (Issue #480).
+
+- BaseTransport now raises RecoverableConnectionError when disconnected
+  (Issue #507).
+
+- Consumer: Adds ``tag_prefix`` option to modify how consumer tags are
+  generated (Issue #509).
+
+.. _version-3.0.26:
 
 3.0.26
 ======
diff --git a/PKG-INFO b/PKG-INFO
index cce0c3d..bb1f69b 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: kombu
-Version: 3.0.26
+Version: 3.0.27
 Summary: Messaging library for Python
 Home-page: http://kombu.readthedocs.org
 Author: Ask Solem
@@ -12,7 +12,7 @@ Description: .. _kombu-index:
          kombu - Messaging library for Python
         ========================================
         
-        :Version: 3.0.26
+        :Version: 3.0.27
         
         `Kombu` is a messaging library for Python.
         
diff --git a/README.rst b/README.rst
index 97fde73..acab4b6 100644
--- a/README.rst
+++ b/README.rst
@@ -4,7 +4,7 @@
  kombu - Messaging library for Python
 ========================================
 
-:Version: 3.0.26
+:Version: 3.0.27
 
 `Kombu` is a messaging library for Python.
 
diff --git a/docs/_ext/applyxrefs.py b/docs/_ext/applyxrefs.py
index 93222a3..8ad57e8 100644
--- a/docs/_ext/applyxrefs.py
+++ b/docs/_ext/applyxrefs.py
@@ -47,7 +47,6 @@ def has_target(fn):
         if not readok:
             return (True, None)
 
-    #print fn, len(lines)
     if len(lines) < 1:
         print("Not touching empty file %s." % fn)
         return (True, None)
@@ -69,7 +68,6 @@ def main(argv=None):
             files.extend([(dirpath, f) for f in filenames])
     files.sort()
     files = [os.path.join(p, fn) for p, fn in files if fn.endswith('.txt')]
-    #print files
 
     for fn in files:
         if fn in DONT_TOUCH:
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 9f063fa..afa6f32 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -4,7 +4,56 @@
  Change history
 ================
 
-.. _version-3.0.26"
+.. _version-3.0.27:
+
+3.0.27
+======
+:release-date: 2015-10-09 3:10 PM PDT
+:release-by: Ask Solem
+
+- Now depends on :mod:`amqp` 1.4.7.
+
+- Fixed libSystem import error on some OS X 10.11 (El Capitan) installations.
+
+    Fix contributed by Eric Wang.
+
+- Now compatible with Django 1.9.
+
+- Django: Adds migrations for the database transport.
+
+- Redis: Now depends on py-redis 2.10.0 or later (Issue #468).
+
+- QPid: Can now connect as localhost (Issue #519).
+
+    Fix contributed by Brian Bouterse.
+
+- QPid: Adds support for ``login_method`` (Issue #502, Issue #499).
+
+    Contributed by Brian Bouterse.
+
+- QPid: Now reads SASL mechanism from broker string (Issue #498).
+
+    Fix contributed by Brian Bouterse.
+
+- QPid: Monitor thread now properly terminated on session close (Issue #485).
+
+    Fix contributed by Brian Bouterse.
+
+- QPid: Fixed file descriptor leak (Issue #476).
+
+    Fix contributed by Jeff Ortel
+
+- Docs: Fixed wrong order for entrypoint arguments (Issue #473).
+
+- ConsumerMixin: Connection error logs now include traceback (Issue #480).
+
+- BaseTransport now raises RecoverableConnectionError when disconnected
+  (Issue #507).
+
+- Consumer: Adds ``tag_prefix`` option to modify how consumer tags are
+  generated (Issue #509).
+
+.. _version-3.0.26:
 
 3.0.26
 ======
diff --git a/docs/conf.py b/docs/conf.py
index a61b832..7904861 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -7,9 +7,9 @@ import os
 # is relative to the documentation root, use os.path.abspath to make it
 # absolute, like shown here.
 sys.path.append(os.path.join(os.pardir, "tests"))
-import kombu
+import kombu  # noqa
 
-from django.conf import settings
+from django.conf import settings  # noqa
 if not settings.configured:
     settings.configure()
 
diff --git a/docs/introduction.rst b/docs/introduction.rst
index 97fde73..acab4b6 100644
--- a/docs/introduction.rst
+++ b/docs/introduction.rst
@@ -4,7 +4,7 @@
  kombu - Messaging library for Python
 ========================================
 
-:Version: 3.0.26
+:Version: 3.0.27
 
 `Kombu` is a messaging library for Python.
 
diff --git a/docs/userguide/serialization.rst b/docs/userguide/serialization.rst
index 37169a8..b85fed7 100644
--- a/docs/userguide/serialization.rst
+++ b/docs/userguide/serialization.rst
@@ -131,7 +131,7 @@ entry-points.
 
 The entry-point must provide the name of the serializer along
 with the path to a tuple providing the rest of the args:
-``decoder_function, encoder_function, content_type, content_encoding``.
+``encoder_function, decoder_function, content_type, content_encoding``.
 
 An example entrypoint could be:
 
@@ -152,7 +152,7 @@ Then the module ``my_module.serializer`` would look like:
 
 .. code-block:: python
 
-    register_args = (my_decoder, my_encoder, 'application/x-mimetype', 'utf-8')
+    register_args = (my_encoder, my_decoder, 'application/x-mimetype', 'utf-8')
 
 
 When this package is installed the new 'my_serializer' serializer will be
diff --git a/examples/experimental/async_consume.py b/examples/experimental/async_consume.py
index 1127128..1a15c7a 100644
--- a/examples/experimental/async_consume.py
+++ b/examples/experimental/async_consume.py
@@ -2,12 +2,12 @@
 
 from kombu import Connection, Exchange, Queue, Producer, Consumer
 from kombu.async import Hub
-from threading import Event
 
 hub = Hub()
 exchange = Exchange('asynt')
 queue = Queue('asynt', exchange, 'asynt')
 
+
 def send_message(conn):
     producer = Producer(conn)
     producer.publish('hello world', exchange=exchange, routing_key='asynt')
diff --git a/extra/release/bump_version.py b/extra/release/bump_version.py
index be122ec..921f9bc 100755
--- a/extra/release/bump_version.py
+++ b/extra/release/bump_version.py
@@ -10,10 +10,13 @@ import subprocess
 from contextlib import contextmanager
 from tempfile import NamedTemporaryFile
 
-rq = lambda s: s.strip("\"'")
 str_t = str if sys.version_info[0] >= 3 else basestring
 
 
+def rq(s):
+    return s.strip("\"'")
+
+
 def cmd(*args):
     return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
 
diff --git a/funtests/tests/test_SLMQ.py b/funtests/tests/test_SLMQ.py
index d8fd47a..fe1cc9e 100644
--- a/funtests/tests/test_SLMQ.py
+++ b/funtests/tests/test_SLMQ.py
@@ -10,8 +10,8 @@ class test_SLMQ(transport.TransportCase):
     event_loop_max = 100
     message_size_limit = 4192
     reliable_purge = False
-    suppress_disorder_warning = True  # does not guarantee FIFO order,
-                                      # even in simple cases.
+    # does not guarantee FIFO order, even in simple cases.
+    suppress_disorder_warning = True
 
     def before_connect(self):
         if "SLMQ_ACCOUNT" not in os.environ:
diff --git a/funtests/tests/test_SQS.py b/funtests/tests/test_SQS.py
index de08efb..8abba07 100644
--- a/funtests/tests/test_SQS.py
+++ b/funtests/tests/test_SQS.py
@@ -11,8 +11,9 @@ class test_SQS(transport.TransportCase):
     event_loop_max = 100
     message_size_limit = 4192  # SQS max body size / 2.
     reliable_purge = False
-    suppress_disorder_warning = True  # does not guarantee FIFO order,
-                                      # even in simple cases.
+
+    # does not guarantee FIFO order, even in simple cases.
+    suppress_disorder_warning = True
 
     def before_connect(self):
         try:
diff --git a/funtests/tests/test_qpid.py b/funtests/tests/test_qpid.py
index f4e8a8e..adf42d2 100644
--- a/funtests/tests/test_qpid.py
+++ b/funtests/tests/test_qpid.py
@@ -2,6 +2,7 @@ from nose import SkipTest
 
 from funtests import transport
 
+
 class test_qpid(transport.TransportCase):
     transport = 'qpid'
     prefix = 'qpid'
@@ -10,4 +11,4 @@ class test_qpid(transport.TransportCase):
         try:
             import qpid.messaging  # noqa
         except ImportError:
-            raise SkipTest('qpid.messaging not installed')
\ No newline at end of file
+            raise SkipTest('qpid.messaging not installed')
diff --git a/kombu.egg-info/PKG-INFO b/kombu.egg-info/PKG-INFO
index cce0c3d..bb1f69b 100644
--- a/kombu.egg-info/PKG-INFO
+++ b/kombu.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: kombu
-Version: 3.0.26
+Version: 3.0.27
 Summary: Messaging library for Python
 Home-page: http://kombu.readthedocs.org
 Author: Ask Solem
@@ -12,7 +12,7 @@ Description: .. _kombu-index:
          kombu - Messaging library for Python
         ========================================
         
-        :Version: 3.0.26
+        :Version: 3.0.27
         
         `Kombu` is a messaging library for Python.
         
diff --git a/kombu.egg-info/requires.txt b/kombu.egg-info/requires.txt
index 7f36296..b2f1e7a 100644
--- a/kombu.egg-info/requires.txt
+++ b/kombu.egg-info/requires.txt
@@ -1,5 +1,5 @@
 anyjson>=0.3.3
-amqp>=1.4.6,<2.0
+amqp>=1.4.7,<2.0
 
 [sqlalchemy]
 sqlalchemy
diff --git a/kombu/__init__.py b/kombu/__init__.py
index 5d92394..d73f6c3 100644
--- a/kombu/__init__.py
+++ b/kombu/__init__.py
@@ -1,13 +1,17 @@
 """Messaging library for Python"""
 from __future__ import absolute_import
 
+import os
+import sys
+
 from collections import namedtuple
+from types import ModuleType
 
 version_info_t = namedtuple(
     'version_info_t', ('major', 'minor', 'micro', 'releaselevel', 'serial'),
 )
 
-VERSION = version_info_t(3, 0, 26, '', '')
+VERSION = version_info_t(3, 0, 27, '', '')
 __version__ = '{0.major}.{0.minor}.{0.micro}{0.releaselevel}'.format(VERSION)
 __author__ = 'Ask Solem'
 __contact__ = 'ask at celeryproject.org'
@@ -16,9 +20,6 @@ __docformat__ = 'restructuredtext en'
 
 # -eof meta-
 
-import os
-import sys
-
 if sys.version_info < (2, 6):  # pragma: no cover
     raise Exception('Kombu 3.1 requires Python versions 2.6 or later.')
 
@@ -41,7 +42,6 @@ if STATICA_HACK:  # pragma: no cover
 
 # Lazy loading.
 # - See werkzeug/__init__.py for the rationale behind this.
-from types import ModuleType
 
 all_by_module = {
     'kombu.connection':    ['Connection', 'BrokerConnection'],
diff --git a/kombu/abstract.py b/kombu/abstract.py
index 6dff848..e55f0c5 100644
--- a/kombu/abstract.py
+++ b/kombu/abstract.py
@@ -20,17 +20,20 @@ def unpickle_dict(cls, kwargs):
     return cls(**kwargs)
 
 
+def _any(v):
+    return v
+
+
 class Object(object):
     """Common base class supporting automatic kwargs->attributes handling,
     and cloning."""
     attrs = ()
 
     def __init__(self, *args, **kwargs):
-        any = lambda v: v
         for name, type_ in self.attrs:
             value = kwargs.get(name)
             if value is not None:
-                setattr(self, name, (type_ or any)(value))
+                setattr(self, name, (type_ or _any)(value))
             else:
                 try:
                     getattr(self, name)
diff --git a/kombu/clocks.py b/kombu/clocks.py
index a986238..e6de0c4 100644
--- a/kombu/clocks.py
+++ b/kombu/clocks.py
@@ -52,9 +52,15 @@ class timetuple(tuple):
             return self[1] < other[1]  # ... or use timestamp
         except IndexError:
             return NotImplemented
-    __gt__ = lambda self, other: other < self
-    __le__ = lambda self, other: not other < self
-    __ge__ = lambda self, other: not self < other
+
+    def __gt__(self, other):
+        return other < self
+
+    def __le__(self, other):
+        return not other < self
+
+    def __ge__(self, other):
+        return not self < other
 
     clock = property(itemgetter(0))
     timestamp = property(itemgetter(1))
diff --git a/kombu/five.py b/kombu/five.py
index b7116fa..06cbd91 100644
--- a/kombu/five.py
+++ b/kombu/five.py
@@ -49,7 +49,7 @@ if sys.version_info < (3, 3):
 
     if SYSTEM == 'Darwin' and has_ctypes:
         from ctypes.util import find_library
-        libSystem = ctypes.CDLL('libSystem.dylib')
+        libSystem = ctypes.CDLL(find_library('libSystem.dylib'))
         CoreServices = ctypes.CDLL(find_library('CoreServices'),
                                    use_errno=True)
         mach_absolute_time = libSystem.mach_absolute_time
diff --git a/kombu/messaging.py b/kombu/messaging.py
index fbc6b92..baa9ef9 100644
--- a/kombu/messaging.py
+++ b/kombu/messaging.py
@@ -345,13 +345,14 @@ class Consumer(object):
 
     def __init__(self, channel, queues=None, no_ack=None, auto_declare=None,
                  callbacks=None, on_decode_error=None, on_message=None,
-                 accept=None):
+                 accept=None, tag_prefix=None):
         self.channel = channel
         self.queues = self.queues or [] if queues is None else queues
         self.no_ack = self.no_ack if no_ack is None else no_ack
         self.callbacks = (self.callbacks or [] if callbacks is None
                           else callbacks)
         self.on_message = on_message
+        self.tag_prefix = tag_prefix
         self._active_tags = {}
         if auto_declare is not None:
             self.auto_declare = auto_declare
@@ -572,7 +573,8 @@ class Consumer(object):
         return tag
 
     def _add_tag(self, queue, consumer_tag=None):
-        tag = consumer_tag or str(next(self._tags))
+        tag = consumer_tag or '{0}{1}'.format(
+            self.tag_prefix, next(self._tags))
         self._active_tags[queue.name] = tag
         return tag
 
diff --git a/kombu/mixins.py b/kombu/mixins.py
index 081ae58..4793e8f 100644
--- a/kombu/mixins.py
+++ b/kombu/mixins.py
@@ -28,6 +28,14 @@ __all__ = ['ConsumerMixin']
 logger = get_logger(__name__)
 debug, info, warn, error = logger.debug, logger.info, logger.warn, logger.error
 
+W_CONN_LOST = """\
+Connection to broker lost, trying to re-establish connection...\
+"""
+
+W_CONN_ERROR = """\
+Broker connection error, trying again in %s seconds: %r.\
+"""
+
 
 class ConsumerMixin(object):
     """Convenience mixin for implementing consumer programs.
@@ -153,8 +161,7 @@ class ConsumerMixin(object):
         message.ack()
 
     def on_connection_error(self, exc, interval):
-        warn('Broker connection error: %r. '
-             'Trying again in %s seconds.', exc, interval)
+        warn(W_CONN_ERROR, interval, exc, exc_info=1)
 
     @contextmanager
     def extra_context(self, connection, channel):
@@ -172,8 +179,7 @@ class ConsumerMixin(object):
                 else:
                     sleep(restart_limit.expected_time(_tokens))
             except errors:
-                warn('Connection to broker lost. '
-                     'Trying to re-establish the connection...')
+                warn(W_CONN_LOST, exc_info=1)
 
     @contextmanager
     def consumer_context(self, **kwargs):
diff --git a/kombu/serialization.py b/kombu/serialization.py
index 738fc37..9958139 100644
--- a/kombu/serialization.py
+++ b/kombu/serialization.py
@@ -365,7 +365,9 @@ def register_msgpack():
     try:
         try:
             from msgpack import packb as pack, unpackb
-            unpack = lambda s: unpackb(s, encoding='utf-8')
+
+            def unpack(s, encoding='utf-8'):
+                return unpackb(s, encoding=encoding)
         except ImportError:
             # msgpack < 0.2.0 and Python 2.5
             from msgpack import packs as pack, unpacks as unpack  # noqa
diff --git a/kombu/tests/test_messaging.py b/kombu/tests/test_messaging.py
index a64ebd5..6c6df3a 100644
--- a/kombu/tests/test_messaging.py
+++ b/kombu/tests/test_messaging.py
@@ -381,6 +381,16 @@ class test_Consumer(Case):
         consumer.cancel_by_queue(queue.name)
         self.assertFalse(consumer._active_tags)
 
+    def test_consumer_tag_prefix(self):
+        channel = self.connection.channel()
+        queue = Queue('qname', self.exchange, 'rkey')
+        consumer = Consumer(channel, queue, tag_prefix='consumer_')
+        consumer.consume()
+
+        self.assertTrue(
+            consumer._active_tags[queue.name].startswith('consumer_'),
+        )
+
     def test_manual_declare(self):
         channel = self.connection.channel()
         queue = Queue('qname', self.exchange, 'rkey')
diff --git a/kombu/tests/transport/test_SQS.py b/kombu/tests/transport/test_SQS.py
index e4efb53..69704d5 100644
--- a/kombu/tests/transport/test_SQS.py
+++ b/kombu/tests/transport/test_SQS.py
@@ -161,7 +161,7 @@ class test_Channel(Case):
         message = 'my test message'
         self.producer.publish(message)
         results = self.channel._get_from_sqs(self.queue_name)
-        self.assertEquals(len(results), 1)
+        self.assertEqual(len(results), 1)
 
         # Now test getting many messages
         for i in xrange(3):
@@ -169,7 +169,7 @@ class test_Channel(Case):
             self.producer.publish(message)
 
         results = self.channel._get_from_sqs(self.queue_name, count=3)
-        self.assertEquals(len(results), 3)
+        self.assertEqual(len(results), 3)
 
     def test_get_with_empty_list(self):
         with self.assertRaises(five.Empty):
@@ -197,7 +197,7 @@ class test_Channel(Case):
         )
 
         # We got the same number of payloads back, right?
-        self.assertEquals(len(payloads), message_count)
+        self.assertEqual(len(payloads), message_count)
 
         # Make sure they're payload-style objects
         for p in payloads:
@@ -207,7 +207,7 @@ class test_Channel(Case):
         message = 'my test message'
         self.producer.publish(message)
         results = self.queue(self.channel).get().payload
-        self.assertEquals(message, results)
+        self.assertEqual(message, results)
 
     def test_puts_and_gets(self):
         for i in xrange(3):
@@ -215,15 +215,15 @@ class test_Channel(Case):
             self.producer.publish(message)
 
         for i in xrange(3):
-            self.assertEquals('message: %s' % i,
-                              self.queue(self.channel).get().payload)
+            self.assertEqual('message: %s' % i,
+                             self.queue(self.channel).get().payload)
 
     def test_put_and_get_bulk(self):
         # With QoS.prefetch_count = 0
         message = 'my test message'
         self.producer.publish(message)
         results = self.channel._get_bulk(self.queue_name)
-        self.assertEquals(1, len(results))
+        self.assertEqual(1, len(results))
 
     def test_puts_and_get_bulk(self):
         # Generate 8 messages
@@ -240,11 +240,11 @@ class test_Channel(Case):
         # Count how many messages are retrieved the first time. Should
         # be 5 (message_count).
         results = self.channel._get_bulk(self.queue_name)
-        self.assertEquals(5, len(results))
+        self.assertEqual(5, len(results))
 
         # Now, do the get again, the number of messages returned should be 3.
         results = self.channel._get_bulk(self.queue_name)
-        self.assertEquals(3, len(results))
+        self.assertEqual(3, len(results))
 
     def test_drain_events_with_empty_list(self):
         def mock_can_consume():
@@ -270,7 +270,7 @@ class test_Channel(Case):
             self.channel.drain_events()
 
         # How many times was the SQSConnectionMock get_message method called?
-        self.assertEquals(
+        self.assertEqual(
             expected_get_message_count,
             self.channel._queue_cache[self.queue_name]._get_message_calls)
 
@@ -291,6 +291,6 @@ class test_Channel(Case):
             self.channel.drain_events()
 
         # How many times was the SQSConnectionMock get_message method called?
-        self.assertEquals(
+        self.assertEqual(
             expected_get_message_count,
             self.channel._queue_cache[self.queue_name]._get_message_calls)
diff --git a/kombu/tests/transport/test_mongodb.py b/kombu/tests/transport/test_mongodb.py
index b4d10fc..c8d71de 100644
--- a/kombu/tests/transport/test_mongodb.py
+++ b/kombu/tests/transport/test_mongodb.py
@@ -34,8 +34,8 @@ class test_mongodb(Case):
         c = self._get_connection(url)
         hostname, dbname, options = c.channels[0]._parse_uri()
 
-        self.assertEquals(dbname, 'kombu_default')
-        self.assertEquals(hostname, 'mongodb://127.0.0.1')
+        self.assertEqual(dbname, 'kombu_default')
+        self.assertEqual(hostname, 'mongodb://127.0.0.1')
 
     @skip_if_not_module('pymongo')
     def test_custom_host(self):
@@ -43,7 +43,7 @@ class test_mongodb(Case):
         c = self._get_connection(url)
         hostname, dbname, options = c.channels[0]._parse_uri()
 
-        self.assertEquals(dbname, 'kombu_default')
+        self.assertEqual(dbname, 'kombu_default')
 
     @skip_if_not_module('pymongo')
     def test_custom_database(self):
@@ -51,7 +51,7 @@ class test_mongodb(Case):
         c = self._get_connection(url)
         hostname, dbname, options = c.channels[0]._parse_uri()
 
-        self.assertEquals(dbname, 'dbname')
+        self.assertEqual(dbname, 'dbname')
 
     @skip_if_not_module('pymongo')
     def test_custom_credentials(self):
@@ -59,17 +59,17 @@ class test_mongodb(Case):
         c = self._get_connection(url, userid='foo', password='bar')
         hostname, dbname, options = c.channels[0]._parse_uri()
 
-        self.assertEquals(hostname, 'mongodb://foo:bar@localhost/dbname')
-        self.assertEquals(dbname, 'dbname')
+        self.assertEqual(hostname, 'mongodb://foo:bar@localhost/dbname')
+        self.assertEqual(dbname, 'dbname')
 
     @skip_if_not_module('pymongo')
     def test_options(self):
-        url = 'mongodb://localhost,localhost2:29017/dbname?safe=true'
+        url = 'mongodb://localhost,localhost2:29017/dbname?fsync=true'
         c = self._get_connection(url)
 
         hostname, dbname, options = c.channels[0]._parse_uri()
 
-        self.assertEqual(options['safe'], True)
+        self.assertTrue(options['fsync'])
 
     @skip_if_not_module('pymongo')
     def test_real_connections(self):
@@ -87,7 +87,7 @@ class test_mongodb(Case):
         # server instead of a repl / mongoss.
         if len(nodes) == 2:
             self.assertTrue(('localhost', 29017) in nodes)
-            self.assertEquals(client.name, 'dbname')
+            self.assertEqual(client.name, 'dbname')
 
         url = 'mongodb://localhost:27017,localhost2:29017/dbname'
         c = self._get_connection(url)
@@ -97,7 +97,7 @@ class test_mongodb(Case):
         url = 'mongodb://adminusername:adminpassword@localhost'
         c = self._get_connection()
         client = c.channels[0].client
-        self.assertEquals(client.name, 'kombu_default')
+        self.assertEqual(client.name, 'kombu_default')
 
         # Lets make sure that using admin db doesn't break anything
         # when no user is specified
diff --git a/kombu/tests/transport/test_qpid.py b/kombu/tests/transport/test_qpid.py
index 7ace243..38a8f51 100644
--- a/kombu/tests/transport/test_qpid.py
+++ b/kombu/tests/transport/test_qpid.py
@@ -283,11 +283,9 @@ class ConnectionTestBase(Case):
         self.connection_options = {
             'host': 'localhost',
             'port': 5672,
-            'username': 'guest',
-            'password': '',
             'transport': 'tcp',
             'timeout': 10,
-            'sasl_mechanisms': 'ANONYMOUS PLAIN',
+            'sasl_mechanisms': 'ANONYMOUS',
         }
         self.mock_qpid_connection = mock_qpid.messaging.Connection
         self.conn = Connection(**self.connection_options)
@@ -301,7 +299,6 @@ class TestConnectionInit(ExtraAssertionsMixin, ConnectionTestBase):
         # ensure that only one mech was passed into connection. The other
         # options should all be passed through as-is
         modified_conn_opts = self.connection_options
-        modified_conn_opts['sasl_mechanisms'] = 'PLAIN'
         self.assertDictEqual(
             modified_conn_opts, self.conn.connection_options,
         )
@@ -312,7 +309,6 @@ class TestConnectionInit(ExtraAssertionsMixin, ConnectionTestBase):
 
     def test_establishes_connection(self):
         modified_conn_opts = self.connection_options
-        modified_conn_opts['sasl_mechanisms'] = 'PLAIN'
         self.mock_qpid_connection.establish.assert_called_with(
             **modified_conn_opts
         )
@@ -1155,7 +1151,16 @@ class TestChannel(ExtraAssertionsMixin, Case):
         self.mock_broker.addQueue.side_effect = unique_exception
         with self.assertRaises(unique_exception.__class__):
             self.my_channel.queue_declare(mock_queue)
-        self.mock_broker.addQueue.assert_called_once()
+        self.mock_broker.addQueue.assert_called_once_with(
+            mock_queue,
+            options={
+                'exclusive': False,
+                'durable': False,
+                'qpid.policy_type': 'ring',
+                'passive': False,
+                'arguments': None,
+                'auto-delete': True
+            })
 
     def test_exchange_declare_raises_exception_and_silenced(self):
         """Create exchange where an exception is raised and then silenced"""
@@ -1308,10 +1313,10 @@ class TestChannel(ExtraAssertionsMixin, Case):
         self.my_channel.basic_publish(
             mock_message, mock_exchange, mock_routing_key,
         )
-        mock_encode_body.assert_called_once(
+        mock_encode_body.assert_called_once_with(
             mock_original_body, mock_body_encoding,
         )
-        mock_buffer.assert_called_once(mock_encode_body)
+        mock_buffer.assert_called_once_with(mock_encoded_body)
         self.assertIs(mock_message['body'], mock_encoded_buffered_body)
         self.assertIs(
             mock_message['properties']['body_encoding'], mock_body_encoding,
@@ -1444,6 +1449,19 @@ class TestReceiversMonitorRun(ReceiversMonitorTestBase):
             self.monitor.run()
         mock_monitor_receivers.assert_called_once_with()
 
+    @patch(QPID_MODULE + '.SessionClosed', new=QpidException)
+    @patch.object(ReceiversMonitor, 'monitor_receivers')
+    @patch(QPID_MODULE + '.time.sleep')
+    def test_receivers_monitor_run_exits_on_session_closed(
+            self, mock_sleep, mock_monitor_receivers):
+        mock_monitor_receivers.side_effect = QpidException()
+        try:
+            self.monitor.run()
+        except Exception:
+            self.fail('No exception should be raised here')
+        mock_monitor_receivers.assert_called_once_with()
+        mock_sleep.has_calls([])
+
     @patch.object(Transport, 'connection_errors', new=(BreakOutException, ))
     @patch.object(ReceiversMonitor, 'monitor_receivers')
     @patch(QPID_MODULE + '.time.sleep')
@@ -1567,8 +1585,9 @@ class TestTransportInit(Case):
         self.mock_verify_runtime_environment.assert_called_once_with()
 
     def test_transport___init___calls_parent_class___init__(self):
-        Transport(Mock())
-        self.mock_base_Transport__init__.assert_caled_once_with()
+        m = Mock()
+        Transport(m)
+        self.mock_base_Transport__init__.assert_called_once_with(m)
 
     def test_transport___init___calls_os_pipe(self):
         Transport(Mock())
@@ -1674,6 +1693,9 @@ class TestTransportEstablishConnection(Case):
         self.client.connect_timeout = 4
         self.client.ssl = False
         self.client.transport_options = {}
+        self.client.userid = None
+        self.client.password = None
+        self.client.login_method = None
         self.transport = Transport(self.client)
         self.mock_conn = Mock()
         self.transport.Connection = self.mock_conn
@@ -1685,28 +1707,15 @@ class TestTransportEstablishConnection(Case):
         self.patcher.stop()
 
     def test_transport_establish_conn_new_option_overwrites_default(self):
-        new_userid_string = 'new-userid'
-        self.client.userid = new_userid_string
-        self.transport.establish_connection()
-        self.mock_conn.assert_called_once_with(
-            username=new_userid_string,
-            sasl_mechanisms='PLAIN ANONYMOUS',
-            host='127.0.0.1',
-            timeout=4,
-            password='',
-            port=5672,
-            transport='tcp',
-        )
-
-    def test_transport_establish_conn_sasl_mech_sorting(self):
-        self.client.sasl_mechanisms = 'MECH1 MECH2'
+        self.client.userid = 'new-userid'
+        self.client.password = 'new-password'
         self.transport.establish_connection()
         self.mock_conn.assert_called_once_with(
-            username='guest',
-            sasl_mechanisms='MECH1 MECH2',
-            host='127.0.0.1',
+            username=self.client.userid,
+            password=self.client.password,
+            sasl_mechanisms='PLAIN',
+            host='localhost',
             timeout=4,
-            password='',
             port=5672,
             transport='tcp',
         )
@@ -1714,11 +1723,9 @@ class TestTransportEstablishConnection(Case):
     def test_transport_establish_conn_empty_client_is_default(self):
         self.transport.establish_connection()
         self.mock_conn.assert_called_once_with(
-            username='guest',
-            sasl_mechanisms='PLAIN ANONYMOUS',
-            host='127.0.0.1',
+            sasl_mechanisms='ANONYMOUS',
+            host='localhost',
             timeout=4,
-            password='',
             port=5672,
             transport='tcp',
         )
@@ -1728,12 +1735,10 @@ class TestTransportEstablishConnection(Case):
         self.client.transport_options['new_param'] = new_param_value
         self.transport.establish_connection()
         self.mock_conn.assert_called_once_with(
-            username='guest',
-            sasl_mechanisms='PLAIN ANONYMOUS',
-            host='127.0.0.1',
+            sasl_mechanisms='ANONYMOUS',
+            host='localhost',
             timeout=4,
             new_param=new_param_value,
-            password='',
             port=5672,
             transport='tcp',
         )
@@ -1742,24 +1747,55 @@ class TestTransportEstablishConnection(Case):
         self.client.hostname = 'localhost'
         self.transport.establish_connection()
         self.mock_conn.assert_called_once_with(
-            username='guest',
-            sasl_mechanisms='PLAIN ANONYMOUS',
-            host='127.0.0.1',
+            sasl_mechanisms='ANONYMOUS',
+            host='localhost',
             timeout=4,
-            password='',
             port=5672,
             transport='tcp',
         )
 
-    def test_transport_establish_conn_set_password(self):
+    def test_transport_password_no_userid_raises_exception(self):
         self.client.password = 'somepass'
+        self.assertRaises(Exception, self.transport.establish_connection)
+
+    def test_transport_userid_no_password_raises_exception(self):
+        self.client.userid = 'someusername'
+        self.assertRaises(Exception, self.transport.establish_connection)
+
+    def test_transport_overrides_sasl_mech_from_login_method(self):
+        self.client.login_method = 'EXTERNAL'
+        self.transport.establish_connection()
+        self.mock_conn.assert_called_once_with(
+            sasl_mechanisms='EXTERNAL',
+            host='localhost',
+            timeout=4,
+            port=5672,
+            transport='tcp',
+        )
+
+    def test_transport_overrides_sasl_mech_has_username(self):
+        self.client.userid = 'new-userid'
+        self.client.login_method = 'EXTERNAL'
         self.transport.establish_connection()
         self.mock_conn.assert_called_once_with(
-            username='guest',
-            sasl_mechanisms='PLAIN ANONYMOUS',
-            host='127.0.0.1',
... 1069 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/kombu.git



More information about the Python-modules-commits mailing list