Skip to content
Snippets Groups Projects
Commit 64fe38e8 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Create Video: mock platform.system() to test both Windows and Linux

Windows is not POSIX-compliant, and as a result ffmpeg does not support
the `-pattern_type glob` CLI argument.
parent ef68b294
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import shlex ...@@ -7,6 +7,7 @@ import shlex
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
from unittest import mock
from tests.test_runner import AbstractCommandTest from tests.test_runner import AbstractCommandTest
...@@ -45,25 +46,39 @@ class CreateVideoTest(AbstractCommandTest): ...@@ -45,25 +46,39 @@ class CreateVideoTest(AbstractCommandTest):
self.assertEqual(['ffmpeg'], settings['ffmpeg_cmd'], self.assertEqual(['ffmpeg'], settings['ffmpeg_cmd'],
'The default setting should be stored in the dict after validation') 'The default setting should be stored in the dict after validation')
def test_build_ffmpeg_cmd(self): def test_build_ffmpeg_cmd_windows(self):
self.cmd.validate(self.settings) self.cmd.validate(self.settings)
cliargs = self.cmd._build_ffmpeg_command(self.settings)
with mock.patch('platform.system') as mock_system:
if platform.system() == 'Windows': mock_system.return_value = 'Windows'
input_args = [ cliargs = self.cmd._build_ffmpeg_command(self.settings)
'-f', 'concat',
'-i', Path(self.settings['input_files']).absolute().with_name('ffmpeg-input.txt').as_posix(), self.assertEqual([
] Path(sys.executable).absolute().as_posix(), '-hide_banner',
else: '-r', '24',
input_args = [ '-f', 'concat',
'-pattern_type', 'glob', '-i', Path(self.settings['input_files']).absolute().with_name('ffmpeg-input.txt').as_posix(),
'-i', '/tmp/*.png', '-c:v', 'h264',
] '-crf', '23',
'-g', '18',
'-vf', 'pad=ceil(iw/2)*2:ceil(ih/2)*2',
'-y',
'-bf', '0',
'/tmp/merged.mkv',
], cliargs)
def test_build_ffmpeg_cmd_linux(self):
self.cmd.validate(self.settings)
with mock.patch('platform.system') as mock_system:
mock_system.return_value = 'Linux'
cliargs = self.cmd._build_ffmpeg_command(self.settings)
self.assertEqual([ self.assertEqual([
Path(sys.executable).absolute().as_posix(), '-hide_banner', Path(sys.executable).absolute().as_posix(), '-hide_banner',
'-r', '24', '-r', '24',
*input_args, '-pattern_type', 'glob',
'-i', '/tmp/*.png',
'-c:v', 'h264', '-c:v', 'h264',
'-crf', '23', '-crf', '23',
'-g', '18', '-g', '18',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment