tests for trimmed with pagination
Browse files
tests/contrib/test_playlist.py
CHANGED
@@ -158,3 +158,30 @@ def test_playlist_pagination(request_get, playlist_html, playlist_long_html):
|
|
158 |
playlist = Playlist(url)
|
159 |
assert len(playlist.video_urls) == 101
|
160 |
assert request_get.call_count == 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
playlist = Playlist(url)
|
159 |
assert len(playlist.video_urls) == 101
|
160 |
assert request_get.call_count == 2
|
161 |
+
|
162 |
+
|
163 |
+
@mock.patch("pytube.contrib.playlist.request.get")
|
164 |
+
def test_trimmed_pagination(request_get, playlist_html, playlist_long_html):
|
165 |
+
url = "https://www.fakeurl.com/playlist?list=whatever"
|
166 |
+
request_get.side_effect = [
|
167 |
+
playlist_long_html,
|
168 |
+
'{"content_html":"<a href=\\"/watch?v=BcWz41-4cDk&feature=plpp_video&ved'
|
169 |
+
'=CCYQxjQYACITCO33n5-pn-cCFUG3xAodLogN2yj6LA\\">}", "load_more_widget_html":""}',
|
170 |
+
"{}",
|
171 |
+
]
|
172 |
+
playlist = Playlist(url)
|
173 |
+
assert len(list(playlist.trimmed("FN9vC8aR7Yk"))) == 3
|
174 |
+
assert request_get.call_count == 1
|
175 |
+
|
176 |
+
|
177 |
+
@mock.patch("pytube.contrib.playlist.request.get")
|
178 |
+
def test_trimmed_pagination_not_found(request_get, playlist_html, playlist_long_html):
|
179 |
+
url = "https://www.fakeurl.com/playlist?list=whatever"
|
180 |
+
request_get.side_effect = [
|
181 |
+
playlist_long_html,
|
182 |
+
'{"content_html":"<a href=\\"/watch?v=BcWz41-4cDk&feature=plpp_video&ved'
|
183 |
+
'=CCYQxjQYACITCO33n5-pn-cCFUG3xAodLogN2yj6LA\\">}", "load_more_widget_html":""}',
|
184 |
+
"{}",
|
185 |
+
]
|
186 |
+
playlist = Playlist(url)
|
187 |
+
assert len(list(playlist.trimmed("wont-be-found"))) == 101
|