31 lines
956 B
Python
31 lines
956 B
Python
import pytest
|
|
from django.core.management import call_command
|
|
from django.core.management.base import CommandError
|
|
|
|
from apps.blog.models import ArticleIndexPage, ArticlePage
|
|
from apps.blog.tests.factories import AuthorFactory
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_check_content_integrity_passes_when_requirements_met(home_page):
|
|
call_command("check_content_integrity")
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_check_content_integrity_fails_for_blank_summary(home_page):
|
|
index = ArticleIndexPage(title="Articles", slug="articles")
|
|
home_page.add_child(instance=index)
|
|
author = AuthorFactory()
|
|
article = ArticlePage(
|
|
title="Article",
|
|
slug="article",
|
|
author=author,
|
|
summary=" ",
|
|
body=[("rich_text", "<p>body</p>")],
|
|
)
|
|
index.add_child(instance=article)
|
|
article.save_revision().publish()
|
|
|
|
with pytest.raises(CommandError, match="empty summary"):
|
|
call_command("check_content_integrity")
|