Add MP4 upload support
This commit is contained in:
@@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from src.audio_separation import DEFAULT_MIX_MODE
|
||||
|
||||
from main import _build_translation_config, build_parser
|
||||
from main import _build_translation_config, _validate_source_args, build_parser
|
||||
|
||||
|
||||
def test_parser_accepts_lmstudio_flags():
|
||||
@@ -69,3 +69,37 @@ def test_parser_defaults_to_instrumental_only_mix_mode():
|
||||
args = parser.parse_args(["https://youtube.com/watch?v=demo"])
|
||||
|
||||
assert args.mix_mode == DEFAULT_MIX_MODE
|
||||
|
||||
|
||||
def test_parser_accepts_local_input_file_without_url():
|
||||
parser = build_parser()
|
||||
|
||||
args = parser.parse_args(["--input-file", "demo.mp4", "--lang", "fr"])
|
||||
|
||||
assert args.url is None
|
||||
assert args.input_file == "demo.mp4"
|
||||
assert args.lang == "fr"
|
||||
|
||||
|
||||
def test_validate_source_args_rejects_missing_source():
|
||||
parser = build_parser()
|
||||
args = parser.parse_args([])
|
||||
|
||||
try:
|
||||
_validate_source_args(args)
|
||||
except SystemExit as exc:
|
||||
assert "Provide either" in str(exc)
|
||||
else:
|
||||
raise AssertionError("Expected SystemExit for missing source")
|
||||
|
||||
|
||||
def test_validate_source_args_rejects_two_sources():
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(["https://youtube.com/watch?v=demo", "--input-file", "demo.mp4"])
|
||||
|
||||
try:
|
||||
_validate_source_args(args)
|
||||
except SystemExit as exc:
|
||||
assert "not both" in str(exc)
|
||||
else:
|
||||
raise AssertionError("Expected SystemExit for two sources")
|
||||
|
||||
@@ -39,6 +39,20 @@ def test_build_pipeline_command_accepts_optional_settings():
|
||||
assert "--gpu" in command
|
||||
|
||||
|
||||
def test_build_pipeline_command_accepts_uploaded_mp4():
|
||||
command = build_pipeline_command(
|
||||
{
|
||||
"input_file": "C:\\videos\\demo.mp4",
|
||||
"lang": "de",
|
||||
}
|
||||
)
|
||||
|
||||
assert "https://youtube.com/watch?v=demo" not in command
|
||||
assert "--input-file" in command
|
||||
assert command[command.index("--input-file") + 1] == "C:\\videos\\demo.mp4"
|
||||
assert command[command.index("--lang") + 1] == "de"
|
||||
|
||||
|
||||
def test_create_app_builds_gradio_blocks():
|
||||
app = create_app()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user