Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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!")
Esempio n. 4
0
    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!")
Esempio n. 5
0
    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!")
Esempio n. 6
0
    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!")
Esempio n. 7
0
 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!")
Esempio n. 8
0
 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!")
Esempio n. 9
0
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)
Esempio n. 10
0
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)
Esempio n. 11
0
 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)
Esempio n. 12
0
 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)