feat: rebuild site content management
Replace legacy FAQ, downloads, and release flows with project and blog publishing. Add configurable branding and theme fields plus clean-start Compose seeding support.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.pages.models import FAQEntry
|
||||
from apps.pages.models import BlogPost, HomepageSection
|
||||
|
||||
|
||||
class HomeViewTest(TestCase):
|
||||
@@ -13,6 +14,16 @@ class HomeViewTest(TestCase):
|
||||
response = self.client.get(reverse("pages:home"))
|
||||
self.assertTemplateUsed(response, "pages/home.html")
|
||||
|
||||
def test_section_description_renders_markdown_and_html(self):
|
||||
HomepageSection.objects.create(
|
||||
section_type=HomepageSection.TYPE_FEATURES,
|
||||
title="Rich section",
|
||||
description="**Formatted** content",
|
||||
description_format="markdown",
|
||||
)
|
||||
response = self.client.get(reverse("pages:home"))
|
||||
self.assertContains(response, "<strong>Formatted</strong>")
|
||||
|
||||
|
||||
class AboutViewTest(TestCase):
|
||||
def test_about_returns_200(self):
|
||||
@@ -24,34 +35,30 @@ class AboutViewTest(TestCase):
|
||||
self.assertTemplateUsed(response, "pages/about.html")
|
||||
|
||||
|
||||
class FAQViewTest(TestCase):
|
||||
class BlogViewTest(TestCase):
|
||||
def setUp(self):
|
||||
FAQEntry.objects.create(
|
||||
question="What is the license?",
|
||||
answer="It is CC BY-NC-SA.",
|
||||
order=1,
|
||||
is_active=True,
|
||||
)
|
||||
FAQEntry.objects.create(
|
||||
question="Hidden question",
|
||||
answer="Hidden answer",
|
||||
order=2,
|
||||
is_active=False,
|
||||
self.post = BlogPost.objects.create(
|
||||
title="Research update",
|
||||
slug="research-update",
|
||||
excerpt="A short summary.",
|
||||
content="## Results\n\n**Promising** findings.",
|
||||
content_format="markdown",
|
||||
status=BlogPost.STATUS_PUBLISHED,
|
||||
published_at=timezone.now(),
|
||||
)
|
||||
|
||||
def test_faq_returns_200(self):
|
||||
response = self.client.get(reverse("pages:faq"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
def test_blog_list_and_detail_render_published_post(self):
|
||||
listing = self.client.get(reverse("pages:blog_list"))
|
||||
detail = self.client.get(self.post.get_absolute_url())
|
||||
self.assertContains(listing, self.post.title)
|
||||
self.assertContains(detail, "<h2>Results</h2>")
|
||||
self.assertContains(detail, "<strong>Promising</strong>")
|
||||
|
||||
def test_faq_uses_correct_template(self):
|
||||
response = self.client.get(reverse("pages:faq"))
|
||||
self.assertTemplateUsed(response, "pages/faq.html")
|
||||
|
||||
def test_faq_only_shows_active_entries(self):
|
||||
response = self.client.get(reverse("pages:faq"))
|
||||
entries = response.context["faq_entries"]
|
||||
self.assertEqual(entries.count(), 1)
|
||||
self.assertEqual(entries.first().question, "What is the license?")
|
||||
def test_draft_post_is_not_public(self):
|
||||
self.post.status = BlogPost.STATUS_DRAFT
|
||||
self.post.save(update_fields=["status"])
|
||||
self.assertNotContains(self.client.get(reverse("pages:blog_list")), self.post.title)
|
||||
self.assertEqual(self.client.get(self.post.get_absolute_url()).status_code, 404)
|
||||
|
||||
|
||||
class ContactViewTest(TestCase):
|
||||
@@ -69,7 +76,7 @@ class NavigationContextTest(TestCase):
|
||||
urls = [
|
||||
reverse("pages:home"),
|
||||
reverse("pages:about"),
|
||||
reverse("pages:faq"),
|
||||
reverse("pages:blog_list"),
|
||||
reverse("pages:contact"),
|
||||
reverse("products:overview"),
|
||||
]
|
||||
@@ -85,7 +92,7 @@ class NavigationContextTest(TestCase):
|
||||
urls = [
|
||||
reverse("pages:home"),
|
||||
reverse("pages:about"),
|
||||
reverse("pages:faq"),
|
||||
reverse("pages:blog_list"),
|
||||
reverse("pages:contact"),
|
||||
]
|
||||
for url in urls:
|
||||
|
||||
Reference in New Issue
Block a user