summaryrefslogtreecommitdiff
path: root/python/qpid
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2006-09-27 19:50:23 +0000
committerAlan Conway <aconway@apache.org>2006-09-27 19:50:23 +0000
commitcaca23c5dc055d985fecfe188573104bc707ad9d (patch)
tree154c0bbd4c7bca70080de28116b5654491657906 /python/qpid
parent9d718c2348708b0b27ce9fb9fcbf05c4b0a997cc (diff)
downloadqpid-python-caca23c5dc055d985fecfe188573104bc707ad9d.tar.gz
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@450556 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
-rw-r--r--python/qpid/connection.py8
-rw-r--r--python/qpid/peer.py3
-rw-r--r--python/qpid/testlib.py20
3 files changed, 14 insertions, 17 deletions
diff --git a/python/qpid/connection.py b/python/qpid/connection.py
index f4d0817e60..fc6c147f2b 100644
--- a/python/qpid/connection.py
+++ b/python/qpid/connection.py
@@ -20,7 +20,7 @@ to read and write Frame objects. This could be used by a client,
server, or even a proxy implementation.
"""
-import socket, codec
+import socket, codec,logging
from cStringIO import StringIO
from spec import load, pythonize
from codec import EOF
@@ -240,8 +240,10 @@ class Header(Payload):
properties = {}
for b, f in zip(bits, klass.fields):
if b:
- properties[f.name] = c.decode(f.type)
-
+ # Note: decode returns a unicode u'' string but only
+ # plain '' strings can be used as keywords so we need to
+ # stringify the names.
+ properties[str(f.name)] = c.decode(f.type)
return Header(klass, weight, size, **properties)
def __str__(self):
diff --git a/python/qpid/peer.py b/python/qpid/peer.py
index 31d3d24f5f..3085e24247 100644
--- a/python/qpid/peer.py
+++ b/python/qpid/peer.py
@@ -146,7 +146,6 @@ class Channel:
def invoke(self, method, args, content = None):
if self.closed:
raise Closed(self.reason)
-
frame = Frame(self.id, Method(method, *args))
self.outgoing.put(frame)
@@ -181,7 +180,7 @@ class Channel:
def write_content(self, klass, content, queue):
size = content.size()
- header = Frame(self.id, Header(klass, content.weight(), size))
+ header = Frame(self.id, Header(klass, content.weight(), size, **content.properties))
queue.put(header)
for child in content.children:
self.write_content(klass, child, queue)
diff --git a/python/qpid/testlib.py b/python/qpid/testlib.py
index 0bec6a8708..92925bea20 100644
--- a/python/qpid/testlib.py
+++ b/python/qpid/testlib.py
@@ -22,7 +22,7 @@ import sys, re, unittest, os, random, logging
import qpid.client, qpid.spec
import Queue
from getopt import getopt, GetoptError
-
+from qpid.content import Content
def findmodules(root):
"""Find potential python modules under directory root"""
@@ -161,10 +161,6 @@ class TestBase(unittest.TestCase):
self.channel.channel_open()
def tearDown(self):
- # TODO aconway 2006-09-05: Wrong behaviour here, we should
- # close all open channels (checking for exceptions on the
- # channesl) then open a channel to clean up qs and exs,
- # finally close that channel.
for ch, q in self.queues:
ch.queue_delete(queue=q)
for ch, ex in self.exchanges:
@@ -186,13 +182,11 @@ class TestBase(unittest.TestCase):
arguments={}):
channel = channel or self.channel
reply = channel.exchange_declare(ticket, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
- # TODO aconway 2006-09-14: Don't add exchange on failure.
self.exchanges.append((channel,exchange))
return reply
def uniqueString(self):
"""Generate a unique string, unique for this TestBase instance"""
- # TODO aconway 2006-09-20: Not thread safe.
if not "uniqueCounter" in dir(self): self.uniqueCounter = 1;
return "Test Message " + str(self.uniqueCounter)
@@ -208,22 +202,24 @@ class TestBase(unittest.TestCase):
self.fail("Queue is not empty.")
except Queue.Empty: None # Ignore
- def assertPublishGet(self, queue, exchange="", routing_key=""):
+ def assertPublishGet(self, queue, exchange="", routing_key="", properties=None):
"""
Publish to exchange and assert queue.get() returns the same message.
"""
body = self.uniqueString()
self.channel.basic_publish(exchange=exchange,
- content=qpid.content.Content(body),
+ content=Content(body, properties=properties),
routing_key=routing_key)
- self.assertEqual(body, queue.get(timeout=2).content.body)
+ msg = queue.get(timeout=1)
+ self.assertEqual(body, msg.content.body)
+ if (properties): self.assertEqual(properties, msg.content.properties)
- def assertPublishConsume(self, queue="", exchange="", routing_key=""):
+ def assertPublishConsume(self, queue="", exchange="", routing_key="", properties=None):
"""
Publish a message and consume it, assert it comes back intact.
Return the Queue object used to consume.
"""
- self.assertPublishGet(self.consume(queue), exchange, routing_key)
+ self.assertPublishGet(self.consume(queue), exchange, routing_key, properties)
def assertChannelException(self, expectedCode, message):
self.assertEqual(message.method.klass.name, "channel")