ahmedsadman
commited on
Commit
·
b49425d
1
Parent(s):
946cd32
added playlist unit-test
Browse files- tests/test_playlist.py +37 -0
tests/test_playlist.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
import pytest
|
3 |
+
from pytube import playlist
|
4 |
+
|
5 |
+
|
6 |
+
def test_construct():
|
7 |
+
ob = playlist.Playlist(
|
8 |
+
"https://www.youtube.com/watch?v=m5q2GCsteQs&list="
|
9 |
+
"PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw")
|
10 |
+
expected = "https://www.youtube.com/" \
|
11 |
+
"playlist?list=" \
|
12 |
+
"PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw"
|
13 |
+
|
14 |
+
assert ob.construct_playlist_url() == expected
|
15 |
+
|
16 |
+
|
17 |
+
def test_link_parse():
|
18 |
+
ob = playlist.Playlist(
|
19 |
+
"https://www.youtube.com/watch?v=m5q2GCsteQs&list="
|
20 |
+
"PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw")
|
21 |
+
|
22 |
+
expected = ["/watch?v=m5q2GCsteQs",
|
23 |
+
"/watch?v=5YK63cXyJ2Q",
|
24 |
+
"/watch?v=Rzt4rUPFYD4"]
|
25 |
+
assert ob.parse_links() == expected
|
26 |
+
|
27 |
+
|
28 |
+
def test_populate():
|
29 |
+
ob = playlist.Playlist(
|
30 |
+
"https://www.youtube.com/watch?v=m5q2GCsteQs&list="
|
31 |
+
"PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw")
|
32 |
+
expected = ["https://www.youtube.com/watch?v=m5q2GCsteQs",
|
33 |
+
"https://www.youtube.com/watch?v=5YK63cXyJ2Q",
|
34 |
+
"https://www.youtube.com/watch?v=Rzt4rUPFYD4"]
|
35 |
+
|
36 |
+
ob.populate_video_urls()
|
37 |
+
assert ob.video_urls == expected
|