Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch00k committed Jul 30, 2024
1 parent 6a835b3 commit f268028
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
- run: |
pip install poetry
poetry install --with dev
- run: cp tests/ffmpeg/ffmpeg /usr/local/bin/ffmpeg
- run: poetry run pytest --cov=ffmpy --cov-report xml
- uses: codecov/codecov-action@v4
if: matrix.python-version == 3.12
Expand Down
15 changes: 14 additions & 1 deletion tests/test_cmd_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from ffmpy import FFmpeg
from ffmpy import FFmpeg, FFprobe


@pytest.mark.parametrize(
Expand Down Expand Up @@ -142,3 +142,16 @@ def test_path_with_spaces():
ff = FFmpeg(inputs=inputs, outputs=outputs)
assert ff._cmd == ["ffmpeg", "-i", "/home/ay/file with spaces", "output.ts"]
assert ff.cmd == 'ffmpeg -i "/home/ay/file with spaces" output.ts'


def test_repr():
inputs = {"input.ts": "-f rawvideo"}
outputs = {"output.ts": "-f rawvideo"}
ff = FFmpeg(inputs=inputs, outputs=outputs)
assert repr(ff) == "<'FFmpeg' 'ffmpeg -f rawvideo -i input.ts -f rawvideo output.ts'>"


def test_ffprobe():
inputs = {"input.ts": "-f rawvideo"}
ff = FFprobe(global_options="--verbose", inputs=inputs)
assert repr(ff) == "<'FFprobe' 'ffprobe --verbose -f rawvideo -i input.ts'>"
18 changes: 18 additions & 0 deletions tests/test_cmd_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

from ffmpy import FFExecutableNotFoundError, FFmpeg, FFRuntimeError

FFMPEG_PATH = os.path.join(os.path.dirname(__file__), "ffmpeg")
os.environ["PATH"] = FFMPEG_PATH + os.pathsep + os.environ["PATH"]


def test_invalid_executable_path():
ff = FFmpeg(executable="/tmp/foo/bar/ffmpeg")
Expand All @@ -16,6 +19,21 @@ def test_invalid_executable_path():
assert str(exc_info.value) == "Executable '/tmp/foo/bar/ffmpeg' not found"


def test_other_oserror():
executable = os.path.join(FFMPEG_PATH, "ffmpeg.go")
ff = FFmpeg(executable=executable)
with pytest.raises(PermissionError) as exc_info:
ff.run()
assert str(exc_info.value).startswith("[Errno 13] Permission denied")


def test_executable_full_path():
executable = os.path.join(FFMPEG_PATH, "ffmpeg")
ff = FFmpeg(executable=executable)
ff.run()
assert ff.cmd == executable


def test_no_redirection():
global_options = "--stdin none --stdout oneline --stderr multiline --exit-code 0"
ff = FFmpeg(global_options=global_options)
Expand Down

0 comments on commit f268028

Please sign in to comment.