Skip to content

Commit

Permalink
Test default channel gets used
Browse files Browse the repository at this point in the history
  • Loading branch information
lambacck committed Oct 9, 2020
1 parent f9ae51f commit 5c08827
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions t/unit/test_pidbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,47 @@ def callback(body):
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
Expand Down

0 comments on commit 5c08827

Please sign in to comment.