from dataclasses import FrozenInstanceError from genesis.writer.models import ContentBlock, ChapterContent, GenerationContext, ChapterSpec def test_content_block_defaults(): b = ContentBlock(block_id="b1", type="paragraph", text="你好") assert b.level is None assert b.source_uris == [] def test_chapter_content_holds_blocks(): b = ContentBlock(block_id="b1", type="heading", level=2, text="标题") c = ChapterContent(chapter_id="db_design", version=1, title="DB 设计", blocks=[b]) assert c.blocks[0].type == "heading" assert c.version == 1 def test_generation_context_no_impact_field(): ctx = GenerationContext( chapter_id="db_design", title="DB 设计", template_marker=ChapterSpec(chapter_id="db_design", title="DB 设计", section_placeholder="{{section:db_design}}"), structured_source=None, write_rules=["规则1"], design_rules=["规则2"], template_styles={"Heading 1"}, ) assert not hasattr(ctx, "impact") def test_chapter_spec_placeholder_optional(): s = ChapterSpec(chapter_id="x", title="X", section_placeholder=None) assert s.section_placeholder is None