First version
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""Tests for the Typer CLI."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from genshin_tcg import __version__
|
||||
from genshin_tcg.cli import app
|
||||
from genshin_tcg.data.catalog import Catalog, save_catalog
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
def test_version_flag() -> None:
|
||||
result = runner.invoke(app, ["--version"])
|
||||
assert result.exit_code == 0
|
||||
assert __version__ in result.output
|
||||
|
||||
|
||||
def test_list_without_catalogue_errors(tmp_path: Path) -> None:
|
||||
result = runner.invoke(
|
||||
app,
|
||||
["--build-dir", str(tmp_path / "build"), "--assets-dir", str(tmp_path / "assets"), "list"],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
assert "Error" in result.output
|
||||
|
||||
|
||||
def test_list_prints_catalogue(tmp_path: Path, sample_catalog: Catalog) -> None:
|
||||
build_dir = tmp_path / "build"
|
||||
build_dir.mkdir(parents=True)
|
||||
save_catalog(sample_catalog, build_dir / "catalog.json")
|
||||
|
||||
result = runner.invoke(
|
||||
app,
|
||||
["--build-dir", str(build_dir), "--assets-dir", str(tmp_path / "assets"), "list"],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "test_pyro" in result.output
|
||||
assert "Test Pyro" in result.output
|
||||
Reference in New Issue
Block a user