def test_v3_to_v4(self): # Setup paths. old_version = 3 new_version = 4 notebook_filename = setup_old_notebook(old_version, new_version) # Load old notebook. book = notebook_v3.NoteBook() book.load(notebook_filename) old_attrs = dict(book._attr) # Update notebook (in place). update.update_notebook(notebook_filename, new_version, verify=True) # Load new notebook. book = notebook_v4.NoteBook() book.load(notebook_filename) # Test for common error. self.assertEqual(book.get_title(), old_attrs['title'])
# Clear out old index. index_file = os.path.join(notebook.get_pref_dir(), "index.sqlite") if os.path.exists(index_file): os.remove(index_file) # Write new preferences. notebook_v3.write_new_preferences(notebook.pref, notebook.get_pref_file()) notebook.close() version = 4 # upgrade 4 --> 5 elif version == 4: from keepnote.compat import notebook_v4 # try to load old notebook (may raise exceptions) notebook = notebook_v4.NoteBook() notebook.load(filename) notebook.pref.set("version", 5) notebook.save(force=True) #if notebook.index_needed(): # notebook.clear_index() notebook.close() version = 5 elif version == 5: notebook_update_v5_6.update(filename) version = 6