def test_no_handler_config(self, server_init_mock, broker_mock): """ Tests that a ValueError is raised when creating a handler with a config of None """ server = Server() with assert_raises_regexp(ValueError, 'No handler config to create handler from.'): server._create_handler(None)
def test_handler_that_doesnt_exist(self, server_init_mock, broker_mock): """ Tests that exception thrown if handler doesn't exist """ server = Server() config = {'name': 'some_nonexistant_handler'} with assert_raises_regexp( ImportError, "No module named '{}'".format(config['name'])): server._create_handler(config)
def test_no_handler_config(self, server_stream_plugin_mock_mock, broker_mock): """Tests that a ValueError is raised when creating a handler with a config of None""" server = Server() with pytest.raises(ValueError, match="No handler config to create handler from."): server._create_handler(None)
def test_handler_that_doesnt_exist(self, server_stream_plugin_mock_mock, broker_mock): """Tests that exception thrown if handler doesn't exist""" server = Server() config = {"name": "some_nonexistant_handler"} with pytest.raises(ImportError, match="No module named '{}'".format( config["name"])): server._create_handler(config)
def test_handler_creation_with_no_configs(self, server_init_mock, broker_mock): """ Tests handler is successfully created when it has no configs """ server = Server() config = { 'name': 'ait.core.server.handlers.PacketHandler', 'packet': 'CCSDS_HEADER' } handler = server._create_handler(config) assert type(handler) == ait.core.server.handlers.PacketHandler assert handler.input_type is None assert handler.output_type is None
def test_handler_creation_with_no_configs(self, server_stream_plugin_mock_mock, broker_mock): """Tests handler is successfully created when it has no configs""" server = Server() config = { "name": "ait.core.server.handlers.PacketHandler", "packet": "CCSDS_HEADER", } handler = server._create_handler(config) assert type(handler) == ait.core.server.handlers.PacketHandler assert handler.input_type is None assert handler.output_type is None
def test_handler_creation_with_configs(self, server_stream_plugin_mock_mock, broker_mock): """Tests handler is successfully created when it has configs""" server = Server() # config = {'name': 'ait.core.server.handlers.example_handler', 'input_type': 'int', 'output_type': 'int'} config = { "name": "ait.core.server.handlers.PacketHandler", "input_type": "int", "output_type": "int", "packet": "CCSDS_HEADER", } handler = server._create_handler(config) assert type(handler) == ait.core.server.handlers.PacketHandler assert handler.input_type == "int" assert handler.output_type == "int"