Exemple #1
0
    def test_open(self, connection, find, add_transports, ssl_domain):
        url = TEST_URL
        connector = Connector(url)
        connector.ssl.ca_certificate = 'test-ca'
        connector.ssl.client_key = 'test-key'
        connector.ssl.client_certificate = 'test-crt'
        connector.heartbeat = '4'
        find.return_value = connector

        ssl_properties = {'A': 1, 'B': 2}
        ssl_domain.return_value = ssl_properties

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

        # validation
        add_transports.assert_called_once_with()
        connection.assert_called_once_with(host=connector.host,
                                           port=connector.port,
                                           tcp_nodelay=True,
                                           transport=connector.scheme,
                                           username=connector.userid,
                                           password=connector.password,
                                           heartbeat=connector.heartbeat,
                                           **ssl_properties)

        ssl_domain.assert_called_once_with(connector)
        c._impl.open.assert_called_once_with()
        self.assertEqual(c._impl, connection.return_value)
Exemple #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()
Exemple #3
0
 def __init__(self, url):
     """
     :param url: The broker url.
     :type url: str
     """
     BaseSender.__init__(self, url)
     self.connection = Connection(url)
     self.session = None
Exemple #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)
Exemple #5
0
 def __init__(self, url, name, arguments):
     """
     :param url: The broker url.
     :type url: str
     :param name: The method name.
     :type name: str
     :param arguments: The method arguments.
     :type arguments: dict
     """
     super(Method, self).__init__(url)
     self.name = name
     self.arguments = arguments
     self.connection = Connection(url)
     self.session = None
     self.sender = None
     self.receiver = None
     self.reply_to = REPLY_TO % uuid4()
Exemple #6
0
 def test_init(self):
     url = TEST_URL
     c = Connection(url)
     self.assertTrue(isinstance(c, BaseConnection))
     self.assertEqual(c.url, url)
Exemple #7
0
 def test_session(self):
     url = TEST_URL
     c = Connection(url)
     c._impl = Mock()
     session = c.session()
     self.assertEqual(session, c._impl.session.return_value)
Exemple #8
0
 def test_open_already(self):
     url = TEST_URL
     c = Connection(url)
     c._impl = Mock()
     c.open()
     self.assertFalse(c._impl.open.called)