- 新增 apps/blog、apps/solutions、apps/home、apps/api 测试文件,覆盖标签/排序/ 草稿过滤、HomePage.subpage_types 回归测试、page_preview 预览接口 - apps/core/tests.py 新增健康检查端点、发布 webhook 信号、bootstrap_deployment 命令的测试用例,pytest 用例数从 40 增至 65,全部通过 - 修复 apps/api/urls.py 中 PagePreviewAPIViewSet.get_object() 未捕获 DoesNotExist 导致 500 而非文档承诺 404 的 bug - 新增 apps/core/management/commands/bootstrap_deployment.py:部署时按环境变量 幂等创建首个超级管理员账号并联动初始化 RBAC 权限组,.env.example 补充对应 环境变量说明 - 新增 OpenSearch + 中文分词本地 PoC 脚手架(docker-compose.opensearch.yml + docker/opensearch/Dockerfile),调研结论详见设计文档 §2.10 - 更新设计文档 §2.16 Phase 1 进度清单
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""apps.solutions 单元测试:页面树结构与列表上下文(与 apps.products/apps.cases 同构)。"""
|
|
import pytest
|
|
|
|
from apps.solutions.models import SolutionIndexPage, SolutionPage
|
|
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
@pytest.fixture
|
|
def solution_index(home_page):
|
|
index = SolutionIndexPage(title="解决方案", slug="solutions", intro="行业解决方案")
|
|
home_page.add_child(instance=index)
|
|
return index
|
|
|
|
|
|
def test_solution_page_can_be_created_under_index(solution_index):
|
|
solution = SolutionPage(
|
|
title="制造业解决方案",
|
|
slug="manufacturing",
|
|
industry="制造业",
|
|
summary="面向制造业的数字化转型方案",
|
|
)
|
|
solution_index.add_child(instance=solution)
|
|
|
|
assert SolutionPage.objects.live().descendant_of(solution_index).count() == 1
|
|
|
|
|
|
def test_solution_index_context_excludes_draft_solutions(solution_index):
|
|
live_solution = SolutionPage(title="方案 A", slug="solution-a")
|
|
solution_index.add_child(instance=live_solution)
|
|
|
|
draft_solution = SolutionPage(title="方案 B", slug="solution-b", live=False)
|
|
solution_index.add_child(instance=draft_solution)
|
|
|
|
context = solution_index.get_context(request=None)
|
|
titles = [s.title for s in context["solutions"]]
|
|
|
|
assert "方案 A" in titles
|
|
assert "方案 B" not in titles
|