GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
2
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
process_podcast
Browse code
Removed inadvertent maxDiff setting (ref #31).
master
1 parent
298d5b1
commit
891857d618e2d92c85c8f4d0af5ebfaac3a147ed
Nigel Stanger
authored
on 20 Sep 2018
Patch
Showing
2 changed files
test_ffmpeg_command.py
test_ffprobe_command.py
Ignore Space
Show notes
View
test_ffmpeg_command.py
import shutil from pathlib import Path import tempfile import unittest from shell_command import ( ShellCommand, FFmpegCommand ) class TestFFmpegCommand(unittest.TestCase): """Test the FFmpegCommand class. """ def setUp(self): """Initialisation. Make sure the input and output options are explicitly set otherwise they hang around from previous tests. A fresh temporary file is created for each test. """ self.command = FFmpegCommand( input_options=["-i", "in.mov"], output_options=["out.mov"]) self.expected_executable = shutil.which("ffmpeg") self.expected_base_options = ["-y", "-nostdin",] self.expected_input_options = ["-i", "in.mov"] self.expected_output_options = ["out.mov"] def tearDown(self): """Cleanup. """ self.command = None def test_base_options(self): """Test that base options match expected. """ self.assertEqual( self.command._base_options, self.expected_base_options) def test_input_options(self): """Test that input options match expected. """ self.assertEqual( self.command.input_options, self.expected_input_options) def test_output_options(self): """Test that output options match expected. """ self.assertEqual( self.command.output_options, self.expected_output_options) def test_executable_string(self): """Test that executable path matches expected. """ self.assertEqual(self.command.executable_string(quote=False), self.expected_executable) # Note: don't explicitly specify quoted value, because # the executable path will vary across different systems. self.assertEqual(self.command.executable_string(quote=True), ShellCommand.shellquote(self.expected_executable)) def test_argument_string(self): """Test that the argument string matches expected. """ args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) self.assertEqual(self.command.argument_string(quote=False), " ".join(args)) self.assertEqual(self.command.argument_string(quote=True), " ".join([ShellCommand.shellquote(a) for a in args])) def test_argument_list(self): """Test that the argument list matches expected. """ self.assertEqual(self.command.argument_list(), self.expected_base_options + self.expected_input_options + self.expected_output_options) def test_command_string(self): """Test that the command string matches expected. """ args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) expected_cmd_unquoted = ( "{exe} {arg}".format(exe=self.expected_executable, arg=" ".join(args)) ) expected_cmd_quoted = ( '{exe} {arg}'.format( exe=ShellCommand.shellquote(self.expected_executable), arg=" ".join([ShellCommand.shellquote(a) for a in args])) ) self.assertEqual(self.command.command_string(quote=False), expected_cmd_unquoted) self.assertEqual(self.command.command_string(quote=True), expected_cmd_quoted)
import shutil from pathlib import Path import tempfile import unittest from shell_command import ( ShellCommand, FFmpegCommand ) class TestFFmpegCommand(unittest.TestCase): """Test the FFmpegCommand class. """ def setUp(self): """Initialisation. Make sure the input and output options are explicitly set otherwise they hang around from previous tests. A fresh temporary file is created for each test. """ self.command = FFmpegCommand( input_options=["-i", "in.mov"], output_options=["out.mov"]) self.expected_executable = shutil.which("ffmpeg") self.expected_base_options = ["-y", "-nostdin",] self.expected_input_options = ["-i", "in.mov"] self.expected_output_options = ["out.mov"] def tearDown(self): """Cleanup. """ self.command = None def test_base_options(self): """Test that base options match expected. """ self.assertEqual( self.command._base_options, self.expected_base_options) def test_input_options(self): """Test that input options match expected. """ self.assertEqual( self.command.input_options, self.expected_input_options) def test_output_options(self): """Test that output options match expected. """ self.assertEqual( self.command.output_options, self.expected_output_options) def test_executable_string(self): """Test that executable path matches expected. """ self.assertEqual(self.command.executable_string(quote=False), self.expected_executable) # Note: don't explicitly specify quoted value, because # the executable path will vary across different systems. self.assertEqual(self.command.executable_string(quote=True), ShellCommand.shellquote(self.expected_executable)) def test_argument_string(self): """Test that the argument string matches expected. """ self.maxDiff = None args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) self.assertEqual(self.command.argument_string(quote=False), " ".join(args)) self.assertEqual(self.command.argument_string(quote=True), " ".join([ShellCommand.shellquote(a) for a in args])) def test_argument_list(self): """Test that the argument list matches expected. """ self.assertEqual(self.command.argument_list(), self.expected_base_options + self.expected_input_options + self.expected_output_options) def test_command_string(self): """Test that the command string matches expected. """ args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) expected_cmd_unquoted = ( "{exe} {arg}".format(exe=self.expected_executable, arg=" ".join(args)) ) expected_cmd_quoted = ( '{exe} {arg}'.format( exe=ShellCommand.shellquote(self.expected_executable), arg=" ".join([ShellCommand.shellquote(a) for a in args])) ) self.assertEqual(self.command.command_string(quote=False), expected_cmd_unquoted) self.assertEqual(self.command.command_string(quote=True), expected_cmd_quoted)
Ignore Space
Show notes
View
test_ffprobe_command.py
import shutil from pathlib import Path import tempfile import unittest from shell_command import ( ShellCommand, FFprobeCommand ) class TestFFprobeCommand(unittest.TestCase): """Test the FFprobeCommand class. """ def setUp(self): """Initialisation. Make sure the input and output options are explicitly set otherwise they hang around from previous tests. A fresh temporary file is created for each test. """ self.tmpfile = tempfile.NamedTemporaryFile() self.command = FFprobeCommand( input_options=["-i", self.tmpfile.name], output_options=[]) self.expected_executable = shutil.which("ffprobe") self.expected_base_options = [ "-loglevel", "error", "-show_entries", "format:stream", "-print_format", "json", ] self.expected_input_options = ["-i", self.tmpfile.name] self.expected_output_options = [] def tearDown(self): """Cleanup. """ self.tmpfile.close() self.command = None def test_base_options(self): """Test that base options match expected. """ self.assertEqual( self.command._base_options, self.expected_base_options) def test_input_options(self): """Test that input options match expected. """ self.assertEqual( self.command.input_options, self.expected_input_options) def test_output_options(self): """Test that output options match expected. """ self.assertEqual( self.command.output_options, self.expected_output_options) def test_executable_string(self): """Test that executable path matches expected. """ self.assertEqual(self.command.executable_string(quote=False), self.expected_executable) # Note: don't explicitly specify quoted value, because # the executable path will vary across different systems. self.assertEqual(self.command.executable_string(quote=True), ShellCommand.shellquote(self.expected_executable)) def test_argument_string(self): """Test that the argument string matches expected. """ args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) self.assertEqual(self.command.argument_string(quote=False), " ".join(args)) self.assertEqual(self.command.argument_string(quote=True), " ".join([ShellCommand.shellquote(a) for a in args])) def test_argument_list(self): """Test that the argument list matches expected. """ self.assertEqual(self.command.argument_list(), self.expected_base_options + self.expected_input_options + self.expected_output_options) def test_command_string(self): """Test that the command string matches expected. """ args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) expected_cmd_unquoted = ( "{exe} {arg}".format(exe=self.expected_executable, arg=" ".join(args)) ) expected_cmd_quoted = ( '{exe} {arg}'.format( exe=ShellCommand.shellquote(self.expected_executable), arg=" ".join([ShellCommand.shellquote(a) for a in args])) ) self.assertEqual(self.command.command_string(quote=False), expected_cmd_unquoted) self.assertEqual(self.command.command_string(quote=True), expected_cmd_quoted) def test_last_modified(self): """Test that last modified time matches tmpfile on disk. """ self.assertEqual( self.command.last_modified, Path(self.tmpfile.name).stat().st_mtime) # get_entries()?
import shutil from pathlib import Path import tempfile import unittest from shell_command import ( ShellCommand, FFprobeCommand ) class TestFFprobeCommand(unittest.TestCase): """Test the FFprobeCommand class. """ def setUp(self): """Initialisation. Make sure the input and output options are explicitly set otherwise they hang around from previous tests. A fresh temporary file is created for each test. """ self.tmpfile = tempfile.NamedTemporaryFile() self.command = FFprobeCommand( input_options=["-i", self.tmpfile.name], output_options=[]) self.expected_executable = shutil.which("ffprobe") self.expected_base_options = [ "-loglevel", "error", "-show_entries", "format:stream", "-print_format", "json", ] self.expected_input_options = ["-i", self.tmpfile.name] self.expected_output_options = [] def tearDown(self): """Cleanup. """ self.tmpfile.close() self.command = None def test_base_options(self): """Test that base options match expected. """ self.assertEqual( self.command._base_options, self.expected_base_options) def test_input_options(self): """Test that input options match expected. """ self.assertEqual( self.command.input_options, self.expected_input_options) def test_output_options(self): """Test that output options match expected. """ self.assertEqual( self.command.output_options, self.expected_output_options) def test_executable_string(self): """Test that executable path matches expected. """ self.assertEqual(self.command.executable_string(quote=False), self.expected_executable) # Note: don't explicitly specify quoted value, because # the executable path will vary across different systems. self.assertEqual(self.command.executable_string(quote=True), ShellCommand.shellquote(self.expected_executable)) def test_argument_string(self): """Test that the argument string matches expected. """ self.maxDiff = None args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) self.assertEqual(self.command.argument_string(quote=False), " ".join(args)) self.assertEqual(self.command.argument_string(quote=True), " ".join([ShellCommand.shellquote(a) for a in args])) def test_argument_list(self): """Test that the argument list matches expected. """ self.assertEqual(self.command.argument_list(), self.expected_base_options + self.expected_input_options + self.expected_output_options) def test_command_string(self): """Test that the command string matches expected. """ args = (self.expected_base_options + self.expected_input_options + self.expected_output_options) expected_cmd_unquoted = ( "{exe} {arg}".format(exe=self.expected_executable, arg=" ".join(args)) ) expected_cmd_quoted = ( '{exe} {arg}'.format( exe=ShellCommand.shellquote(self.expected_executable), arg=" ".join([ShellCommand.shellquote(a) for a in args])) ) self.assertEqual(self.command.command_string(quote=False), expected_cmd_unquoted) self.assertEqual(self.command.command_string(quote=True), expected_cmd_quoted) def test_last_modified(self): """Test that last modified time matches tmpfile on disk. """ self.assertEqual( self.command.last_modified, Path(self.tmpfile.name).stat().st_mtime) # get_entries()?
Show line notes below