platform-core/tests/serviceGeneration/test_style_resolver.py
ValueOn AG 4a60086c80
Some checks failed
Deploy Plattform-Core (Int) / test (push) Failing after 15s
Deploy Plattform-Core (Int) / deploy (push) Has been skipped
cp adapted to 2026 poweron
2026-06-09 09:53:31 +02:00

49 lines
1.6 KiB
Python

# Copyright (c) 2026 PowerOn AG
# All rights reserved.
import pytest
from modules.serviceCenter.services.serviceGeneration.styleDefaults import (
resolveStyle,
DEFAULT_STYLE,
)
def test_resolve_none_returns_defaults():
result = resolveStyle(None)
assert result == DEFAULT_STYLE
def test_resolve_empty_returns_defaults():
result = resolveStyle({})
assert result == DEFAULT_STYLE
def test_override_single_color():
result = resolveStyle({"colors": {"primary": "#FF0000"}})
assert result["colors"]["primary"] == "#FF0000"
assert result["colors"]["secondary"] == DEFAULT_STYLE["colors"]["secondary"]
def test_override_nested_heading():
result = resolveStyle({"headings": {"h1": {"sizePt": 30}}})
assert result["headings"]["h1"]["sizePt"] == 30
assert result["headings"]["h1"]["weight"] == "bold"
def test_override_font():
result = resolveStyle({"fonts": {"primary": "Arial"}})
assert result["fonts"]["primary"] == "Arial"
assert result["fonts"]["monospace"] == "Consolas"
def test_full_style_passthrough():
custom = {"fonts": {"primary": "Helvetica", "monospace": "Monaco"}}
result = resolveStyle(custom)
assert result["fonts"]["primary"] == "Helvetica"
assert result["fonts"]["monospace"] == "Monaco"
def test_override_document_title_partial_merge():
result = resolveStyle({"documentTitle": {"sizePt": 32}})
assert result["documentTitle"]["sizePt"] == 32
assert result["documentTitle"]["align"] == "center"
assert result["headings"]["h1"]["sizePt"] == DEFAULT_STYLE["headings"]["h1"]["sizePt"]