コード例 #1
0
    def test_refresh(self, connector):
        url = 'amqp://localhost'
        descriptor = Mock(main=Mock(enabled='1', threads=4),
                          messaging=Mock(uuid='x99',
                                         url='amqp://localhost',
                                         cacert='ca',
                                         clientkey='key',
                                         clientcert='crt',
                                         heartbeat='8'))

        # test
        plugin = Plugin(descriptor, '')
        plugin.refresh()

        # validation
        connector.assert_called_once_with(descriptor.messaging.url)
        connector = connector.return_value
        connector.add.assert_called_once_with()
        self.assertEqual(connector.ssl.ca_certificate,
                         descriptor.messaging.cacert)
        self.assertEqual(connector.ssl.client_key,
                         descriptor.messaging.clientkey)
        self.assertEqual(connector.ssl.client_certificate,
                         descriptor.messaging.clientcert)
        self.assertEqual(connector.ssl.host_validation,
                         descriptor.messaging.host_validation)
コード例 #2
0
ファイル: test_plugin.py プロジェクト: darinlively/gofer
    def test_refresh(self, connector):
        url = 'amqp://localhost'
        descriptor = Mock(
            main=Mock(
                enabled='1',
                threads=4),
            messaging=Mock(
                uuid='x99',
                url='amqp://localhost',
                cacert='ca',
                clientkey='key',
                clientcert='crt',
                heartbeat='8')
        )

        # test
        plugin = Plugin(descriptor, '')
        plugin.refresh()

        # validation
        connector.assert_called_once_with(descriptor.messaging.url)
        connector = connector.return_value
        connector.add.assert_called_once_with()
        self.assertEqual(connector.ssl.ca_certificate, descriptor.messaging.cacert)
        self.assertEqual(connector.ssl.client_key, descriptor.messaging.clientkey)
        self.assertEqual(connector.ssl.client_certificate, descriptor.messaging.clientcert)
        self.assertEqual(connector.ssl.host_validation, descriptor.messaging.host_validation)
コード例 #3
0
    def test_attach(self, pool, model, consumer, node):
        queue = 'test'
        descriptor = Mock(main=Mock(threads=4))
        pool.return_value.run.side_effect = lambda fn: fn()
        model.return_value.queue = queue

        # test
        plugin = Plugin(descriptor, '')
        plugin.authenticator = Mock()
        plugin.detach = Mock()
        plugin.refresh = Mock()
        plugin.attach()

        # validation
        plugin.detach.assert_called_once_with(False)
        model.assert_called_with(plugin)
        model.return_value.setup.assert_called_once_with()
        node.assert_called_once_with(queue)
        consumer.assert_called_once_with(node.return_value, plugin)
        consumer = consumer.return_value
        consumer.start.assert_called_once_with()
        self.assertEqual(consumer.authenticator, plugin.authenticator)
        self.assertEqual(plugin.consumer, consumer)
コード例 #4
0
ファイル: test_plugin.py プロジェクト: darinlively/gofer
    def test_attach(self, pool, model, consumer, node):
        queue = 'test'
        descriptor = Mock(main=Mock(threads=4))
        pool.return_value.run.side_effect = lambda fn: fn()
        model.return_value.queue = queue

        # test
        plugin = Plugin(descriptor, '')
        plugin.authenticator = Mock()
        plugin.detach = Mock()
        plugin.refresh = Mock()
        plugin.attach()

        # validation
        plugin.detach.assert_called_once_with(False)
        model.assert_called_with(plugin)
        model.return_value.setup.assert_called_once_with()
        node.assert_called_once_with(queue)
        consumer.assert_called_once_with(node.return_value, plugin)
        consumer = consumer.return_value
        consumer.start.assert_called_once_with()
        self.assertEqual(consumer.authenticator, plugin.authenticator)
        self.assertEqual(plugin.consumer, consumer)