# # patch "merkle_dir.py" # from [09d854914ad5a16e07d04184f78880edb99918fc] # to [fea4ab58f66ad1998e570b0ed5b0615f2845a068] # # patch "test_merkle_dir.py" # from [27014de99955ad80cbc870a054f627800d8210bb] # to [8ffc5f896fd31c747a7f3bcd764e6890cb295528] # ======================================================================== --- merkle_dir.py 09d854914ad5a16e07d04184f78880edb99918fc +++ merkle_dir.py fea4ab58f66ad1998e570b0ed5b0615f2845a068 @@ -280,7 +280,7 @@ raise def pull(self, source, new_chunk_callback=None): - source.push(self, new_chunk_callback=new_chunk_callback) + source.push(self, new_chunk_callback) def sync(self, other, new_self_chunk_callback=None, new_other_chunk_callback=None): ======================================================================== --- test_merkle_dir.py 27014de99955ad80cbc870a054f627800d8210bb +++ test_merkle_dir.py 8ffc5f896fd31c747a7f3bcd764e6890cb295528 @@ -41,6 +41,15 @@ new[key] = val return new +class expecting_callback: + def __init__(self, in_source, in_target): + self.expected = new_in(in_source, in_target) + def __call__(self, id, data): + assert self.expected[id] == data + del self.expected[id] + def check_done(self): + assert len(self.expected) == 0 + def run_tests(): random.seed(0) @@ -81,13 +90,26 @@ verb = random.choice(["push", "pull", "sync", "nothing"]) print "%s(%s, %s)" % (verb, subject_name, object_name) if verb == "push": - subject.push(object) + new_in_subj_callback = expecting_callback(in_subject, + in_object) + subject.push(object, new_in_subj_callback) + new_in_subj_callback.check_done() in_object.update(in_subject) elif verb == "pull": - subject.pull(object) + new_in_obj_callback = expecting_callback(in_object, + in_subject) + subject.pull(object, new_in_obj_callback) + new_in_obj_callback.check_done() in_subject.update(in_object) elif verb == "sync": - subject.sync(object) + new_in_subj_callback = expecting_callback(in_subject, + in_object) + new_in_obj_callback = expecting_callback(in_object, + in_subject) + subject.sync(object, + new_in_obj_callback, new_in_subj_callback) + new_in_subj_callback.check_done() + new_in_obj_callback.check_done() in_subject.update(in_object) in_object.update(in_subject) elif verb == "nothing":