Exemplo n.º 1
0
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
Exemplo n.º 2
0
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&amp;feature=plpp_video&amp;ved'
        '=CCYQxjQYACITCO33n5-pn-cCFUG3xAodLogN2yj6LA\\">}", "load_more_widget_html":""}',
        "{}",
    ]
    playlist = Playlist(url)
    assert len(list(playlist.trimmed("wont-be-found"))) == 101