aboutsummaryrefslogtreecommitdiffstats
path: root/tests/integration/test_check_absolute_subfolder.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2021-02-03 19:17:50 -0500
committerLibravatarUnit 193 <unit193@unit193.net>2021-02-03 19:17:50 -0500
commit475d074fd74425efbe783fad08f97f2df0c4909f (patch)
tree2acdae53999b3c74b716efa4edb5b40311fa356a /tests/integration/test_check_absolute_subfolder.py
parentcd502d52787f666fff3254d7d7e7578930c813c2 (diff)
parent3a0d66f07b112b6d2bdc2b57bbf717a89a351ce6 (diff)
Update upstream source from tag 'upstream/8.1.2'
Update to upstream version '8.1.2' with Debian dir e5e966a9e6010ef70618dc9a61558fa4db35aceb
Diffstat (limited to 'tests/integration/test_check_absolute_subfolder.py')
-rw-r--r--tests/integration/test_check_absolute_subfolder.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/integration/test_check_absolute_subfolder.py b/tests/integration/test_check_absolute_subfolder.py
new file mode 100644
index 0000000..86af065
--- /dev/null
+++ b/tests/integration/test_check_absolute_subfolder.py
@@ -0,0 +1,50 @@
+"""
+Validate links in a site which is:
+
+* built in URL_TYPE="absolute"
+* deployable to a subfolder (BASE_URL="https://example.com/foo/")
+"""
+
+import io
+import os
+
+import pytest
+
+from nikola import __main__
+
+from .helper import cd, patch_config
+from .test_demo_build import prepare_demo_site
+from .test_empty_build import ( # NOQA
+ test_archive_exists,
+ test_avoid_double_slash_in_rss,
+ test_check_files,
+ test_check_links,
+)
+
+
+def test_index_in_sitemap(build, output_dir):
+ """
+ Test that the correct path is in sitemap, and not the wrong one.
+
+ The correct path ends in /foo/ because this is where we deploy to.
+ """
+ sitemap_path = os.path.join(output_dir, "sitemap.xml")
+ with io.open(sitemap_path, "r", encoding="utf8") as inf:
+ sitemap_data = inf.read()
+
+ assert "<loc>https://example.com/foo/</loc>" in sitemap_data
+
+
+@pytest.fixture(scope="module")
+def build(target_dir):
+ """Fill the site with demo content and build it."""
+ prepare_demo_site(target_dir)
+
+ patch_config(
+ target_dir,
+ ('SITE_URL = "https://example.com/"', 'SITE_URL = "https://example.com/foo/"'),
+ ("# URL_TYPE = 'rel_path'", "URL_TYPE = 'absolute'"),
+ )
+
+ with cd(target_dir):
+ __main__.main(["build"])