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