mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-21 04:26:40 +08:00

* chore(tests): adding tests for Qt widgets * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: reset WINDOW name * chore(tests): addign tests * chore: adding more tests * fix how bin existence is checked * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: which takes str * more tests! * todo: fix * change verbosity in tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
142 lines
3.9 KiB
Python
142 lines
3.9 KiB
Python
from pathlib import Path
|
|
from typing import Iterator, Tuple
|
|
|
|
import pytest
|
|
from click.testing import CliRunner
|
|
from PySide6.QtWidgets import QApplication
|
|
|
|
from manim_slides.present import present
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def auto_shutdown_qapp() -> Iterator[None]:
|
|
if app := QApplication.instance():
|
|
app.shutdown()
|
|
|
|
yield
|
|
|
|
if app := QApplication.instance():
|
|
app.shutdown()
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def args(slides_folder: Path) -> Iterator[Tuple[str, ...]]:
|
|
yield ("--folder", str(slides_folder), "--skip-all", "--playback-rate", "25")
|
|
|
|
|
|
def test_present(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_unexisting_slide(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["UnexistingSlide", *args])
|
|
|
|
assert results.exit_code != 0
|
|
assert "UnexistingSlide.json does not exist" in results.stdout
|
|
|
|
|
|
def test_present_full_screen(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--fullscreen", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_hide_mouse(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--hide-mouse", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_ignore_aspect_ratio(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(
|
|
present, ["BasicSlide", "--aspect-ratio", "ignore", *args]
|
|
)
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_start_at(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--start-at", "-1,-1", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_start_at_invalid(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--start-at", "0,1234", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert "Could not set presentation index to 1234"
|
|
|
|
|
|
def test_present_start_at_scene_number(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(
|
|
present, ["BasicSlide", "BasicSlide", "--start-at-scene-number", "1", *args]
|
|
)
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_start_at_slide_number(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(
|
|
present, ["BasicSlide", "--start-at-slide-number", "1", *args]
|
|
)
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
def test_present_set_screen(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--screen", "0", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert results.stdout == ""
|
|
|
|
|
|
@pytest.mark.skip(reason="Fails when running the whole test suite.")
|
|
def test_present_set_invalid_screen(args: Tuple[str, ...]) -> None:
|
|
runner = CliRunner()
|
|
|
|
with runner.isolated_filesystem():
|
|
results = runner.invoke(present, ["BasicSlide", "--screen", "999", *args])
|
|
|
|
assert results.exit_code == 0
|
|
assert "Invalid screen number 999" in results.stdout
|