gateway/tests/unit/datamodels/test_udm_models.py
2026-04-16 23:13:05 +02:00

34 lines
984 B
Python

# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
from modules.datamodels.datamodelUdm import UdmContentBlock, UdmDocument, UdmStructuralNode
def test_udmDocument_roundtrip_minimal():
doc = UdmDocument(
id="d1",
sourceType="html",
sourcePath="x.html",
children=[
UdmStructuralNode(
id="s1",
role="section",
index=0,
label="body",
children=[
UdmContentBlock(
id="b1",
contentType="text",
raw="hello",
)
],
)
],
)
dumped = doc.model_dump()
assert dumped["sourceType"] == "html"
assert len(doc.children[0].children) == 1
def test_udmContentBlock_fileRef_optional():
b = UdmContentBlock(id="x", contentType="image", raw="", fileRef="file:123")
assert b.fileRef == "file:123"