def test_get_all(self): print ("\n") log("Starting test") nr_items = 5 for i in range(nr_items): title = "Test get all %d" % i url = "Url %d" % i fm.add(title, url) all_items = fm.get_all() print str(all_items) self.assertEqual(len(all_items), nr_items)
def test_get_all(self): print("\n") log("Starting test") nr_items = 5 for i in range(nr_items): title = "Test get all %d" % i url = "Url %d" % i fm.add(title, url) all_items = fm.get_all() print str(all_items) self.assertEqual(len(all_items), nr_items)
def test_remove(self): print("\n") log("Starting test") #Add item title = "Test remove" url = "http://apa.com" fav_id = fm.add(title, url) self.assertIsNotNone(fm.get(fav_id), "Could not retrieve item!") # Remove item removed = fm.remove(fav_id) self.assertTrue(removed, "Item could not be removed!") self.assertIsNone(fm.get(fav_id), "Item is still in collection!")
def test_get(self): print("\n") log("Starting test") # Add item title = "Test get" url = "http://apa.com" fav_id = fm.add(title, url) # Get item fav_obj = fm.get(fav_id) self.assertIsNotNone(fav_obj, "Could not retrieve item!") fav_obj = None fav_obj = fm.get_by_title(title) self.assertIsNotNone(fav_obj, "Could not retrieve item!")
def test_remove(self): print ("\n") log("Starting test") # Add item title = "Test remove" url = "http://apa.com" fav_id = fm.add(title, url) self.assertIsNotNone(fm.get(fav_id), "Could not retrieve item!") # Remove item removed = fm.remove(fav_id) self.assertTrue(removed, "Item could not be removed!") self.assertIsNone(fm.get(fav_id), "Item is still in collection!")
def test_get(self): print ("\n") log("Starting test") # Add item title = "Test get" url = "http://apa.com" fav_id = fm.add(title, url) # Get item fav_obj = fm.get(fav_id) self.assertIsNotNone(fav_obj, "Could not retrieve item!") fav_obj = None fav_obj = fm.get_by_title(title) self.assertIsNotNone(fav_obj, "Could not retrieve item!")
def test_add(self): print("\n") log("Starting test") # Add item title = "Test add" url = "http://apa.com" fav_id = fm.add(title, url) # Check that item is in file file_handle = open(FILE_PATH, "r") lines = file_handle.readlines() file_handle.close() lines = "".join(lines) if not fav_id in lines: self.fail("Test object was not written to file!")
def test_add(self): print ("\n") log("Starting test") # Add item title = "Test add" url = "http://apa.com" fav_id = fm.add(title, url) # Check that item is in file file_handle = open(FILE_PATH, "r") lines = file_handle.readlines() file_handle.close() lines = "".join(lines) if not fav_id in lines: self.fail("Test object was not written to file!")
def viewFavorites(): favorites = FavoritesManager.get_all() for item in favorites: list_item = xbmcgui.ListItem(item["title"]) fm_script = "special://home/addons/plugin.video.svtplay/resources/lib/FavoritesManager.py" fm_action = "remove" list_item.addContextMenuItems( [(localize(30407), "XBMC.RunScript(" + fm_script + ", " + fm_action + ", " + item["id"] + ")")], replaceItems=True) params = {} params["url"] = item["url"] params["mode"] = MODE_PROGRAM xbmcplugin.addDirectoryItem( PLUGIN_HANDLE, sys.argv[0] + '?' + urllib.urlencode(params), list_item, True)
def viewFavorites(): favorites = FavoritesManager.get_all() for item in favorites: list_item = xbmcgui.ListItem(item["title"]) fm_script = "special://home/addons/plugin.video.svtplay/resources/lib/FavoritesManager.py" fm_action = "remove" list_item.addContextMenuItems( [ ( localize(30407), "XBMC.RunScript("+fm_script+", "+fm_action+", "+item["id"]+")" ) ], replaceItems=True) params = {} params["url"] = item["url"] params["mode"] = MODE_PROGRAM xbmcplugin.addDirectoryItem(PLUGIN_HANDLE, sys.argv[0] + '?' + urllib.urlencode(params), list_item, True)
def tearDown(self): log("Clear FM") fm.clear() if os.path.exists(FILE_PATH): log("Removing favorites file '%s'" % FILE_PATH) os.remove(FILE_PATH)