Ejemplo n.º 1
0
    def test_open(self, connection, ssl_domain, find):
        url = TEST_URL
        connector = Connector(url)
        connector.ssl.ca_certificate = 'test-ca'
        connector.ssl.client_key = 'test-key'
        connector.ssl.client_certificate = 'test-crt'
        find.return_value = connector

        # test
        c = Connection(url)
        c._ssh = Mock()
        c.open()

        # validation
        ssl_domain.assert_called_once_with(connector)
        connection.assert_called_once_with(
            host=':'.join((connector.host, str(connector.port))),
            virtual_host=connector.virtual_host,
            userid=connector.userid,
            password=connector.password,
            ssl=ssl_domain.return_value,
            confirm_publish=True)

        connection.return_value.connect.assert_called_once_with()
        self.assertEqual(c._impl, connection.return_value)
Ejemplo n.º 2
0
 def test_close_failed(self):
     url = 'test-url'
     c = Connection(url)
     impl = Mock()
     impl.close.side_effect = ValueError
     c._impl = impl
     c.close()
Ejemplo n.º 3
0
 def __init__(self, url):
     """
     :param url: The broker url.
     :type url: str
     """
     BaseSender.__init__(self, url)
     self.connection = Connection(url)
     self.channel = None
Ejemplo n.º 4
0
 def test_close(self):
     url = 'test-url'
     c = Connection(url)
     impl = Mock()
     c._impl = impl
     c.close()
     impl.close.assert_called_once_with()
     self.assertEqual(c._impl, None)
Ejemplo n.º 5
0
 def __init__(self, node, url):
     """
     :param node: The AMQP node to read.
     :type node: gofer.messaging.adapter.model.Node
     :param url: The broker url.
     :type url: str
     :see: gofer.messaging.adapter.url.URL
     """
     BaseReader.__init__(self, node, url)
     self.connection = Connection(url)
     self.channel = None
     self.receiver = None
Ejemplo n.º 6
0
 def __init__(self, url):
     super(Endpoint, self).__init__(url)
     self.connection = Connection(url)
     self.channel = None
Ejemplo n.º 7
0
 def test_channel(self):
     url = TEST_URL
     c = Connection(url)
     c._impl = Mock()
     ch = c.channel()
     self.assertEqual(ch, c._impl.channel.return_value)
Ejemplo n.º 8
0
 def test_open_already(self):
     url = TEST_URL
     c = Connection(url)
     c._impl = Mock()
     c.open()
     self.assertFalse(c._impl.open.called)
Ejemplo n.º 9
0
 def test_init(self):
     url = TEST_URL
     c = Connection(url)
     self.assertTrue(isinstance(c, BaseConnection))
     self.assertEqual(c.url, url)