Example #1
0
 def test_reload_devices(self):
     environment = yield self._logicLayer.add_environment(name="Test Environment", description="A test Environment", status="active")
     environment2 = yield self._logicLayer.add_environment(name="Test Environment2", description="A test Environment2", status="inactive")
     
     device = yield self._logicLayer.add_device(environmentId = environment.cid, name="Test Device",description = "A test description")
     device2 = yield self._logicLayer.add_device(environmentId = environment.cid, name="Test Device Two",description = "A test description too")
     device3 = yield self._logicLayer.add_device(environmentId = environment2.cid, name="Test Device Three")
     
     self._persistenceLayer.tearDown()
     self._persistenceLayer = None
     self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
     self._logicLayer = LogicLayer(self._persistenceLayer)
     yield self._logicLayer.setup()
     
     lExpDevicesEnv1 = [device,device2]
     lObsDevicesEnv1 = yield self._logicLayer.get_devices(environmentId = environment.cid)
     lExpDevicesEnv1 = sorted(lExpDevicesEnv1,key=lambda device: device.name)
     lObsDevicesEnv1 = sorted(lObsDevicesEnv1,key=lambda device: device.name)
     self.assertEquals(lObsDevicesEnv1, lExpDevicesEnv1)
     
     lExpDevicesEnv2 = [device3]
     lObsDevicesEnv2 = yield self._logicLayer.get_devices(environmentId = environment2.cid)
     lExpDevicesEnv2 = sorted(lExpDevicesEnv2,key=lambda device: device.name)
     lObsDevicesEnv2 = sorted(lObsDevicesEnv2,key=lambda device: device.name)
     self.assertEquals(lObsDevicesEnv2, lExpDevicesEnv2)
     
     yield self._persistenceLayer.delete_environments([environment,environment2]) 
Example #2
0
 def test_reload_tasks(self):
     environment = yield self._logicLayer.add_environment(name="Test Environment", description="A test Environment", status="active")
     environment2 = yield self._logicLayer.add_environment(name="Test Environment2", description="A test Environment2", status="inactive")
     
     task = yield self._logicLayer.add_task(environmentId = environment.cid, name="Test Task",description = "A test description")
     task2 = yield self._logicLayer.add_task(environmentId = environment.cid, name="Test Task Two",description = "A test description too")
     task3 = yield self._logicLayer.add_task(environmentId = environment2.cid, name="Test Task Three")
     
     self._persistenceLayer.tearDown()
     self._persistenceLayer = None
     self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
     self._logicLayer = LogicLayer(self._persistenceLayer)
     yield self._logicLayer.setup()
     
     lExpTasksEnv1 = [task,task2]
     lObsTasksEnv1 = yield self._logicLayer.get_tasks(environmentId = environment.cid)
     lExpTasksEnv1 = sorted(lExpTasksEnv1,key=lambda task: task.name)
     lObsTasksEnv1 = sorted(lObsTasksEnv1,key=lambda task: task.name)
     self.assertEquals(lObsTasksEnv1, lExpTasksEnv1)
     
     lExpTasksEnv2 = [task3]
     lObsTasksEnv2 = yield self._logicLayer.get_tasks(environmentId = environment2.cid)
     lExpTasksEnv2 = sorted(lExpTasksEnv2,key=lambda task: task.name)
     lObsTasksEnv2 = sorted(lObsTasksEnv2,key=lambda task: task.name)
     self.assertEquals(lObsTasksEnv2, lExpTasksEnv2)
     
     yield self._persistenceLayer.delete_environments([environment,environment2]) 
