class TaskManagerFTest(unittest.TestCase): @defer.inlineCallbacks def setUp(self): self._path_manager = PathManager() self._path_manager._addon_path = os.path.abspath("addons") self._path_manager.tmpPath = os.path.abspath("tmp") if not os.path.exists(self._path_manager.tmpPath): os.makedirs(self._path_manager.tmpPath) if not os.path.exists(self._path_manager._addon_path): os.makedirs(self._path_manager._addon_path) self._persistenceLayer = PersistenceLayer(pathManager=self._path_manager) self._taskManager = TaskManager(pathManager=self._path_manager) yield self._taskManager.setup() def tearDown(self): if os.path.exists(self._path_manager.tmpPath): shutil.rmtree(self._path_manager.tmpPath) if os.path.exists(self._path_manager._addon_path): shutil.rmtree(self._path_manager._addon_path) def test_add_task(self): task = self._taskManager.add_task("Test task", "a description", None, None) def test_add_task_condition(self): task = self._taskManager.add_task("Test task", "a description") self._taskManager.add_conditionToTask(id, condition) #self._taskManager.a
def __init__(self,parent = None, persistenceLayer= None, name="home",description="Add Description here",status="active",*args,**kwargs): BaseComponent.__init__(self, parent) self._persistenceLayer = persistenceLayer self.name=name self.description=description self.status=status self._devices=DeviceManager(self) self._tasks=TaskManager(self)
def setUp(self): self._path_manager = PathManager() self._path_manager._addon_path = os.path.abspath("addons") self._path_manager.tmpPath = os.path.abspath("tmp") if not os.path.exists(self._path_manager.tmpPath): os.makedirs(self._path_manager.tmpPath) if not os.path.exists(self._path_manager._addon_path): os.makedirs(self._path_manager._addon_path) self._persistenceLayer = PersistenceLayer(pathManager=self._path_manager) self._taskManager = TaskManager(pathManager=self._path_manager) yield self._taskManager.setup()
def __init__( self, parent=None, persistenceLayer=None, name="home", description="Add Description here", status="active", *args, **kwargs ): BaseComponent.__init__(self, parent) self._persistenceLayer = persistenceLayer self.name = name self.description = description self.status = status self._devices = DeviceManager(self) self._tasks = TaskManager(self)
class Environment(BaseComponent): def __init__(self,parent = None, persistenceLayer= None, name="home",description="Add Description here",status="active",*args,**kwargs): BaseComponent.__init__(self, parent) self._persistenceLayer = persistenceLayer self.name=name self.description=description self.status=status self._devices=DeviceManager(self) self._tasks=TaskManager(self) def __eq__(self, other): return self.cid == other.cid and self.name == other.name and self.description == other.description and self.status == other.status def __ne__(self, other): return not self.__eq__(other) def __str__(self): return "%s %s %s" %(self.name,self.description,self.status) def __getattr__(self, attr_name): if hasattr(self._devices, attr_name): return getattr(self._devices, attr_name) elif hasattr(self._tasks, attr_name): return getattr(self._tasks, attr_name) else: raise AttributeError(attr_name) """ #################################################################################### Configuration and shutdown methods """ @defer.inlineCallbacks def setup(self): """ Method configuring additional elements of the current environment """ yield self._devices.setup() yield self._tasks.setup() log.msg("Environment ",self.name ,"with id", self.cid," setup correctly", logLevel=logging.CRITICAL, system="environment") def teardown(self): """
class Environment(BaseComponent): def __init__( self, parent=None, persistenceLayer=None, name="home", description="Add Description here", status="active", *args, **kwargs ): BaseComponent.__init__(self, parent) self._persistenceLayer = persistenceLayer self.name = name self.description = description self.status = status self._devices = DeviceManager(self) self._tasks = TaskManager(self) def __eq__(self, other): return ( self.cid == other.cid and self.name == other.name and self.description == other.description and self.status == other.status ) def __ne__(self, other): return not self.__eq__(other) def __str__(self): return "%s %s %s" % (self.name, self.description, self.status) def __getattr__(self, attr_name): if hasattr(self._devices, attr_name): return getattr(self._devices, attr_name) elif hasattr(self._tasks, attr_name): return getattr(self._tasks, attr_name) else: raise AttributeError(attr_name) """ #################################################################################### Configuration and shutdown methods """ @defer.inlineCallbacks def setup(self): """ Method configuring additional elements of the current environment """ yield self._devices.setup() yield self._tasks.setup() log.msg( "Environment ", self.name, "with id", self.cid, " setup correctly", logLevel=logging.CRITICAL, system="environment", ) def teardown(self): """