コード例 #1
0
    def test_duplicate_stream_name(self, server_stream_plugin_mock_mock,
                                   broker_class_mock):
        """Tests that a ValueError is raised when creating a stream with
        a name that already belongs to another stream or plugin"""
        server = Server()

        config = {
            "input": ["some_stream"],
            "name": "myname",
            "handlers": [{
                "name": "some-handler"
            }],
        }

        # Testing existing name in plugins
        server.plugins = [FakeStream(name="myname")]
        with pytest.raises(
                ValueError,
                match=('Duplicate stream name "{}" encountered.'
                       " Stream names must be unique.").format("myname"),
        ):
            server._get_stream_name(config)

        # Testing existing name in inbound_streams
        server.plugins = []
        server.inbound_streams = [FakeStream(name="myname")]
        with pytest.raises(
                ValueError,
                match=('Duplicate stream name "{}" encountered.'
                       " Stream names must be unique.").format("myname"),
        ):
            server._get_stream_name(config)

        # Testing existing name in outbound_streams
        server.inbound_streams = []
        server.outbound_streams = [FakeStream(name="myname")]
        with pytest.raises(
                ValueError,
                match=('Duplicate stream name "{}" encountered.'
                       " Stream names must be unique.").format("myname"),
        ):
            server._get_stream_name(config)
コード例 #2
0
ファイル: test_server.py プロジェクト: tylerobrien2/AIT-Core
    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)
コード例 #3
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)
コード例 #4
0
ファイル: test_server.py プロジェクト: tylerobrien2/AIT-Core
    def test_duplicate_stream_name(self, server_init_mock, broker_class_mock):
        """ Tests that a ValueError is raised when creating a stream with
        a name that already belongs to another stream or plugin """
        server = Server()

        config = {
            'input': ['some_stream'],
            'name': 'myname',
            'handlers': [{
                'name': 'some-handler'
            }]
        }

        # Testing existing name in plugins
        server.plugins = [FakeStream(name='myname')]
        with assert_raises_regexp(
                ValueError,
            ('Duplicate stream name "{}" encountered.'
             ' Stream names must be unique.').format('myname')):
            server._get_stream_name(config)

        # Testing existing name in inbound_streams
        server.plugins = []
        server.inbound_streams = [FakeStream(name='myname')]
        with assert_raises_regexp(
                ValueError,
            ('Duplicate stream name "{}" encountered.'
             ' Stream names must be unique.').format('myname')):
            server._get_stream_name(config)

        # Testing existing name in outbound_streams
        server.inbound_streams = []
        server.outbound_streams = [FakeStream(name='myname')]
        with assert_raises_regexp(
                ValueError,
            ('Duplicate stream name "{}" encountered.'
             ' Stream names must be unique.').format('myname')):
            server._get_stream_name(config)