FFmpeg Handling CI / test (push) Successful in 49s
FFmpeg Handling CI / lint (push) Successful in 8s
FFmpeg Handling CI / build (push) Skipped
FFmpeg Handling CI / install (quiethost) (push) Skipped
FFmpeg Handling CI / install (serverhost) (push) Skipped
FFmpeg Handling CI / install (vivohost) (push) Skipped
Wallpaper Changer CI / test-wallpaper-changer (push) Successful in 22s
Wallpaper Changer CI / build (push) Skipped
Wallpaper Changer CI / install (quiethost) (push) Skipped
Wallpaper Changer CI / install (serverhost) (push) Skipped
Wallpaper Changer CI / install (vivohost) (push) Skipped
Wallpaper Changer CI / lint-wallpaper-changer (push) Failing after 8s
61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
from ffmpeg_handling import build_parser, main
|
|
|
|
ASSET_DIR = Path(__file__).resolve().parents[2] / "testassets" / "ffmpeg_handling"
|
|
|
|
|
|
class CliTests(unittest.TestCase):
|
|
def test_test_command_is_not_registered(self):
|
|
with self.assertRaises(SystemExit) as error:
|
|
build_parser().parse_args(["test"])
|
|
self.assertEqual(error.exception.code, 2)
|
|
|
|
def test_short_command_alias_resolves_to_canonical_name(self):
|
|
args = build_parser().parse_args(["i", str(ASSET_DIR / "test_auto.mp4")])
|
|
self.assertEqual(args.command, "info")
|
|
|
|
def test_missing_ffmpeg_logs_error_and_returns_failure(self):
|
|
with patch("ffmpeg_handling.cli.shutil.which", return_value=None), \
|
|
patch("ffmpeg_handling.cli.setup_logging"), \
|
|
self.assertLogs("ffmpeg_handling", level="ERROR") as captured:
|
|
result = main(["info", str(ASSET_DIR / "test_auto_no_subs.mkv")])
|
|
|
|
self.assertEqual(result, 1)
|
|
self.assertIn("FFmpeg is not installed", captured.output[0])
|
|
|
|
def test_non_output_command_returns_success(self):
|
|
with patch("ffmpeg_handling.cli.setup_logging"), \
|
|
self.assertLogs("ffmpeg_handling", level="INFO"):
|
|
self.assertEqual(
|
|
main(["info", str(ASSET_DIR / "test_auto_no_subs.mkv")]), 0
|
|
)
|
|
|
|
def test_cli_dry_run_uses_requested_output_and_creates_nothing(self):
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
output = Path(temp_dir) / "dry_run.mkv"
|
|
with patch("ffmpeg_handling.cli.setup_logging"), \
|
|
self.assertLogs("ffmpeg_handling", level="INFO"):
|
|
result = main([
|
|
"downsize",
|
|
str(ASSET_DIR / "test_auto_no_subs.mkv"),
|
|
"-o",
|
|
str(output),
|
|
"--dry-run",
|
|
"-w",
|
|
"320",
|
|
"-he",
|
|
"180",
|
|
"-c",
|
|
"30",
|
|
])
|
|
self.assertEqual(result, 0)
|
|
self.assertFalse(output.exists())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|