def test_trimmed(request_get, playlist_html): url = "https://www.fakeurl.com/playlist?list=whatever" request_get.return_value = playlist_html playlist = Playlist(url) trimmed = list(playlist.trimmed("1BYu65vLKdA")) assert trimmed == [ "https://www.youtube.com/watch?v=ujTCoH21GlA", "https://www.youtube.com/watch?v=45ryDIPHdGg", ] assert request_get.call_count == 1
def test_trimmed_pagination_not_found(request_get, playlist_html, playlist_long_html): url = "https://www.fakeurl.com/playlist?list=whatever" request_get.side_effect = [ playlist_long_html, '{"content_html":"<a href=\\"/watch?v=BcWz41-4cDk&feature=plpp_video&ved' '=CCYQxjQYACITCO33n5-pn-cCFUG3xAodLogN2yj6LA\\">}", "load_more_widget_html":""}', "{}", ] playlist = Playlist(url) assert len(list(playlist.trimmed("wont-be-found"))) == 101