Example #3
0
 def test_reload_complete(self):
     environment = yield self._logicLayer.add_environment(name="Test Environment", description="A test Environment", status="active")
     environment2 = yield self._logicLayer.add_environment(name="Test Environment2", description="A test Environment2", status="inactive")
     
     task = yield self._logicLayer.add_task(environmentId = environment.cid, name="Test Task",description = "A test description")
     task2 = yield self._logicLayer.add_task(environmentId = environment.cid, name="Test Task Two",description = "A test description too")
     task3 = yield self._logicLayer.add_task(environmentId = environment2.cid, name="Test Task Three")
     task4 = yield self._logicLayer.add_task(environmentId = environment2.cid, name="Test Task Four")
     
     device = yield self._logicLayer.add_device(environmentId = environment.cid, name="Test Device", description = "A test description", type="Test")
     device2 = yield self._logicLayer.add_device(environmentId = environment2.cid, name="Test Device Two", description = "Another test description", type="Test")
     device3 = yield self._logicLayer.add_device(environmentId = environment2.cid, name="Test Device Three", type="Test")
     
     """destroy current layer, restart and reload"""
     self._persistenceLayer.tearDown()
     self._persistenceLayer = None
     self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
     self._logicLayer = LogicLayer(self._persistenceLayer)
     yield self._logicLayer.setup()
     
     lExpEnvs = [environment,environment2]
     lObsEnvs = yield self._logicLayer.get_environments()
     lObsEnvs = sorted(lObsEnvs,key=lambda environment: environment.name)
     lExpEnvs = sorted(lExpEnvs,key=lambda environment: environment.name)
     self.assertEquals(lObsEnvs,lExpEnvs)
     
     lExpTasksEnv1 = [task,task2]
     lObsTasksEnv1 = yield self._logicLayer.get_tasks(environmentId = environment.cid)
     lExpTasksEnv1 = sorted(lExpTasksEnv1,key=lambda task: task.name)
     lObsTasksEnv1 = sorted(lObsTasksEnv1,key=lambda task: task.name)
     self.assertEquals(lObsTasksEnv1, lExpTasksEnv1)
     
     lExpTasksEnv2 = [task3,task4]
     lObsTasksEnv2 = yield self._logicLayer.get_tasks(environmentId = environment2.cid)
     lExpTasksEnv2 = sorted(lExpTasksEnv2,key=lambda task: task.name)
     lObsTasksEnv2 = sorted(lObsTasksEnv2,key=lambda task: task.name)
     self.assertEquals(lObsTasksEnv2, lExpTasksEnv2)
     
     lExpDevicesEnv1 = [device]
     lObsDevicesEnv1 = yield self._logicLayer.get_devices(environmentId = environment.cid)
     lExpDevicesEnv1 = sorted(lExpDevicesEnv1,key=lambda device: device.name)
     lObsDevicesEnv1 = sorted(lObsDevicesEnv1,key=lambda device: device.name)
     self.assertEquals(lObsDevicesEnv1, lExpDevicesEnv1)
     
     lExpDevicesEnv2 = [device2,device3]
     lObsDevicesEnv2 = yield self._logicLayer.get_devices(environmentId = environment2.cid)
     lExpDevicesEnv2 = sorted(lExpDevicesEnv2,key=lambda device: device.name)
     lObsDevicesEnv2 = sorted(lObsDevicesEnv2,key=lambda device: device.name)
     self.assertEquals(lObsDevicesEnv2, lExpDevicesEnv2)
     
     yield self._persistenceLayer.delete_environments([environment,environment2]) 
Example #4
0
 def test_reload_environments(self):
     environment = yield self._logicLayer.add_environment(name="Test Environment", description="A test Environment", status="active")
     environment2 = yield self._logicLayer.add_environment(name="Test Environment2", description="A test Environment2", status="inactive")
     
     self._persistenceLayer.tearDown()
     self._persistenceLayer = None
     self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
     self._logicLayer = LogicLayer(self._persistenceLayer)
     yield self._logicLayer.setup()
     
     lExpEnvs = [environment,environment2]
     lObsEnvs = yield self._logicLayer.get_environments()
     lObsEnvs = sorted(lObsEnvs,key=lambda environment: environment.name)
     lExpEnvs = sorted(lExpEnvs,key=lambda environment: environment.name)
     self.assertEquals(lObsEnvs,lExpEnvs)
     
     yield self._persistenceLayer.delete_environments([environment,environment2])         
Example #5
0
 def setUp(self):
     self._path_manager = PathManager()
     self._path_manager.dataPath = "."
     self._persistenceLayer = PersistenceLayer(pathManager = self._path_manager)
     self._logicLayer = LogicLayer(self._persistenceLayer)
     yield self._logicLayer.setup()