This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
flamenco-worker/tests/test_commands_encode_audio.py
Sybren A. Stüvel 05408dc8c1 Cleanup: reformat with Black
Reformat the entire project with Black.

No functional changes.
2021-07-09 14:26:13 +02:00

56 lines
1.4 KiB
Python

import logging
import shutil
import typing
from pathlib import Path
import shlex
import subprocess
import sys
import tempfile
from tests.test_runner import AbstractCommandTest
log = logging.getLogger(__name__)
frame_dir = Path(__file__).with_name("test_frames")
class EncodeAudioTest(AbstractCommandTest):
settings: typing.Dict[str, typing.Any] = {
"ffmpeg_cmd": f'"{sys.executable}" -hide_banner',
"input_file": f"{frame_dir}/audio.flac",
"codec": "aac",
"bitrate": "192k",
"output_file": f"{frame_dir}/audio.aac",
}
def setUp(self):
super().setUp()
from flamenco_worker.commands import EncodeAudioCommand
self.cmd = EncodeAudioCommand(
worker=self.fworker,
task_id="12345",
command_idx=0,
)
self.settings = self.__class__.settings.copy()
def test_build_ffmpeg_cmd(self):
self.cmd.validate(self.settings)
cliargs = self.cmd._build_ffmpeg_command(self.settings)
self.assertEqual(
[
sys.executable,
"-hide_banner",
"-i",
str(frame_dir / "audio.flac"),
"-c:a",
"aac",
"-b:a",
"192k",
"-y",
str(frame_dir / "audio.aac"),
],
cliargs,
)