hbmartin commited on
Commit
516b351
·
1 Parent(s): d156421

more pagination testing

Browse files
.flake8 CHANGED
@@ -1,3 +1,3 @@
1
  [flake8]
2
  ignore = E231,E203,W503
3
- max-line-length = 88
 
1
  [flake8]
2
  ignore = E231,E203,W503
3
+ max-line-length = 89
tests/contrib/test_playlist.py CHANGED
@@ -130,7 +130,7 @@ def test_trimmed(request_get, playlist_html):
130
 
131
 
132
  @mock.patch("pytube.contrib.playlist.request.get")
133
- def test_playlist_pagination(request_get, playlist_long_html):
134
  url = "https://www.fakeurl.com/playlist?list=whatever"
135
  request_get.side_effect = [
136
  playlist_long_html,
@@ -144,3 +144,17 @@ def test_playlist_pagination(request_get, playlist_long_html):
144
  "https://www.youtube.com/browse_ajax?action_continuation=1&continuation"
145
  "=4qmFsgIsEhpWTFVVYS12aW9HaGUyYnRCY1puZWFQb25LQRoOZWdaUVZEcERSMUUlM0Q%253D"
146
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
 
132
  @mock.patch("pytube.contrib.playlist.request.get")
133
+ def test_playlist_failed_pagination(request_get, playlist_long_html):
134
  url = "https://www.fakeurl.com/playlist?list=whatever"
135
  request_get.side_effect = [
136
  playlist_long_html,
 
144
  "https://www.youtube.com/browse_ajax?action_continuation=1&continuation"
145
  "=4qmFsgIsEhpWTFVVYS12aW9HaGUyYnRCY1puZWFQb25LQRoOZWdaUVZEcERSMUUlM0Q%253D"
146
  )
147
+
148
+
149
+ @mock.patch("pytube.contrib.playlist.request.get")
150
+ def test_playlist_pagination(request_get, playlist_html, playlist_long_html):
151
+ url = "https://www.fakeurl.com/playlist?list=whatever"
152
+ request_get.side_effect = [
153
+ playlist_long_html,
154
+ '{"content_html":"<a href=\\"/watch?v=BcWz41-4cDk&amp;feature=plpp_video&amp;ved'
155
+ '=CCYQxjQYACITCO33n5-pn-cCFUG3xAodLogN2yj6LA\\">}", "load_more_widget_html":""}',
156
+ "{}",
157
+ ]
158
+ playlist = Playlist(url)
159
+ assert len(playlist.video_urls) == 101
160
+ assert request_get.call_count == 2
tests/mocks/playlist_long.html.gz ADDED
Binary file (47.7 kB). View file