def test_dispatch_controller_json_parsing_on_failure_of_dgram(self): manager = EventlessPropulsionManager( serial_sett_entity=SettingsEntity("")) propulsion = Propulsion(device_manager=manager) controller = DispatchController([propulsion]) controller.acquire_new_data(self.invalid_json) self.assertFalse(propulsion.data)
def test_data_handling_to_device(self): manager = EventlessPropulsionManager( serial_sett_entity=SettingsEntity("")) propulsion = Propulsion(device_manager=manager) controller = DataController(propulsion, NullDevice(), NullDevice()) controller.acquire_new_data(self.system_json) self.assertTrue(manager.is_line_sent, "Line not sent")
def test_dispatch_controller_send_to_propulsion(self): manager = EventlessPropulsionManager( serial_sett_entity=SettingsEntity("")) propulsion = Propulsion(device_manager=manager) controller = DispatchController([propulsion]) controller.acquire_new_data(self.system_json) propulsion_recvd_dict = json.loads(manager.line_sent) self.assertDictEqual(self.propulsion_dict, propulsion_recvd_dict)
def test_expected_line_handling_propulsion(self): manager = EventlessPropulsionManager( serial_sett_entity=SettingsEntity("")) propulsion = Propulsion(device_manager=manager) controller = DataController(propulsion, NullDevice(), NullDevice()) controller.acquire_new_data(self.system_json) propulsion_recvd_dict = json.loads(manager.line_sent) self.assertDictEqual(self.propulsion_dict, propulsion_recvd_dict)
def test_dispatch_controller_send_to_propulsion_and_manipulator(self): manipulator_manager = EventlessManipulatorManager( serial_sett_entity=SettingsEntity("")) propulsion_manager = EventlessManipulatorManager( serial_sett_entity=SettingsEntity("")) propulsion = Propulsion(device_manager=propulsion_manager) manipulator = Manipulator(device_manager=manipulator_manager) controller = DispatchController([propulsion, manipulator]) controller.acquire_new_data(self.system_json) manipulator_recvd_dict = json.loads(manipulator_manager.line_sent) propulsion_recvd_dict = json.loads(propulsion_manager.line_sent) self.assertDictContainsSubset(self.manipulator_dict, manipulator_recvd_dict, "MSG") self.assertDictEqual(self.propulsion_dict, propulsion_recvd_dict)
def setUp(self): self.propulsion_manager = EventlessPropulsionManager() self.propulsion = Propulsion(self.propulsion_manager)
def create(self, *args, **kwargs): propulsion_manager = self.device_manager_factory.create() return Propulsion(device_manager=propulsion_manager)