Updates the generation means of robots.txt and sitemap.xml to be based off siteconfig's website param.
CI Pipeline / backend-test (push) Successful in 10m0s
CI Pipeline / frontend-build (push) Successful in 32s
CI Pipeline / backend-lint (push) Successful in 10s
CI Pipeline / frontend-test (push) Successful in 28s
CI Pipeline / backend-test (pull_request) Successful in 11m42s
CI Pipeline / frontend-test (pull_request) Successful in 31s
CI Pipeline / frontend-build (pull_request) Successful in 32s
CI Pipeline / backend-lint (pull_request) Successful in 12s
CI Pipeline / quality-gate (push) Successful in 3s
CI Pipeline / quality-gate (pull_request) Successful in 3s

This commit is contained in:
kfj001 committed 2026-08-04 20:33:25 -07:00
1 parent 55be42ed99
commit 4b123025e4
2 files changed
+69 -10

No files matched your search

+27 -1
View File
@@ -1,12 +1,38 @@
"""Tests for sitemap API endpoints — /api/sitemap/sitemap.xml, /api/sitemap/robots.txt, /api/sitemap/regenerate."""
"""Tests for sitemap API endpoints — /api/sitemap/sitemap.xml, /api/sitemap/robots.txt, /api/sitemap/regenerate.
Note: The sitemap and robots.txt endpoints now read the site URL from
StationConfig.website in the database (falling back to KMTN_WEBSITE_URL
if the config is missing). These tests assume a seeded database with the
default station config (website = 'kmountainflower.org').
"""
import pytest
from httpx import AsyncClient
from starlette.testclient import TestClient
from app.api.sitemap import _build_base_url
from app.main import app
class TestBuildBaseUrl:
"""Tests for the _build_base_url helper."""
def test_bare_domain_gets_https(self):
assert _build_base_url("kmountainflower.org") == "https://kmountainflower.org"
def test_domain_with_trailing_slash(self):
assert _build_base_url("kmountainflower.org/") == "https://kmountainflower.org"
def test_domain_with_whitespace(self):
assert _build_base_url(" mystation.org ") == "https://mystation.org"
def test_already_has_https_scheme(self):
assert _build_base_url("https://kmountainflower.org") == "https://kmountainflower.org"
def test_already_has_http_scheme(self):
assert _build_base_url("http://kmountainflower.org") == "http://kmountainflower.org"
class TestSitemapEndpoints:
"""Tests for sitemap API routes."""