def test_json_parsing_on_failure_of_dgram(self): manager = EventlessPropulsionManager( serial_sett_entity=SettingsEntity("")) propulsion = Propulsion(device_manager=manager) controller = DataController(propulsion, NullDevice(), NullDevice()) 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_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_expected_line_handling_manipulator(self): manager = EventlessManipulatorManager( serial_sett_entity=SettingsEntity("")) manipulator = Manipulator(device_manager=manager) controller = DataController(NullDevice(), manipulator, NullDevice()) controller.acquire_new_data(self.system_json) manipulator_recvd_dict = json.loads(manager.line_sent) self.assertDictContainsSubset(self.manipulator_dict, manipulator_recvd_dict, "MSG")
def __init__(self, *args, **kwargs): NullDevice.__init__(self)
def __init__(self, serial_sett_entity=SettingsEntity(""), device_model=NullDevice()): self.is_line_sent = False self.line_sent = "" self.serial_sett_entity = serial_sett_entity self.device_conn = serial_sett_entity.get_settings() self.device_model = device_model
def test_udpreceiver_to_data_controller_communication(self): controller = DataController(NullDevice(), NullDevice(), NullDevice()) recvr = EventlessUDPReceiver(controller=controller) recvr.on_read_line(self.address, self.simple_json) self.assertEqual(self.simple_json, controller.recent_line_acquired)