From 46f8cdcc24ee64b270702bdf8c7c7518ca7051e0 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sun, 16 Mar 2025 21:15:34 -0500 Subject: [PATCH] test the build command Signed-off-by: Brian S. Stephan --- tests/test_commands.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_commands.py diff --git a/tests/test_commands.py b/tests/test_commands.py new file mode 100644 index 0000000..2bf80cd --- /dev/null +++ b/tests/test_commands.py @@ -0,0 +1,30 @@ +"""Test command line invocations. + +SPDX-FileCopyrightText: © 2023 Brian S. Stephan +SPDX-License-Identifier: AGPL-3.0-or-later +""" +import os +import tempfile +from subprocess import run + +HERE = os.path.dirname(os.path.abspath(__file__)) + + +def test_build(): + """Test some of the output of the core builder command.""" + with tempfile.TemporaryDirectory() as tmpdir: + result = run(['incorporealcms-build', os.path.join(HERE, 'instance'), tmpdir], + capture_output=True, encoding='utf8') + assert "creating temporary directory" in result.stdout + assert "copying file" in result.stdout + assert "creating symlink" in result.stdout + assert "creating directory" in result.stdout + assert "renaming" in result.stdout + + +def test_build_error(): + """Test some of the output of the core builder command.""" + result = run(['incorporealcms-build', os.path.join(HERE, 'instance'), os.path.join(HERE, 'test_markdown.py')], + capture_output=True, encoding='utf8') + assert "specified output path" in result.stderr + assert "exists as a file!" in result.stderr