class TestContainersReceivingSerialDataAndObserverPattern(unittest.TestCase):
    def setUp(self):
        self.propulsion_manager = EventlessPropulsionManager()
        self.propulsion = Propulsion(self.propulsion_manager)

    def test_on_read_line_is_notify_triggered(self):
        self.propulsion.notify_all = MagicMock()
        self.propulsion_manager.on_read_line('{"test": 1}')
        self.assertTrue(self.propulsion.notify_all.called)
예제 #2
0
 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)
예제 #3
0
 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")
예제 #4
0
 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)
예제 #5
0
 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 setUp(self):
     self.propulsion_manager = EventlessPropulsionManager()
     self.propulsion = Propulsion(self.propulsion_manager)