about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-10-21 13:19:58 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-10-21 13:19:58 +0200
commita9c58ad945e88e8eadbbff9c165c19b46805063b (patch)
treecb89e6ca2e09bcfca95d53511df8811b68e5366e /test
parentf8b45beacccbc5c237b0a04a568b51d602b1c1d3 (diff)
downloadyoutube-dl-a9c58ad945e88e8eadbbff9c165c19b46805063b.tar.gz
youtube-dl-a9c58ad945e88e8eadbbff9c165c19b46805063b.tar.xz
youtube-dl-a9c58ad945e88e8eadbbff9c165c19b46805063b.zip
Accept requested formats to be in the format 35/best (closes #1552)
The format selection code is now an independent function.
Diffstat (limited to 'test')
-rw-r--r--test/test_YoutubeDL.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py
index ba6dc05bc..2073bc4df 100644
--- a/test/test_YoutubeDL.py
+++ b/test/test_YoutubeDL.py
@@ -94,6 +94,29 @@ class TestFormatSelection(unittest.TestCase):
         downloaded = ydl.downloaded_info_dicts[0]
         self.assertEqual(downloaded[u'format_id'], u'excellent')
 
+    def test_format_selection(self):
+        formats = [
+            {u'format_id': u'35'},
+            {u'format_id': u'47'},
+            {u'format_id': u'2'},
+        ]
+        info_dict = {u'formats': formats, u'extractor': u'test'}
+
+        ydl = YDL({'format': u'20/47'})
+        ydl.process_ie_result(info_dict)
+        downloaded = ydl.downloaded_info_dicts[0]
+        self.assertEqual(downloaded['format_id'], u'47')
+
+        ydl = YDL({'format': u'20/71/worst'})
+        ydl.process_ie_result(info_dict)
+        downloaded = ydl.downloaded_info_dicts[0]
+        self.assertEqual(downloaded['format_id'], u'35')
+
+        ydl = YDL()
+        ydl.process_ie_result(info_dict)
+        downloaded = ydl.downloaded_info_dicts[0]
+        self.assertEqual(downloaded['format_id'], u'2')
+
 
 if __name__ == '__main__':
     unittest.main()