def _create_internal_sensor(self) -> AlertLevelInstrumentationErrorSensor: global_data = GlobalData() global_data.logger = logging.getLogger( "Alert Level Instrumentation Error Test Case") global_data.sensorAlertExecuter = MockSensorAlertExecuter() sensor = AlertLevelInstrumentationErrorSensor(global_data) sensor.initialize() return sensor
def _create_option_executer(self) -> Tuple[OptionExecuter, GlobalData]: config_logging(logging.ERROR) global_data = GlobalData() global_data.logger = logging.getLogger("Option Test Case") global_data.storage = MockStorage() global_data.managerUpdateExecuter = MockManagerUpdateExecuter() internal_sensor = MockProfileChangeSensorSensor(global_data) global_data.internalSensors.append(internal_sensor) option_executer = OptionExecuter(global_data) option_executer.daemon = True option_executer.start() return option_executer, global_data
def _create_internal_sensor(self) -> Tuple[ProfileChangeSensor, GlobalData]: global_data = GlobalData() global_data.logger = logging.getLogger("Profile Change Test Case") global_data.sensorAlertExecuter = MockSensorAlertExecuter() global_data.storage = MockStorage() profile = Profile() profile.profileId = 1 profile.name = "profile_1" global_data.profiles.append(profile) profile = Profile() profile.profileId = 2 profile.name = "profile_2" global_data.profiles.append(profile) sensor = ProfileChangeSensor(global_data) sensor.initialize() sensor.data = 1 sensor.nodeId = 1 sensor.clientSensorId = 2 return sensor, global_data
def _create_options(self, storage: Optional[Sqlite] = None) -> Sqlite: if storage is None: self.addCleanup(self._clean_up_storage) self.temp_dir = tempfile.mkdtemp() self.global_data = GlobalData() self.global_data.storageBackendSqliteFile = os.path.join( self.temp_dir, "database.db") self.global_data.logger = logging.getLogger("server") storage = Sqlite(self.global_data.storageBackendSqliteFile, self.global_data) self.options = [] # type: List[Option] # Account for implicit option "profile" which is created on storage creation. option = storage.get_option_by_type("profile") self.options.append(option) option = Option() option.type = "type_1" option.value = 1 self.options.append(option) storage.update_option_by_obj(option) option = Option() option.type = "type_2" option.value = 2 self.options.append(option) storage.update_option_by_obj(option) option = Option() option.type = "type_3" option.value = 3 self.options.append(option) storage.update_option_by_obj(option) return storage
def __init__(self): global_data = GlobalData() super().__init__(global_data) self._optional_data = list() # type: List[Dict[str, Any]]