Example #1
0
 def test_no_stream_name(self, server_init_mock, broker_class_mock):
     """ Tests that a ValueError is raised when creating a stream
     with no name specified in the config """
     config = {
         'input': 'some_stream',
         'handlers': [{
             'name': 'some-handler'
         }]
     }
     server = Server()
     with assert_raises_regexp(
             cfg.AitConfigMissing,
             'The parameter %s is missing from config.yaml' %
             'stream name'):
         server._get_stream_name(config)
Example #2
0
 def test_no_stream_name(self, server_stream_plugin_mock_mock,
                         broker_class_mock):
     """Tests that a ValueError is raised when creating a stream
     with no name specified in the config"""
     config = {
         "input": "some_stream",
         "handlers": [{
             "name": "some-handler"
         }]
     }
     server = Server()
     with pytest.raises(
             cfg.AitConfigMissing,
             match="The parameter stream name is missing from config.yaml",
     ):
         server._get_stream_name(config)
Example #3
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)
Example #4
0
    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)