예제 #1
0
 def test_bind_sends_exchange_unbind_obj(self, rpc):
     rpc.return_value = specification.Exchange.UnbindOk
     obj = exchange.Exchange(self.channel, 'foo')
     val = mock.Mock()
     val.name = 'bar'
     obj.unbind(val, 'b')
     self.assertIsInstance(rpc.mock_calls[0][1][0],
                           specification.Exchange.Unbind)
예제 #2
0
def delete_exchange(uri=None, exchange_name=None):
    """Delete an exchange from RabbitMQ. This should only be used for one-off
    operations.

    :param str uri: AMQP URI to connect to
    :param str exchange_name: The exchange name to delete
    :raises: :py:class:`ValueError`
    :raises: :py:class:`rabbitpy.RemoteClosedException`

    """
    _validate_name(exchange_name, 'exchange')
    with SimpleChannel(uri) as channel:
        exchange.Exchange(channel, exchange_name).delete()
예제 #3
0
파일: simple.py 프로젝트: jtillman/rabbitpy
def delete_exchange(uri=None, exchange_name=None):
    """Delete an exchange from RabbitMQ. This should only be used for one-off
    operations.

    :param str uri: AMQP URI to connect to
    :param str exchange_name: The exchange name to delete
    :raises: :py:class:`ValueError`
    :raises: :py:class:`rabbitpy.RemoteClosedException`

    """
    if not exchange_name:
        raise ValueError('You must specify a exchange name to delete')
    with connection.Connection(uri) as conn:
        with conn.channel() as channel:
            obj = exchange.Exchange(channel, exchange_name)
            obj.delete()
예제 #4
0
 def test_bind_sends_exchange_unbind(self, rpc):
     rpc.return_value = specification.Exchange.UnbindOk
     obj = exchange.Exchange(self.channel, 'foo')
     obj.unbind('a', 'b')
     self.assertIsInstance(rpc.mock_calls[0][1][0],
                           specification.Exchange.Unbind)
예제 #5
0
 def test_bind_sends_exchange_delete(self, rpc):
     rpc.return_value = specification.Exchange.DeleteOk
     obj = exchange.Exchange(self.channel, 'foo')
     obj.delete()
     self.assertIsInstance(rpc.mock_calls[0][1][0],
                           specification.Exchange.Delete)
예제 #6
0
 def test_publish_with_exchange_object(self):
     _exchange = exchange.Exchange(self.channel, self.EXCHANGE)
     with mock.patch('rabbitpy.channel.Channel.write_frames') as wframes:
         self.msg.publish(_exchange, self.ROUTING_KEY)
         self.assertEqual(wframes.mock_calls[0][1][0][0].exchange,
                          self.EXCHANGE)