def test_is_open(self): url = 'test-url' sender = Sender(url) # closed self.assertFalse(sender.is_open()) # open sender.channel = Mock() self.assertTrue(sender.is_open())
def test_is_open(self): url = 'test-url' sender = Sender(url) # closed self.assertFalse(sender.is_open()) # open sender.channel = Mock() self.assertTrue(sender.is_open())
def test_close(self): connection = Mock() channel = Mock() # test sender = Sender(None) sender.connection = connection sender.channel = channel sender.is_open = Mock(return_value=True) sender.close() # validation channel.close.assert_called_once_with() self.assertFalse(connection.close.called)
def test_send(self, build): ttl = 10 address = 'jeff' content = 'hello' # test sender = Sender('') sender.durable = 18 sender.channel = Mock() sender.send(address, content, ttl=ttl) # validation build.assert_called_once_with(content, ttl, sender.durable) sender.channel.basic_publish.assert_called_once_with( build.return_value, mandatory=True, exchange='', routing_key='jeff')
def test_send(self, build): ttl = 10 address = 'jeff' content = 'hello' # test sender = Sender('') sender.durable = 18 sender.channel = Mock() sender.send(address, content, ttl=ttl) # validation build.assert_called_once_with(content, ttl, sender.durable) sender.channel.basic_publish.assert_called_once_with( build.return_value, mandatory=True, exchange='', routing_key='jeff')
def test_send_exchange(self, build): ttl = 10 exchange = 'amq.direct' key = 'bar' address = '/'.join((exchange, key)) content = 'hello' # test sender = Sender('') sender.durable = False sender.channel = Mock() sender.send(address, content, ttl=ttl) # validation build.assert_called_once_with(content, ttl, sender.durable) sender.channel.basic_publish.assert_called_once_with( build.return_value, mandatory=True, exchange=exchange, routing_key=key)
def test_send_exchange(self, build): ttl = 10 exchange = 'amq.direct' key = 'bar' address = '/'.join((exchange, key)) content = 'hello' # test sender = Sender('') sender.durable = False sender.channel = Mock() sender.send(address, content, ttl=ttl) # validation build.assert_called_once_with(content, ttl, sender.durable) sender.channel.basic_publish.assert_called_once_with( build.return_value, mandatory=True, exchange=exchange, routing_key=key)