mirror of
https://github.com/jeertmans/manim-slides.git
synced 2025-05-20 20:16:30 +08:00
fix(lib/cli): relative paths, empty slides, and tests (#223)
* fix(lib/cli): relative paths, empty slides, and tests This fixes two issues: 1. Empty slides are now reported as error, to prevent indexing error; 2. Changing the folder path will now produce an absolute path to slides, which was not the case before and would lead to a "file does not exist error". A few tests were also added to cover those * fix(lib): fix from_file, remove useless field, and more * chore(tests): remove print * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
93
tests/test_main.py
Normal file
93
tests/test_main.py
Normal file
@ -0,0 +1,93 @@
|
||||
from pathlib import Path
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
from manim_slides.__main__ import cli
|
||||
|
||||
|
||||
def test_help() -> None:
|
||||
runner = CliRunner()
|
||||
results = runner.invoke(cli, ["-S", "--help"])
|
||||
|
||||
assert results.exit_code == 0
|
||||
|
||||
results = runner.invoke(cli, ["-S", "-h"])
|
||||
|
||||
assert results.exit_code == 0
|
||||
|
||||
|
||||
def test_defaults_to_present(folder_path: Path) -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
with runner.isolated_filesystem():
|
||||
results = runner.invoke(
|
||||
cli, ["BasicExample", "--folder", str(folder_path), "-s"]
|
||||
)
|
||||
|
||||
assert results.exit_code == 0
|
||||
|
||||
|
||||
def test_present(folder_path: Path) -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
with runner.isolated_filesystem():
|
||||
results = runner.invoke(
|
||||
cli, ["present", "BasicExample", "--folder", str(folder_path), "-s"]
|
||||
)
|
||||
|
||||
assert results.exit_code == 0
|
||||
|
||||
|
||||
def test_convert(folder_path: Path) -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
with runner.isolated_filesystem():
|
||||
results = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"convert",
|
||||
"BasicExample",
|
||||
"basic_example.html",
|
||||
"--folder",
|
||||
str(folder_path),
|
||||
],
|
||||
)
|
||||
|
||||
assert results.exit_code == 0
|
||||
|
||||
|
||||
def test_init() -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
with runner.isolated_filesystem():
|
||||
results = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"init",
|
||||
"--force",
|
||||
],
|
||||
)
|
||||
|
||||
assert results.exit_code == 0
|
||||
|
||||
|
||||
def test_list_scenes(folder_path: Path) -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
with runner.isolated_filesystem():
|
||||
results = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"list-scenes",
|
||||
"--folder",
|
||||
str(folder_path),
|
||||
],
|
||||
)
|
||||
|
||||
assert results.exit_code == 0
|
||||
assert "BasicExample" in results.output
|
||||
|
||||
|
||||
def test_wizard() -> None:
|
||||
# TODO
|
||||
pass
|
Reference in New Issue
Block a user