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 8, 2020
1 parent f9ae51f commit 3047dc2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions t/unit/test_pidbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,40 @@ def callback(body):
de.side_effect = socket.timeout
mailbox._collect(ticket, limit=1, channel=channel)

def test_reply__collect_uses_default_channel(sef):
mailbox = pidbox.Mailbox('test_reply__collect')(self.connection)
class ConsumerCalled(Exception):
pass

def fake_Consumer(channel, *args, **kwargs):
raise ConsumerCalled(channel)

with patch('kombu.pidbox.Consumer') as Consumer:
Consumer.side_effect = fake_Consumer
try:
mailbox._collect(ticket, limit=1)
except ConsumerCalled as c:
assert c.args[0] is not None
else:
assert False, "Consumer not called"

def test__publish_uses_default_channel(sef):
mailbox = pidbox.Mailbox('test_reply__collect')(self.connection)
class QueueCalled(Exception):
pass

def queue__call__side(channel, *args, **kwargs):
raise QueueCalled(channel)

with patch.object(pidbox.Queue, '__call__') as queue__call__:
queue__call__.side_effect = queue__call__side
try:
mailbox._publish(ticket, limit=1)
except QueueCalled as c:
assert c.args[0] is not None
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 3047dc2

Please sign in to comment.