From 3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Wed, 3 Feb 2021 19:17:00 -0500 Subject: New upstream version 8.1.2. --- tests/integration/test_check_failure.py | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/integration/test_check_failure.py (limited to 'tests/integration/test_check_failure.py') diff --git a/tests/integration/test_check_failure.py b/tests/integration/test_check_failure.py new file mode 100644 index 0000000..08e9447 --- /dev/null +++ b/tests/integration/test_check_failure.py @@ -0,0 +1,47 @@ +""" +The demo build should pass 'nikola check' and fail with missing files. + +This tests the red path (failures) for the `check` command. +Green path tests (working as expected) can be found in `test_demo_build`. +""" + +import io +import os + +import pytest + +from nikola import __main__ + +from .helper import cd +from .test_demo_build import prepare_demo_site +from .test_empty_build import ( # NOQA + test_avoid_double_slash_in_rss, + test_index_in_sitemap, +) + + +def test_check_links_fail(build, output_dir, target_dir): + os.unlink(os.path.join(output_dir, "archive.html")) + + with cd(target_dir): + result = __main__.main(["check", "-l"]) + assert result != 0 + + +def test_check_files_fail(build, output_dir, target_dir): + manually_added_file = os.path.join(output_dir, "foobar") + with io.open(manually_added_file, "w+", encoding="utf8") as outf: + outf.write("foo") + + with cd(target_dir): + result = __main__.main(["check", "-f"]) + assert result != 0 + + +@pytest.fixture(scope="module") +def build(target_dir): + """Fill the site with demo content and build it.""" + prepare_demo_site(target_dir) + + with cd(target_dir): + __main__.main(["build"]) -- cgit v1.2.3