diff options
author | remitamine <[email protected]> | 2016-03-03 18:40:05 +0100 |
---|---|---|
committer | remitamine <[email protected]> | 2016-03-03 18:40:05 +0100 |
commit | fb640d0a3d3af77e6835d9a6a2bf80920785511a (patch) | |
tree | d4b5d8a53d421ac52d08b4a77c9fb2bf46be4ee1 /test | |
parent | 38f9ef31dc434a6702686844b421085955137c55 (diff) | |
download | youtube-dl-fb640d0a3d3af77e6835d9a6a2bf80920785511a.tar.gz youtube-dl-fb640d0a3d3af77e6835d9a6a2bf80920785511a.zip |
[test/test_utils] add tests for update_url_query
Diffstat (limited to 'test')
-rw-r--r-- | test/test_utils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py index 97587ad2f..19a546619 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -61,6 +61,7 @@ from youtube_dl.utils import ( lowercase_escape, url_basename, urlencode_postdata, + update_url_query, version_tuple, xpath_with_ns, xpath_element, @@ -76,6 +77,8 @@ from youtube_dl.utils import ( ) from youtube_dl.compat import ( compat_etree_fromstring, + compat_urlparse, + compat_parse_qs, ) @@ -454,6 +457,31 @@ class TestUtil(unittest.TestCase): data = urlencode_postdata({'username': '[email protected]', 'password': '1234'}) self.assertTrue(isinstance(data, bytes)) + def test_update_url_query(self): + def query_dict(url): + return compat_parse_qs(compat_urlparse.urlparse(url).query) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path', {'quality': ['HD'], 'format': ['mp4']})), + query_dict('http://example.com/path?quality=HD&format=mp4')) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path', {'system': ['LINUX', 'WINDOWS']})), + query_dict('http://example.com/path?system=LINUX&system=WINDOWS')) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path', {'fields': 'id,formats,subtitles'})), + query_dict('http://example.com/path?fields=id,formats,subtitles')) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path', {'fields': ('id,formats,subtitles', 'thumbnails')})), + query_dict('http://example.com/path?fields=id,formats,subtitles&fields=thumbnails')) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path?manifest=f4m', {'manifest': []})), + query_dict('http://example.com/path')) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path?system=LINUX&system=WINDOWS', {'system': 'LINUX'})), + query_dict('http://example.com/path?system=LINUX')) + self.assertEqual(query_dict(update_url_query( + 'http://example.com/path', {'fields': b'id,formats,subtitles'})), + query_dict('http://example.com/path?fields=id,formats,subtitles')) + def test_dict_get(self): FALSE_VALUES = { 'none': None, |