def test_error(): diff(patch_file, orig_dir, new_dir) # Invalid patched dir try: patch(patch_file, bad_orig_dir, tmp_dir) except InvalidOriginalFile, e: str(e) pass
def test_basic(): def dummy_start(stage, length): pass def dummy_progress(index): pass diff(patch_file, orig_dir, new_dir) patch(patch_file, orig_dir, tmp_dir, dummy_start, dummy_progress) compare_directories(new_dir, tmp_dir)
def _download_finished(self): self.file.close() self.patches_paths.append(self.save_path) if self.download_queue: # Start next download self._download_next() else: # All has been downloaded old_dir = self.patch_target_dir # Create target directory(ies) new_dir = old_dir + "_" while isdir(new_dir): new_dir += "_" os.mkdir(new_dir) if len(self.patches_paths) > 1: new_dir2 = new_dir + "_" while isdir(new_dir2): new_dir2 += "_" os.mkdir(new_dir2) # Apply patches, starting from original dir to new_dir, then # cycling between new_dir and new_dir2 d1 = old_dir d2 = new_dir for patch_index, path in enumerate(self.patches_paths): if patch_index == 1: d1 = new_dir d2 = new_dir2 elif patch_index > 1: d1, d2 = d2, d1 start_cb, progress_cb = self._patch_callbacks(path, patch_index, len(self.patches_paths)) patch(path, d1, d2, start_cb, progress_cb) # Remove middle-temp dir if we used more than one temp dir if d1 != old_dir: shutil.rmtree(d1) # Remove patch files for path in self.patches_paths: os.unlink(path) # Finish update and quit louie.send(signals.update_finished, self, d2) self._exit(0)
def test_new_files(): diff(patch_file, orig_dir, new_dir) patch(patch_file, orig_with_new_dir, tmp_dir) assert isfile(join(tmp_dir, "new_file")) assert isfile(join(tmp_dir, "new_dir", "new_file_2"))
assert isfile(join(tmp_dir, "new_dir", "new_file_2")) def test_error(): diff(patch_file, orig_dir, new_dir) # Invalid patched dir try: patch(patch_file, bad_orig_dir, tmp_dir) except InvalidOriginalFile, e: str(e) pass else: raise AssertionError("InvalidOriginalFile not raised") # Invalid patch file try: patch(bad_patch_file, orig_dir, tmp_dir) except InvalidResultingFile: pass else: raise AssertionError("InvalidResultingFile not raised") # Incompatible patch file try: patch(incompatible_patch_file, orig_dir, tmp_dir) except IncompatiblePatchFormat: pass else: raise AssertionError("IncompatiblePatchFormat not raised") def test_version(): version_groups = [[