]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
0c3d0f51 | 2 | import os |
0c3d0f51 | 3 | import subprocess |
4 | import sys | |
5 | import unittest | |
f8271158 | 6 | |
0c3d0f51 | 7 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
8 | ||
b868936c | 9 | from test.helper import is_download_test, try_rm |
0c3d0f51 | 10 | |
0c3d0f51 | 11 | root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
e5a998f3 | 12 | download_file = os.path.join(root_dir, 'test.webm') |
0c3d0f51 | 13 | |
14 | ||
b868936c | 15 | @is_download_test |
0c3d0f51 | 16 | class TestOverwrites(unittest.TestCase): |
17 | def setUp(self): | |
18 | # create an empty file | |
19 | open(download_file, 'a').close() | |
20 | ||
21 | def test_default_overwrites(self): | |
22 | outp = subprocess.Popen( | |
23 | [ | |
7a5c1cfe | 24 | sys.executable, 'yt_dlp/__main__.py', |
0c3d0f51 | 25 | '-o', 'test.webm', |
26 | 'https://www.youtube.com/watch?v=jNQXAC9IVRw' | |
27 | ], cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
28 | sout, serr = outp.communicate() | |
29 | self.assertTrue(b'has already been downloaded' in sout) | |
30 | # if the file has no content, it has not been redownloaded | |
31 | self.assertTrue(os.path.getsize(download_file) < 1) | |
32 | ||
33 | def test_yes_overwrites(self): | |
34 | outp = subprocess.Popen( | |
35 | [ | |
7a5c1cfe | 36 | sys.executable, 'yt_dlp/__main__.py', '--yes-overwrites', |
0c3d0f51 | 37 | '-o', 'test.webm', |
38 | 'https://www.youtube.com/watch?v=jNQXAC9IVRw' | |
39 | ], cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
40 | sout, serr = outp.communicate() | |
41 | self.assertTrue(b'has already been downloaded' not in sout) | |
42 | # if the file has no content, it has not been redownloaded | |
43 | self.assertTrue(os.path.getsize(download_file) > 1) | |
44 | ||
45 | def tearDown(self): | |
e5a998f3 | 46 | try_rm(os.path.join(root_dir, 'test.webm')) |
0c3d0f51 | 47 | |
48 | ||
49 | if __name__ == '__main__': | |
50 | unittest.main() |