Ejemplo n.º 1
0
class Main:
    def __init__(self):
        self.config_service = ConfigurationService()
        self.comm_service = HubCommunicationService()
        self.rooms_service = RoomsService()

    def main(self):
        try:
            logging.info("System initialization started")
            config = self.config_service.read_configuration()
            self.rooms_service.initialize(configuration=config,
                                          comm_service=self.comm_service)
            self.comm_service.initialize(configuration=config,
                                         rooms_service=self.rooms_service)
            self.rooms_service.reset()
            logging.info("System initialized")

            pause()

            logging.info("System shutdown started")
            self.comm_service.destroy()
            logging.info("System shutdown completed")
        except Exception as ex:
            logging.fatal("System execution failed due exception ",
                          exc_info=True)
            raise ex
 def test_update_status_no_room_with_name(self):
     service = RoomsService()
     room_mock = Room("RoomXX")
     room_mock.updateStatus = Mock()
     service.rooms = [room_mock]
     service.updateStatus(point_id="/Room1/Point1", message="ON")
     room_mock.updateStatus.assert_not_called()
    def test_reset(self):
        service = RoomsService()
        room1 = Mock()
        room2 = Mock()
        service.rooms.append(room1)
        service.rooms.append(room2)

        service.reset()

        room1.reset.assert_called()
        room2.reset.assert_called()
 def test_initialize_sucess(self):
     conf = {
         "Rooms": [{
             "Name": "Office",
             "Points": []
         }, {
             "Name": "LivingRoom",
             "Points": []
         }]
     }
     service = RoomsService()
     service.initialize(configuration=conf, comm_service=None)
     self.assertEqual(2, len(service.rooms))
     self.assertEqual("Office", service.rooms[0].name)
     self.assertEqual("LivingRoom", service.rooms[1].name)
Ejemplo n.º 5
0
 def __init__(self):
     self.config_service = ConfigurationService()
     self.comm_service = HubCommunicationService()
     self.rooms_service = RoomsService()
 def test_get_room_name_success(self):
     service = RoomsService()
     self.assertEqual("RoomX", service.get_room_name("/RoomX/PointDFS"))
     self.assertEqual("Room1", service.get_room_name("/Room1/Point1"))
     self.assertEqual("Room1",
                      service.get_room_name("/Room1/Point1/SubPoint"))
 def test_initalize_none_config(self):
     service = RoomsService()
     service.initialize(configuration=None, comm_service=None)
     self.assertEqual(0, len(service.rooms))
 def test_initalize_empty_config(self):
     conf = {}
     service = RoomsService()
     service.initialize(configuration=conf, comm_service=None)
     self.assertEqual(0, len(service.rooms))
 def test_get_room_name_none(self):
     service = RoomsService()
     self.assertEqual(None, service.get_room_name("Room1"))
     self.assertEqual(None, service.get_room_name("/Room1"))