diff options
author | Alan Conway <aconway@apache.org> | 2006-09-27 19:50:23 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2006-09-27 19:50:23 +0000 |
commit | caca23c5dc055d985fecfe188573104bc707ad9d (patch) | |
tree | 154c0bbd4c7bca70080de28116b5654491657906 /python/qpid/testlib.py | |
parent | 9d718c2348708b0b27ce9fb9fcbf05c4b0a997cc (diff) | |
download | qpid-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/testlib.py')
-rw-r--r-- | python/qpid/testlib.py | 20 |
1 files changed, 8 insertions, 12 deletions
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") |