summaryrefslogtreecommitdiff
path: root/python/qpid
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-03-16 22:54:11 +0000
committerAlan Conway <aconway@apache.org>2007-03-16 22:54:11 +0000
commit15256f1f40f96392028f6182cecf29ff334dbe72 (patch)
tree3c443c2444ee44d42132bbf164d5ee2746beeda8 /python/qpid
parent70e06534778acde7faae8298775857e5a0c56b5a (diff)
downloadqpid-python-15256f1f40f96392028f6182cecf29ff334dbe72.tar.gz
Merged revisions 500305 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9 ........ r500305 | gsim | 2007-01-26 13:51:21 -0500 (Fri, 26 Jan 2007) | 3 lines Updates to use message class in place of basic. ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@519171 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
-rw-r--r--python/qpid/codec.py17
-rw-r--r--python/qpid/connection.py3
-rw-r--r--python/qpid/peer.py2
-rw-r--r--python/qpid/testlib.py19
4 files changed, 25 insertions, 16 deletions
diff --git a/python/qpid/codec.py b/python/qpid/codec.py
index d8617c2937..205405894a 100644
--- a/python/qpid/codec.py
+++ b/python/qpid/codec.py
@@ -157,14 +157,15 @@ class Codec:
def encode_table(self, tbl):
enc = StringIO()
codec = Codec(enc)
- for key, value in tbl.items():
- codec.encode_shortstr(key)
- if isinstance(value, basestring):
- codec.write("S")
- codec.encode_longstr(value)
- else:
- codec.write("I")
- codec.encode_long(value)
+ if tbl:
+ for key, value in tbl.items():
+ codec.encode_shortstr(key)
+ if isinstance(value, basestring):
+ codec.write("S")
+ codec.encode_longstr(value)
+ else:
+ codec.write("I")
+ codec.encode_long(value)
s = enc.getvalue()
self.encode_long(len(s))
self.write(s)
diff --git a/python/qpid/connection.py b/python/qpid/connection.py
index 75fb134760..fb1e0927f0 100644
--- a/python/qpid/connection.py
+++ b/python/qpid/connection.py
@@ -204,6 +204,9 @@ class Request(Frame):
method = Method.decode(spec, dec, size - 20)
return Request(id, mark, method)
+ def __str__(self):
+ return "[%s] Request(%s) %s" % (self.channel, self.id, self.method)
+
class Response(Frame):
type = "frame_response"
diff --git a/python/qpid/peer.py b/python/qpid/peer.py
index 66d325994b..8d5029004e 100644
--- a/python/qpid/peer.py
+++ b/python/qpid/peer.py
@@ -237,6 +237,8 @@ class Channel:
frame = Method(type, type.arguments(*args, **kwargs))
if self.reliable:
self.request(frame, self.queue_response, content)
+ if not frame.method.responses:
+ return None
try:
resp = self.responses.get()
return Message(self, resp)
diff --git a/python/qpid/testlib.py b/python/qpid/testlib.py
index b4534ab362..ecae499451 100644
--- a/python/qpid/testlib.py
+++ b/python/qpid/testlib.py
@@ -80,7 +80,7 @@ Options:
def __init__(self):
# Defaults
self.setBroker("localhost")
- self.specfile = "../specs/amqp.0-8.xml"
+ self.spec = "../specs/amqp.0-8.xml"
self.verbose = 1
self.ignore = []
@@ -203,8 +203,11 @@ class TestBase(unittest.TestCase):
def consume(self, queueName):
"""Consume from named queue returns the Queue object."""
- reply = self.channel.basic_consume(queue=queueName, no_ack=True)
- return self.client.queue(reply.consumer_tag)
+ if not "uniqueTag" in dir(self): self.uniqueTag = 1
+ else: self.uniqueTag += 1
+ consumer_tag = "tag" + str(self.uniqueTag)
+ self.channel.message_consume(queue=queueName, destination=consumer_tag, no_ack=True)
+ return self.client.queue(consumer_tag)
def assertEmpty(self, queue):
"""Assert that the queue is empty"""
@@ -218,12 +221,12 @@ class TestBase(unittest.TestCase):
Publish to exchange and assert queue.get() returns the same message.
"""
body = self.uniqueString()
- self.channel.basic_publish(exchange=exchange,
- content=Content(body, properties=properties),
- routing_key=routing_key)
+ self.channel.message_transfer(destination=exchange,
+ body=body, application_headers=properties,
+ routing_key=routing_key)
msg = queue.get(timeout=1)
- self.assertEqual(body, msg.content.body)
- if (properties): self.assertEqual(properties, msg.content.properties)
+ self.assertEqual(body, msg.body)
+ if (properties): self.assertEqual(properties, msg.application_headers)
def assertPublishConsume(self, queue="", exchange="", routing_key="", properties=None):
"""