def test_successful_outbound_stream_creation( self, create_handler_mock, server_stream_plugin_mock_mock, broker_class_mock): """Tests that all types of outbound streams are successfully created""" # Testing creation of outbound stream with ZMQ input/output server = Server() server.broker = ait.core.server.broker.Broker() config = { "name": "some_stream", "handlers": [{ "name": "some-handler" }] } created_stream = server._create_outbound_stream(config) assert type(created_stream) == ait.core.server.stream.ZMQStream assert created_stream.name == "some_stream" assert type(created_stream.handlers) == list # Testing creation of outbound stream with port output config = cfg.AitConfig(config={"name": "some_stream", "output": 3333}) created_stream = server._create_outbound_stream(config) assert type(created_stream) == ait.core.server.stream.PortOutputStream assert created_stream.name == "some_stream" assert created_stream.out_port == 3333 assert created_stream.handlers == []
def test_successful_outbound_stream_creation(self, create_handler_mock, server_init_mock, broker_class_mock): """ Tests that all types of outbound streams are successfully created """ # Testing creation of outbound stream with ZMQ input/output server = Server() server.broker = ait.core.server.broker.Broker() config = { 'name': 'some_stream', 'handlers': [{ 'name': 'some-handler' }] } created_stream = server._create_outbound_stream(config) assert type(created_stream) == ait.core.server.stream.ZMQStream assert created_stream.name == 'some_stream' assert type(created_stream.handlers) == list # Testing creation of outbound stream with port output config = cfg.AitConfig(config={'name': 'some_stream', 'output': 3333}) created_stream = server._create_outbound_stream(config) assert type(created_stream) == ait.core.server.stream.PortOutputStream assert created_stream.name == 'some_stream' assert created_stream.out_port == 3333 assert created_stream.handlers == []
def test_no_stream_config(self, server_init_mock, broker_class_mock): """ Tests that a ValueError is raised when creating streams with a config of None """ server = Server() with assert_raises_regexp(ValueError, 'No stream config to create stream from.'): server._create_inbound_stream(None) with assert_raises_regexp(ValueError, 'No stream config to create stream from.'): server._create_outbound_stream(None)
def test_no_stream_config(self, server_stream_plugin_mock_mock, broker_class_mock): """Tests that a ValueError is raised when creating streams with a config of None""" server = Server() with pytest.raises(ValueError, match="No stream config to create stream from."): server._create_inbound_stream(None) with pytest.raises(ValueError, match="No stream config to create stream from."): server._create_outbound_stream(None)