def test_99_pbm(self): from pbm.main import ChromiumBookmarks cb = ChromiumBookmarks(self.bookmarks_path) output = list(cb) self.assertTrue(output) output = cb.organize(dest=self.bookmarks_path + '.test99.bak', prompt=False) self.assertTrue(output) cb2 = ChromiumBookmarks(self.bookmarks_path + '.test99.bak') cbdict = cb2.bookmarks_dict queue_folders = [x for x in cbdict['roots']['bookmark_bar']['children'] if x.get('name') == 'queue'] self.assertEqual(len(queue_folders), 1, queue_folders) queue = queue_folders[0] max_node = None max_id = 0 for bm in iter(cb2): idstr = bm.get('id', 0) _id = long(idstr) if _id > max_id: max_id = _id max_node = bm self.assertGreaterEqual(queue['id'], max_id) # , max_node)
def test_97_pbm(self): from pbm.main import ChromiumBookmarks cb = ChromiumBookmarks(self.bookmarks_path) output = list(cb) self.assertTrue(output) output = cb.organize(dest=self.bookmarks_path + '.test97.bak', prompt=False) self.assertTrue(output)
def test_31_walk_bookmarks(self): from pbm.main import ChromiumBookmarks bookmarks = ChromiumBookmarks.read_bookmarks(self.bookmarks_path) self.assertTrue(bookmarks) bookmarks = itertools.chain( ChromiumBookmarks.walk_bookmarks( bookmarks['roots']['bookmark_bar']), ChromiumBookmarks.walk_bookmarks( bookmarks['roots']['other'])) self.check_bookmarks_list(bookmarks)
def test_51_rewrite_bookmarks(self): from pbm.main import ChromiumBookmarks bookmarks_dict = ChromiumBookmarks.transform_bookmarks_dict( bookmarks_path=self.bookmarks_path) bookmarks_json = ChromiumBookmarks._to_json(bookmarks_dict) ChromiumBookmarks.organize_bookmarks_json( bookmarks_json, self.bookmarks_path + '.test51.bak', prompt=False) output_json = json.dumps(bookmarks_dict, indent=2) self.assertTrue(json.loads(output_json), bookmarks_dict)
def test_41_reorganize_by_date(self): from pbm.main import ChromiumBookmarks bookmarks_obj = ChromiumBookmarks(bookmarks_path=self.bookmarks_path) self.assertTrue(bookmarks_obj) log.debug(self.bookmarks_path) bookmarks_list = bookmarks_obj.bookmarks_list self.assertTrue(bookmarks_list) import pbm.plugins.datefolders as dbf bookmarks_list = dbf.DateBasedFoldersPlugin.reorganize_by_date(bookmarks_obj) self.assertTrue(bookmarks_list) bookmarks_obj.bookmarks_dict['roots']['bookmark_bar']['children'] = ( bookmarks_list) json_output = bookmarks_obj.to_json() self.assertTrue(json_output) json_output = json.dumps(bookmarks_obj.bookmarks_dict, indent=2) self.assertTrue(json_output)
def test_33_iter_bookmarks(self): from pbm.main import ChromiumBookmarks bookmarks = list(ChromiumBookmarks.iter_bookmarks(self.bookmarks_path)) self.assertTrue(bookmarks)
def a_test_21_print_bookmarks(self): from pbm.main import ChromiumBookmarks bookmarks = ChromiumBookmarks.read_bookmarks(self.bookmarks_path) output = ChromiumBookmarks.print_bookmarks(bookmarks) self.assertTrue(output)
def test_11_read_bookmarks(self): from pbm.main import ChromiumBookmarks bookmarks = ChromiumBookmarks.read_bookmarks(self.bookmarks_path) self.assertTrue(bookmarks)