Add category taxonomy and navigation integration
Implements Issue #35 with category snippets, article category routing, category-aware templates, and category RSS feeds with tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import pytest
|
||||
from django.db import IntegrityError
|
||||
from taggit.models import Tag
|
||||
|
||||
from apps.blog.models import ArticleIndexPage, ArticlePage, HomePage, TagMetadata
|
||||
from apps.blog.models import ArticleIndexPage, ArticlePage, Category, HomePage, TagMetadata
|
||||
from apps.blog.tests.factories import AuthorFactory
|
||||
|
||||
|
||||
@@ -40,3 +40,29 @@ def test_tag_metadata_css_and_uniqueness():
|
||||
assert meta.get_css_classes()["bg"] == "bg-brand-cyan/10"
|
||||
with pytest.raises(IntegrityError):
|
||||
TagMetadata.objects.create(tag=tag, colour="pink")
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_article_default_category_is_assigned(home_page):
|
||||
index = ArticleIndexPage(title="Articles", slug="articles")
|
||||
home_page.add_child(instance=index)
|
||||
author = AuthorFactory()
|
||||
article = ArticlePage(
|
||||
title="Categorised",
|
||||
slug="categorised",
|
||||
author=author,
|
||||
summary="s",
|
||||
body=[("rich_text", "<p>body</p>")],
|
||||
)
|
||||
index.add_child(instance=article)
|
||||
article.save()
|
||||
assert article.category.slug == "general"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_category_ordering():
|
||||
Category.objects.get_or_create(name="General", slug="general")
|
||||
Category.objects.create(name="Z", slug="z", sort_order=2)
|
||||
Category.objects.create(name="A", slug="a", sort_order=1)
|
||||
names = list(Category.objects.values_list("name", flat=True))
|
||||
assert names == ["General", "A", "Z"]
|
||||
|
||||
Reference in New Issue
Block a user