def test_multiple_updates(self): a = self.make_empty_archive('A') m = FileManifest() data0 = ( \ ('foo.txt', 'This is the foo file.\n'), ('empty.txt', ''), ('big.txt', '*' * (1 * 128)), ) print "manifest sha: ", str_sha(m.stored_sha) m.update(a, entries_from_seq(self.tmps, data0)) print "manifest sha: ", str_sha(m.stored_sha) dump_archive(a, "AFTER FIRST WRITE:") verify_manifest(a, m) data1 = ( \ ('foo.txt', 'This is the foo file.\n'), ('empty.txt', ''), ('big.txt', 'hello' + ('*' * (1 * 128))), ) m.update(a, entries_from_seq(self.tmps, data1)) print "manifest sha: ", str_sha(m.stored_sha) dump_archive(a) verify_link_map(a.blocks.link_map) verify_manifest(a, m)
def test_many_updates(self): a = self.make_empty_archive('A') m = FileManifest() files = ("A.txt", "B.txt", "C.txt") updates = 100 for dummy in range(0, updates): names = list(files) random.shuffle(names) #names = names[:random.randrange(1, len(files))] data = [] for name in names: text = '' if name in m.name_map: tmp = self.tmps.make_temp_file() a.get_file(m.name_map[name][1], tmp) text = self.read_file(tmp) text += "\n".join([line for line in lines(20)]) data.append((name, text)) #print "updating:" #for value in data: # print value[0], len(value[1]) #print "manifest sha: ", str_sha(m.stored_sha) #dump_archive(a, "BEFORE UPDATE: %i" % count, True) m.update(a, entries_from_seq(self.tmps, data)) #print "manifest sha: ", str_sha(m.stored_sha) #dump_archive(a, "AFTER UPDATE: %i" % count, True) verify_manifest(a, m, True) verify_link_map(a.blocks.link_map) dump_blocks(a.blocks, None, True) a.close()