import pytest from django.test import override_settings from apps.blog.models import ArticleIndexPage, ArticlePage from apps.blog.tests.factories import AuthorFactory @pytest.mark.django_db def test_feed_endpoint(client): resp = client.get("/feed/") assert resp.status_code == 200 assert resp["Content-Type"].startswith("application/rss+xml") @pytest.mark.django_db @override_settings(WAGTAILADMIN_BASE_URL="http://wrong-host.example") def test_feed_uses_request_host_for_item_links(client, home_page): index = ArticleIndexPage(title="Articles", slug="articles") home_page.add_child(instance=index) author = AuthorFactory() article = ArticlePage( title="Feed Article", slug="feed-article", author=author, summary="summary", body=[("rich_text", "
Body
")], ) index.add_child(instance=article) article.save_revision().publish() resp = client.get("/feed/") body = resp.content.decode() assert resp.status_code == 200 assert "http://localhost/articles/feed-article/" in body