mirror of
https://github.com/shouptech/synthale.git
synced 2026-02-03 15:39:45 +00:00
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Test interactions with the CLI."""
|
|
|
|
from click.testing import CliRunner
|
|
|
|
from synthale.cli import main
|
|
|
|
|
|
def test_main_help():
|
|
"""Test the help output of the main CLI command."""
|
|
runner = CliRunner()
|
|
result = runner.invoke(main, ['--help'])
|
|
assert 'INPUT_PATH' in result.output
|
|
assert 'OUTPUT_PATH' in result.output
|
|
|
|
|
|
def test_main_directory(tmpdir, md_recipes):
|
|
"""Test command where input is a directory."""
|
|
runner = CliRunner()
|
|
result = runner.invoke(main, ['tests/recipes', str(tmpdir)])
|
|
|
|
assert result.exit_code == 0
|
|
assert result.output.startswith(
|
|
"Generating markdown from 'tests/recipes'..."
|
|
)
|
|
|
|
for recipe in md_recipes:
|
|
path = tmpdir.join(recipe.filename)
|
|
assert path.read() == recipe.markdown
|
|
|
|
|
|
def test_main_file(tmpdir):
|
|
"""Test command where input is a file."""
|
|
runner = CliRunner()
|
|
result = runner.invoke(main, ['tests/recipes/weizen.xml', str(tmpdir)])
|
|
|
|
assert result.exit_code == 0
|
|
assert result.output.startswith(
|
|
"Generating markdown from 'tests/recipes/weizen.xml'..."
|
|
)
|
|
|
|
path = tmpdir.join('weizen.md')
|
|
assert path.read().startswith('Weizen')
|