From 99db8839de65d2940a9c76646cf5930deec635c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Wed, 4 Dec 2024 11:05:12 +0100 Subject: [PATCH] 2.1.2 test release --- CHANGELOG.md | 3 ++- coolamqp/__init__.py | 2 +- coolamqp/argumentify.py | 12 +++++------- coolamqp/clustering/cluster.py | 5 +---- docker-compose.yml | 2 +- docs/whatsnew.rst | 2 ++ tests/test_clustering/test_things.py | 5 ++++- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40503f0..1eb3374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ v2.1.2 ====== * extra_properties passed to Cluster might now be a dict -* basically all arguments can be passed as dicts +* basically all arguments and argument_binds can be passed as dicts +* removed a bogus warning v2.1.1 ====== diff --git a/coolamqp/__init__.py b/coolamqp/__init__.py index 64142ce..f811561 100644 --- a/coolamqp/__init__.py +++ b/coolamqp/__init__.py @@ -1 +1 @@ -__version__ = '2.1.2a1' +__version__ = '2.1.2' diff --git a/coolamqp/argumentify.py b/coolamqp/argumentify.py index ed9b622..8b2c27a 100644 --- a/coolamqp/argumentify.py +++ b/coolamqp/argumentify.py @@ -1,5 +1,3 @@ -import warnings - import six from coolamqp.framing.field_table import get_type_for @@ -17,27 +15,27 @@ def tobytes(q): def toutf8(q): if isinstance(q, memoryview): - q = q.tobytes().decode('utf-8') + q = q.tobytes() return q.decode('utf-8') if isinstance(q, six.binary_type) else q def argumentify(arguments): if arguments is None: return [] + args = [] if isinstance(arguments, dict): for key, value in arguments.items(): key = tobytes(key) args.append((key, (value, get_type_for(value)))) - return (args, 'F') + return args, 'F' elif len(arguments[0]) == 2: for key, value in arguments: key = tobytes(key) args.append((key, (value, get_type_for(value)))) - return (args, 'F') + return args, 'F' elif isinstance(arguments, (list, tuple)): for value in arguments: args.append((value, get_type_for(value))) - return (args, 'A') - warnings.warn('Unnecessary call to argumentify, see issue #11 for details', UserWarning) + return args, 'A' return args diff --git a/coolamqp/clustering/cluster.py b/coolamqp/clustering/cluster.py index f110e4f..3a6ce2b 100644 --- a/coolamqp/clustering/cluster.py +++ b/coolamqp/clustering/cluster.py @@ -78,10 +78,7 @@ class Cluster(object): raise RuntimeError('tracer given, but opentracing is not installed!') if isinstance(extra_properties, dict): - extra_props = [] - for key, value in extra_properties.items(): - extra_props.append((tobytes(key), argumentify(value))) - extra_properties = extra_props + extra_properties = argumentify(extra_properties)[0] self.started = False # type: bool self.tracer = tracer diff --git a/docker-compose.yml b/docker-compose.yml index dfb3f97..63ea25a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: amqp: image: rabbitmq:4.0-management unittest: - command: nose2 -vv + command: coverage run --append -m nose2 -F -vv build: context: . dockerfile: tests/Dockerfile diff --git a/docs/whatsnew.rst b/docs/whatsnew.rst index 66771af..585c002 100644 --- a/docs/whatsnew.rst +++ b/docs/whatsnew.rst @@ -7,6 +7,8 @@ pick their names for themselves. It also forbids some combinations of Queue arguments, and makes the default values more palatable, so for example a naked :class:`coolamqp.objects.Queue` will be anonymous, non-durable, exclusive and auto-delete. +Also, any arguments marked as arguments or arguments_bind may accept a dictionary safely. + Cluster.publish --------------- diff --git a/tests/test_clustering/test_things.py b/tests/test_clustering/test_things.py index 08aafb5..34f3ee9 100644 --- a/tests/test_clustering/test_things.py +++ b/tests/test_clustering/test_things.py @@ -14,8 +14,11 @@ from coolamqp.exceptions import ConnectionDead from coolamqp.objects import NodeDefinition, Queue, Exchange NODE = NodeDefinition(os.environ.get('AMQP_HOST', '127.0.0.1'), 'guest', 'guest', heartbeat=20) -logging.basicConfig(level=logging.DEBUG) logging.getLogger('coolamqp').setLevel(logging.DEBUG) +logging.basicConfig(level=logging.DEBUG, + format='[%(asctime)s] p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%Y-%m-%d:%H:%M:%S',) + class TestConnecting(unittest.TestCase): -- GitLab