Example #1
0
    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})
Example #2
0
    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})
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
 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)
Example #6
0
 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
Example #7
0
    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)
Example #8
0
 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])
Example #9
0
    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)
Example #10
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
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
 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
Example #14
0
 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)
Example #15
0
 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)
Example #16
0
 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])