diff --git a/CHANGELOG.md b/CHANGELOG.md index 40503f03057b1d8baccb697b7a60f25517ff5f20..1eb33744598e942a900407bb7919d81d597aa113 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 64142ce8c74e812ac648aa05adcd069e1140d64f..f811561263c557cf534e90ff763373bccacb20b6 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 ed9b622dad7bf4160b0082bebe8c5fb46f488b80..8b2c27acf8924ff79679d2f5f2151cefe56abb2d 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 f110e4f3157cec69ea1007a29a35df9e805c50b6..3a6ce2b4abaf1796f4a0392eaf4b15c81a5a59b6 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 dfb3f977744c3f8be99333ad9d8ed5f5e3df0638..63ea25ac334548036a514670cbed3f2904b0cc0e 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 66771afe9ca185c3362d3f878d8f289fac8d6310..585c0028ae9489d778a133a6fa971e872be18e3a 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 08aafb5d511871874db2045b47a4d60ae3ae9a34..34f3ee9c868b906c2d7a6c9bb50faffa8be24ab2 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):