aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/parameters.json5
-rw-r--r--test/test_YoutubeDL.py4
-rw-r--r--test/test_compat.py23
-rw-r--r--test/test_utils.py27
4 files changed, 59 insertions, 0 deletions
diff --git a/test/parameters.json b/test/parameters.json
index 65fd54428..76c2a9ae7 100644
--- a/test/parameters.json
+++ b/test/parameters.json
@@ -35,6 +35,11 @@
"verbose": true,
"writedescription": false,
"writeinfojson": true,
+ "writeannotations": false,
+ "writelink": false,
+ "writeurllink": false,
+ "writewebloclink": false,
+ "writedesktoplink": false,
"writesubtitles": false,
"allsubtitles": false,
"listsubtitles": false,
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py
index a9e649191..5950dbffc 100644
--- a/test/test_YoutubeDL.py
+++ b/test/test_YoutubeDL.py
@@ -42,6 +42,7 @@ def _make_result(formats, **kwargs):
'title': 'testttitle',
'extractor': 'testex',
'extractor_key': 'TestEx',
+ 'webpage_url': 'http://example.com/watch?v=shenanigans',
}
res.update(**kwargs)
return res
@@ -567,6 +568,7 @@ class TestYoutubeDL(unittest.TestCase):
'subtitles': subtitles,
'automatic_captions': auto_captions,
'extractor': 'TEST',
+ 'webpage_url': 'http://example.com/watch?v=shenanigans',
}
def get_info(params={}):
@@ -730,6 +732,7 @@ class TestYoutubeDL(unittest.TestCase):
'playlist_id': '42',
'uploader': "變態妍字幕版 太妍 тест",
'creator': "тест ' 123 ' тест--",
+ 'webpage_url': 'http://example.com/watch?v=shenanigans',
}
second = {
'id': '2',
@@ -741,6 +744,7 @@ class TestYoutubeDL(unittest.TestCase):
'filesize': 5 * 1024,
'playlist_id': '43',
'uploader': "тест 123",
+ 'webpage_url': 'http://example.com/watch?v=SHENANIGANS',
}
videos = [first, second]
diff --git a/test/test_compat.py b/test/test_compat.py
index 8c49a001e..f66739bd4 100644
--- a/test/test_compat.py
+++ b/test/test_compat.py
@@ -19,6 +19,8 @@ from youtube_dlc.compat import (
compat_shlex_split,
compat_str,
compat_struct_unpack,
+ compat_urllib_parse_quote,
+ compat_urllib_parse_quote_plus,
compat_urllib_parse_unquote,
compat_urllib_parse_unquote_plus,
compat_urllib_parse_urlencode,
@@ -53,6 +55,27 @@ class TestCompat(unittest.TestCase):
dir(youtube_dlc.compat))) - set(['unicode_literals'])
self.assertEqual(all_names, sorted(present_names))
+ def test_compat_urllib_parse_quote(self):
+ self.assertEqual(compat_urllib_parse_quote('abc def'), 'abc%20def')
+ self.assertEqual(compat_urllib_parse_quote('/~user/abc+def'), '/%7Euser/abc%2Bdef')
+ self.assertEqual(compat_urllib_parse_quote('/~user/abc+def', safe='/~+'), '/~user/abc+def')
+ self.assertEqual(compat_urllib_parse_quote(''), '')
+ self.assertEqual(compat_urllib_parse_quote('%'), '%25')
+ self.assertEqual(compat_urllib_parse_quote('%', safe='%'), '%')
+ self.assertEqual(compat_urllib_parse_quote('津波'), '%E6%B4%A5%E6%B3%A2')
+ self.assertEqual(
+ compat_urllib_parse_quote('''<meta property="og:description" content="▁▂▃▄%▅▆▇█" />
+%<a href="https://ar.wikipedia.org/wiki/تسونامي">%a''', safe='<>=":%/ \r\n'),
+ '''<meta property="og:description" content="%E2%96%81%E2%96%82%E2%96%83%E2%96%84%%E2%96%85%E2%96%86%E2%96%87%E2%96%88" />
+%<a href="https://ar.wikipedia.org/wiki/%D8%AA%D8%B3%D9%88%D9%86%D8%A7%D9%85%D9%8A">%a''')
+ self.assertEqual(
+ compat_urllib_parse_quote('''(^◣_◢^)っ︻デ═一 ⇀ ⇀ ⇀ ⇀ ⇀ ↶%I%Break%25Things%''', safe='% '),
+ '''%28%5E%E2%97%A3_%E2%97%A2%5E%29%E3%81%A3%EF%B8%BB%E3%83%87%E2%95%90%E4%B8%80 %E2%87%80 %E2%87%80 %E2%87%80 %E2%87%80 %E2%87%80 %E2%86%B6%I%Break%25Things%''')
+
+ def test_compat_urllib_parse_quote_plus(self):
+ self.assertEqual(compat_urllib_parse_quote_plus('abc def'), 'abc+def')
+ self.assertEqual(compat_urllib_parse_quote_plus('~/abc def'), '%7E%2Fabc+def')
+
def test_compat_urllib_parse_unquote(self):
self.assertEqual(compat_urllib_parse_unquote('abc%20def'), 'abc def')
self.assertEqual(compat_urllib_parse_unquote('%7e/abc+def'), '~/abc+def')
diff --git a/test/test_utils.py b/test/test_utils.py
index 16ad40831..6562d443a 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -104,6 +104,7 @@ from youtube_dlc.utils import (
cli_valueless_option,
cli_bool_option,
parse_codecs,
+ iri_to_uri,
)
from youtube_dlc.compat import (
compat_chr,
@@ -1465,6 +1466,32 @@ Line 1
self.assertEqual(get_elements_by_attribute('class', 'foo', html), [])
self.assertEqual(get_elements_by_attribute('class', 'no-such-foo', html), [])
+ def test_iri_to_uri(self):
+ self.assertEqual(
+ iri_to_uri('https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8&client=firefox-b'),
+ 'https://www.google.com/search?q=foo&ie=utf-8&oe=utf-8&client=firefox-b') # Same
+ self.assertEqual(
+ iri_to_uri('https://www.google.com/search?q=Käsesoßenrührlöffel'), # German for cheese sauce stirring spoon
+ 'https://www.google.com/search?q=K%C3%A4seso%C3%9Fenr%C3%BChrl%C3%B6ffel')
+ self.assertEqual(
+ iri_to_uri('https://www.google.com/search?q=lt<+gt>+eq%3D+amp%26+percent%25+hash%23+colon%3A+tilde~#trash=?&garbage=#'),
+ 'https://www.google.com/search?q=lt%3C+gt%3E+eq%3D+amp%26+percent%25+hash%23+colon%3A+tilde~#trash=?&garbage=#')
+ self.assertEqual(
+ iri_to_uri('http://правозащита38.рф/category/news/'),
+ 'http://xn--38-6kcaak9aj5chl4a3g.xn--p1ai/category/news/')
+ self.assertEqual(
+ iri_to_uri('http://www.правозащита38.рф/category/news/'),
+ 'http://www.xn--38-6kcaak9aj5chl4a3g.xn--p1ai/category/news/')
+ self.assertEqual(
+ iri_to_uri('https://i❤.ws/emojidomain/👍👏🤝💪'),
+ 'https://xn--i-7iq.ws/emojidomain/%F0%9F%91%8D%F0%9F%91%8F%F0%9F%A4%9D%F0%9F%92%AA')
+ self.assertEqual(
+ iri_to_uri('http://日本語.jp/'),
+ 'http://xn--wgv71a119e.jp/')
+ self.assertEqual(
+ iri_to_uri('http://导航.中国/'),
+ 'http://xn--fet810g.xn--fiqs8s/')
+
if __name__ == '__main__':
unittest.main()