Modified code to cli-based integration testing.

This commit is contained in:
Kazuki Nakai 2024-10-10 21:46:38 +09:00
parent b63201e9e2
commit 1209218856

View File

@ -40,35 +40,35 @@ def test_restore_audio():
expected_command = ['-i', '/fake/temp/path.mp4', '-ss', '0.16666666666666666', '-to', '0.6666666666666666', '-i', target_path, '-c:v', 'copy', '-c:a', 'aac', '-ar', '48000', '-map', '0:v:0', '-map', '1:a:0', '-shortest', '-y', output_path]
mock_run_ffmpeg.assert_called_once_with(expected_command)
# 新しい統合テストメソッドを追加
# New integration test method added
def test_restore_audio_integration():
# 実際の入力と出力のパスを定義
target_path = '/path/to/real/input.mp4' # 実際の入力ファイルに更新
output_path = '/path/to/real/output.mp4' # 出力ファイルの希望に更新
# Define actual input and output paths
target_path = '/path/to/real/input.mp4'
output_path = '/path/to/real/output.mp4'
output_video_fps = 30.0
# 関数を呼び出す
# Call the function
result = restore_audio(target_path, output_path, output_video_fps)
# アサーション
# Assertions
assert result
# CLIベースのユニットテストメソッドを追加
# CLI-based unit test method added
def test_restore_audio_cli_unit():
import subprocess
# テスト用の入力と出力のパスを定義
target_path = '/fake/input/path.mp4' # テスト用の入力ファイル
output_path = '/fake/output/path.mp4' # テスト用の出力ファイル
# Define test input and output paths
target_path = '/fake/input/path.mp4'
output_path = '/fake/output/path.mp4'
output_video_fps = 30.0
# CLIコマンドを実行
command = ['python', 'path/to/your_script.py', target_path, output_path, str(output_video_fps)]
# Execute the CLI command
command = ['python', 'path/to/your_script.py', target_path, output_path, str(output_video_fps)] # {{ edit_1 }}
result = subprocess.run(command, capture_output=True)
# アサーション
assert result.returncode == 0 # 成功を確認
# 追加のアサーションを行うことも可能
# Assertions
assert result.returncode == 0 # Confirm success
# Additional assertions can also be made
if __name__ == '__main__':
unittest.main()