def test_bind(self, _load): name = 'qpid' adapter = Mock() url = URL('redhat.com') _load.return_value = [adapter], {name: adapter} Adapter.bind(str(url), name) _load.assert_called_with() self.assertEqual(Adapter.bindings, {url.canonical: adapter})
def test_find_with_binding(self, _load): name = 'A' url = 'amqp://redhat.com' adapter = Mock() _load.return_value = [adapter], {name: adapter} Adapter.bind(url, name) p = Adapter.find(url) _load.assert_called_with() self.assertEqual(p, adapter)
def __init__(self, url=None): """ :param url: The broker url. :type url: str """ BaseSender.__init__(self, url) adapter = Adapter.find(url) self._impl = adapter.Sender(url)
def __init__(self, url=None): """ :param url: The broker url. :type url: str """ Messenger.__init__(self, url) adapter = Adapter.find(url) self._impl = adapter.Sender(url) self.authenticator = None
def test_find(self, _load): name = 'A' url = '%s+amqp://redhat.com' % name adapter = Mock() _load.return_value = [adapter], {name: adapter} p = Adapter.find(url) _load.assert_called_with() self.assertEqual(p, adapter)
def test_find_without_url(self, _load): _list = [1, 2, 3] catalog = { 'C': _list[0], 'B': _list[1], 'A': _list[2] } _load.return_value = _list, catalog p = Adapter.find('') self.assertEqual(p, _list[0])
def __init__(self, url=None, retry=False): """ :param url: A broker URL. :type url: str :param retry: Retry failed connect. :type retry: bool """ BaseConnection.__init__(self, url) adapter = Adapter.find(url) self._impl = adapter.Connection(url) self.retry = retry
def delete(self, url=None): """ Delete the queue. :param url: The broker URL. :type url: str :raise: ModelError """ url = url or self.url adapter = Adapter.find(url) impl = adapter.Queue(self.name) impl.delete(url)
def delete(self, url=None): """ Delete the exchange. :param url: The broker URL. :type url: str :raise: ModelError """ url = url or self.url adapter = Adapter.find(url) impl = adapter.Exchange(self.name, self.policy) impl.delete(url)
def __init__(self, node, url=None): """ :param node: The ndoe to read. :type node: Node :param url: The broker url. :type url: str :see: gofer.messaging.adapter.url.URL """ BaseReader.__init__(self, node, url) adapter = Adapter.find(url) self._impl = adapter.Reader(node, url) self.authenticator = None
def unbind(self, queue, url=None): """ Unbind the specified queue. :param queue: The queue to unbind. :type queue: BaseQueue :param url: The broker URL. :type url: str """ url = url or self.url adapter = Adapter.find(url) impl = adapter.Exchange(self.name, self.policy) impl.unbind(queue, url)
def declare(self, url=None): """ Declare the queue. :param url: The broker URL. :type url: str :raise: ModelError """ url = url or self.url adapter = Adapter.find(url) impl = adapter.Queue(self.name) impl.durable = self.durable impl.auto_delete = self.auto_delete impl.expiration = self.expiration impl.exclusive = self.exclusive impl.declare(url)
def test_find_without_url(self, _load): _list = [1, 2, 3] catalog = {'C': _list[0], 'B': _list[1], 'A': _list[2]} _load.return_value = _list, catalog p = Adapter.find('') self.assertEqual(p, _list[0])