def test_secHash_consistent(self): """Tests that secHashFile of a pickled object is the same as secHashObject of the object.""" l = [1, 2, 3] d = dict() d['a'] = l d['b'] = l with TempDir() as tempDir: def loc(suffix): return os.path.join(tempDir.location, suffix) persist.savePickle(loc('d.pickle'), d) assert (persist.secHashFile(loc('d.pickle')) == persist.secHashObject(d))
def test_pickling(self): l = [1, 2, 3] d = dict() d['a'] = l d['b'] = l with TempDir() as tempDir: def loc(suffix): return os.path.join(tempDir.location, suffix) location1 = loc('d1.pickle') location2 = loc('d2.pickle') persist.savePickle(location1, d) persist.savePickle(location2, d) dAgain1 = persist.loadPickle(location1) dAgain2 = persist.loadPickle(location2) assert d == dAgain1 == dAgain2
def createLiveJob(self, job, queuer): jobSecHash = job.secHash() jobQueuerDir = self.getJobQueuerDir(job, queuer) createDir(jobQueuerDir) liveJobDir = tempfile.mkdtemp(prefix = 'liveJob.', dir = jobQueuerDir) liveJob = LiveJob(liveJobDir) persist.savePickle(os.path.join(liveJob.dir, 'job.pickle'), job) liveJob.setExtra('secHash', jobSecHash) persist.savePickle(os.path.join(liveJob.dir, 'buildRepo.pickle'), self) liveJob.setStored() job.checkAllSecHash() assert self.getJobQueuerDir(job, queuer) == jobQueuerDir jobAgain = persist.loadPickle(os.path.join(liveJob.dir, 'job.pickle')) job.checkAllSecHash() return liveJob
def saveValue(self, buildRepo, value): return persist.savePickle(self.loc(buildRepo), value)