예제 #1
0
 def testPersistValidation(self):
     logger.configureCategory("APP", logger.Severity.ERR)
     testFile = getTempFileName()
     p = persist.Persist(testFile, {'test': 1})
     p.commit()
     p = persist.Persist(testFile, [],
                         validator=lambda v: isinstance(v, list))
     self.assertEqual(p.data, [])
     os.unlink(testFile)
     logger.configureCategory("APP", logger.Severity.WARN)
예제 #2
0
 def testPersistStore(self):
     testFile = getTempFileName()
     p = persist.Persist(testFile, {})
     self.assertEqual(p.storeFile, testFile)
     self.assertEqual(p.data, {})
     p.data['test'] = 1
     p.commit()
     p = persist.Persist(testFile, {})
     self.assert_('test' in p.data)
     self.assertEqual(p.data['test'], 1)
     os.unlink(testFile)
예제 #3
0
 def testPersistCorrupted(self):
     logger.configureCategory("APP", logger.Severity.ERR)
     testFile = getTempFileName()
     f = open(testFile, 'w')
     f.write('garbage')
     f.close()
     p = persist.Persist(testFile, {})
     self.assertEqual(p.data, {})
     os.unlink(testFile)
     logger.configureCategory("APP", logger.Severity.WARN)