def test_save_device_existing(self): input = Device(name="TestDevice",description="A test description") yield self._deviceSqliteDao.save_device(input) input.name = "TestDeviceModified" yield self._deviceSqliteDao.save_device(input) exp = input obs = yield self._deviceSqliteDao.load_device(id = 1) self.assertEquals(obs,exp)
def test_save_device_existing(self): input = Device(name="TestDevice", description="A test description") yield self._deviceSqliteDao.save_device(input) input.name = "TestDeviceModified" yield self._deviceSqliteDao.save_device(input) exp = input obs = yield self._deviceSqliteDao.load_device(id=1) self.assertEquals(obs, exp)
def test_load_multiple_devices(self): input = [ Device(name="TestDeviceOne", description="A test description", status="inactive"), Device(name="TestDeviceTwo", description="Another test description", status="active") ] yield self._deviceSqliteDao.save_devices(input) exp = input obs = yield self._deviceSqliteDao.load_devices() self.assertEquals(obs, exp)
def test_save_devices(self): input = [ Device(name="TestDevice", description="A test description", status="inactive"), Device(name="TestDevice", description="A test description", status="active") ] yield self._deviceSqliteDao.save_devices(input) expLDevices = input obsLDevices = yield self._deviceSqliteDao.load_devices() self.assertEquals(expLDevices, obsLDevices)
def test_get_store_correct_db_from_sub_elements(self): expEnvironmentOneDbName = "environmentOne.db" env = Environment2(name = "environmentOne") device = Device(name = "arduino") device. _parent = env strategy = SqlitePersistenceStrategy() deviceDbPool = strategy.get_store(device,"Device") try: yield deviceDbPool.runQuery('''select * from devices''') except:pass self.assertTrue(os.path.exists(expEnvironmentOneDbName)) yield strategy.tear_down() os.remove(expEnvironmentOneDbName)
def test_load_devicebyid(self): input = Device(name="TestDevice", description="A test description load", status="active") yield self._deviceSqliteDao.save_device(input) exp = input obs = yield self._deviceSqliteDao.load_device(id=1) self.assertEquals(obs, exp)
def test_get_store_correct_db_from_sub_elements(self): expEnvironmentOneDbName = "environmentOne.db" env = Environment2(name="environmentOne") device = Device(name="arduino") device._parent = env strategy = SqlitePersistenceStrategy() deviceDbPool = strategy.get_store(device, "Device") try: yield deviceDbPool.runQuery('''select * from devices''') except: pass self.assertTrue(os.path.exists(expEnvironmentOneDbName)) yield strategy.tear_down() os.remove(expEnvironmentOneDbName)
def test_load_device(self): input = Device(name="testDevice",description = "just a device") yield self._sqliteDaoManager.save_device(input) exp = input obs = self._sqliteDaoManager.load_device(id = 1)