Example #1
0
    def test_plugin_doesnt_exist(self, server_init_mock, broker_mock):
        """ Tests that error raised if plugin doesn't exist """
        server = Server()

        config = {'name': 'some_nonexistant_plugin', 'inputs': 'some_inputs'}
        with assert_raises_regexp(ImportError,
                                  "No module named 'some_nonexistant_plugin'"):
            server._create_plugin(config)
Example #2
0
    def test_plugin_with_no_config(self, server_init_mock, broker_mock):
        """ Tests that error raised if plugin not configured """
        server = Server()

        config = None
        with assert_raises_regexp(ValueError,
                                  'No plugin config to create plugin from.'):
            server._create_plugin(config)
Example #3
0
    def test_plugin_missing_name(self, server_init_mock, broker_mock):
        """ Tests that error raised if plugin has no name """
        server = Server()

        config = {'inputs': 'some_inputs'}
        with assert_raises_regexp(
                cfg.AitConfigMissing,
                'The parameter plugin name is missing from config.yaml'):
            server._create_plugin(config)
Example #4
0
    def test_plugin_doesnt_exist(self, server_stream_plugin_mock_mock,
                                 broker_mock):
        """Tests that error raised if plugin doesn't exist"""
        server = Server()

        config = {"name": "some_nonexistant_plugin", "inputs": "some_inputs"}
        with pytest.raises(ImportError,
                           match="No module named 'some_nonexistant_plugin'"):
            server._create_plugin(config)
Example #5
0
    def test_plugin_with_no_config(self, server_stream_plugin_mock_mock,
                                   broker_mock):
        """Tests that error raised if plugin not configured"""
        server = Server()

        config = None
        with pytest.raises(ValueError,
                           match="No plugin config to create plugin from."):
            server._create_plugin(config)
Example #6
0
    def test_plugin_name_already_in_use(self, server_init_mock, broker_mock):
        """ Tests that error raised if name already in use """
        server = Server()

        server.plugins = [FakeStream(name='Plugin')]
        config = {'name': 'Plugin', 'inputs': 'some_inputs'}
        with assert_raises_regexp(
                ValueError,
                'Plugin "Plugin" already loaded. Only one plugin of a given name is allowed'
        ):
            server._create_plugin(config)
Example #7
0
    def test_plugin_missing_name(self, server_stream_plugin_mock_mock,
                                 broker_mock):
        """Tests that error raised if plugin has no name"""
        server = Server()

        config = {"inputs": "some_inputs"}
        with pytest.raises(
                cfg.AitConfigMissing,
                match="The parameter plugin name is missing from config.yaml",
        ):
            server._create_plugin(config)
Example #8
0
    def test_plugin_name_already_in_use(self, server_stream_plugin_mock_mock,
                                        broker_mock):
        """Tests that error raised if name already in use"""
        server = Server()

        server.plugins = [FakeStream(name="Plugin")]
        config = {"name": "Plugin", "inputs": "some_inputs"}
        with pytest.raises(
                ValueError,
                match=
                'Plugin "Plugin" already loaded. Only one plugin of a given name is allowed',
        ):
            server._create_plugin(config)
Example #9
0
    def test_plugin_missing_outputs(self, log_warn_mock, server_init_mock,
                                    broker_mock):
        """ Tests that warning logged if plugin has no inputs and
        plugin created anyways """
        server = Server()
        server.broker = ait.core.server.broker.Broker()

        config = {
            'name': 'ait.core.server.plugins.TelemetryLimitMonitor',
            'inputs': 'some_stream'
        }
        server._create_plugin(config)

        log_warn_mock.assert_called_with(
            'No plugin outputs specified for ait.core.server.plugins.TelemetryLimitMonitor'
        )
Example #10
0
    def test_plugin_missing_inputs(self, log_warn_mock,
                                   server_stream_plugin_mock_mock,
                                   broker_mock):
        """Tests that warning logged if plugin has no inputs and
        plugin created anyways"""
        server = Server()
        server.broker = ait.core.server.broker.Broker()

        config = {
            "name": "ait.core.server.plugins.TelemetryLimitMonitor",
            "outputs": "some_stream",
        }
        server._create_plugin(config)

        log_warn_mock.assert_called_with(
            "No plugin inputs specified for ait.core.server.plugins.TelemetryLimitMonitor"
        )