def test_actionView_standalone_episodes(request, main, actionView_standalone_episodes, xbmcgui, xbmcplugin): main() item = actionView_without_seasons_response["item"] for video in item["videos"]: episode_title = "e{:02d}".format(video["number"]) if video["title"]: episode_title = "{} | {}".format(episode_title, video["title"].encode("utf-8")) link = plugin.format("play?{}".format( urlencode({ "id": item["id"], "title": episode_title, "number": video["number"], "video": json.dumps(video) }))) xbmcgui.ListItem.assert_any_call(episode_title, iconImage=video["thumbnail"], thumbnailImage=video["thumbnail"]) li = xbmcgui.ListItem() li.setInfo.assert_any_call("Video", {"playcount": video["watched"]}) li.setArt.assert_any_call({"poster": item["posters"]["big"]}) li.setProperty.assert_any_call("IsPlayable", "true") xbmcplugin.addDirectoryItem.assert_any_call(handle, link, xbmcgui.ListItem(), False) xbmcplugin.setContent.assert_called_once_with(handle, "episodes") xbmcplugin.endOfDirectory.assert_called_once_with(handle)
def test_actionIndex(mocker, actionIndex, main, xbmcplugin, xbmcgui): main() c = u"[COLOR FFFFF000]{}[/COLOR]" expected_results = [ (handle, plugin.format("search"), c.format(u"Поиск"), False), (handle, plugin.format("items"), c.format(u"Последние"), True), (handle, plugin.format("items?sort=-rating"), c.format(u"Популярные"), True), (handle, plugin.format("tv"), c.format(u"ТВ"), True), (handle, plugin.format("bookmarks"), c.format(u"Закладки"), True), (handle, plugin.format("watching"), c.format(u"Я смотрю"), True), (handle, plugin.format("collections"), c.format(u"Подборки"), True), (handle, plugin.format("index?type=movie"), u"Фильмы", True), (handle, plugin.format("index?type=serial"), u"Сериалы", True), (handle, plugin.format("index?type=tvshow"), u"ТВ шоу", True), (handle, plugin.format("index?type=4k"), u"4K", True), (handle, plugin.format("index?type=3d"), u"3D", True), (handle, plugin.format("index?type=concert"), u"Концерты", True), (handle, plugin.format("index?type=documovie"), u"Документальные фильмы", True), (handle, plugin.format("index?type=docuserial"), u"Документальные сериалы", True) ] for result in expected_results: handle_, link, title, is_directory = result xbmcgui.ListItem.assert_any_call(title.encode("utf-8")) li = xbmcgui.ListItem() xbmcplugin.addDirectoryItem.assert_any_call(handle_, link, li, is_directory) xbmcplugin.endOfDirectory.assert_called_once_with(handle)
def test_actionItems(main, actionItems, xbmcgui, xbmcplugin): main() s = plugin i = [item["id"] for item in actionItems_response["items"]] t = [ item["title"].encode("utf-8") for item in actionItems_response["items"] ] expected_results = [ (handle, s.format("play?{}".format(urlencode({ "id": i[0], "title": t[0] }))), t[0], False), (handle, s.format("play?{}".format(urlencode({ "id": i[1], "title": t[1] }))), t[1], False), (handle, s.format("view?id={}".format(i[2])), t[2], True), (handle, s.format("view?id={}".format(i[3])), t[3], True), (handle, s.format("view?id={}".format(i[4])), t[4], True) ] for result in expected_results: handle_, link, title, is_directory = result xbmcgui.ListItem.assert_any_call(title) li = xbmcgui.ListItem() xbmcplugin.addDirectoryItem.assert_any_call(handle_, link, li, is_directory) xbmcplugin.endOfDirectory.assert_called_once_with(handle)
def test_actionPlay(actionPlay, main, xbmcgui, xbmcplugin): stream, video_quality = actionPlay main() title = actionPlay_response["item"]["title"].encode("utf-8") xbmcgui.ListItem.assert_called_with(title) li = xbmcgui.ListItem(title) link = "https://example.com/{}/{}".format(stream, video_quality.rstrip("p")) li.setPath.assert_called_once_with(link) xbmcplugin.setResolvedUrl.assert_called_once_with(handle, True, li)
def test_actionView_seasons(main, actionView_seasons, xbmcgui, xbmcplugin): main() i = actionView_seasons_response["item"]["id"] seasons = actionView_seasons_response["item"]["seasons"] for season in seasons: xbmcgui.ListItem.assert_any_call("Сезон {}".format(season["number"])) link = plugin.format("view_season_episodes?season={}&id={}".format( season["number"], i)) xbmcplugin.addDirectoryItem.assert_any_call(handle, link, xbmcgui.ListItem(), True) xbmcplugin.endOfDirectory.assert_called_once_with(handle)