summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lambacher <clambacher@heroku.com>2020-10-07 11:52:18 -0400
committerAsif Saif Uddin <auvipy@gmail.com>2020-10-13 10:38:43 +0600
commitb79146d8a1f822c486f6ab0df8bf36b5c53cf70d (patch)
treebd508ba3cfba106dab7fc4163c408920e8800de4
parent3704a1c61e802957ed64f61e25106347d5bba856 (diff)
downloadkombu-b79146d8a1f822c486f6ab0df8bf36b5c53cf70d.tar.gz
Test default channel gets used
-rw-r--r--t/unit/test_pidbox.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/unit/test_pidbox.py b/t/unit/test_pidbox.py
index 5b14ffff..dc2467cb 100644
--- a/t/unit/test_pidbox.py
+++ b/t/unit/test_pidbox.py
@@ -95,6 +95,47 @@ class test_Mailbox:
de.side_effect = socket.timeout
mailbox._collect(ticket, limit=1, channel=channel)
+ def test_reply__collect_uses_default_channel(self):
+ class ConsumerCalled(Exception):
+ pass
+
+ def fake_Consumer(channel, *args, **kwargs):
+ raise ConsumerCalled(channel)
+
+ ticket = uuid()
+ with patch('kombu.pidbox.Consumer') as Consumer:
+ mailbox = pidbox.Mailbox('test_reply__collect')(self.connection)
+ assert mailbox.connection.default_channel is not None
+ Consumer.side_effect = fake_Consumer
+ try:
+ mailbox._collect(ticket, limit=1)
+ except ConsumerCalled as c:
+ assert c.args[0] is not None
+ except Exception:
+ raise
+ else:
+ assert False, "Consumer not called"
+
+ def test__publish_uses_default_channel(self):
+ class QueueCalled(Exception):
+ pass
+
+ def queue__call__side(channel, *args, **kwargs):
+ raise QueueCalled(channel)
+
+ ticket = uuid()
+ with patch.object(pidbox.Queue, '__call__') as queue__call__:
+ mailbox = pidbox.Mailbox('test_reply__collect')(self.connection)
+ queue__call__.side_effect = queue__call__side
+ try:
+ mailbox._publish(ticket, {}, reply_ticket=ticket)
+ except QueueCalled as c:
+ assert c.args[0] is not None
+ except Exception:
+ raise
+ else:
+ assert False, "Queue not called"
+
def test_constructor(self):
assert self.mailbox.connection is None
assert self.mailbox.exchange.name