Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

Add regression tests for None, bool, and empty-container HTML rendering

Louis Choquelcc6364607f23
diff --git a/tests/unit/pipelex/core/stuffs/test_html_rendering.py b/tests/unit/pipelex/core/stuffs/test_html_rendering.py
index 86be9a635..9e94c20c1 100644
--- a/tests/unit/pipelex/core/stuffs/test_html_rendering.py
+++ b/tests/unit/pipelex/core/stuffs/test_html_rendering.py
@@ -1,3 +1,7 @@
+from typing import Any
+
+import pytest
+
from pipelex.core.stuffs.html_rendering import render_value_html
@@ -20,3 +24,32 @@ class TestRenderValueHtml:
def test_html_looking_string_inside_dict_is_escaped(self):
result = render_value_html({"payload": "<b>bold</b>"})
assert result == "<dl><dt>payload</dt><dd>&lt;b&gt;bold&lt;/b&gt;</dd></dl>"
+
+ def test_none_renders_as_em_none(self):
+ """None is the only branch producing a literal HTML fragment with no data-derived value."""
+ result = render_value_html(None)
+ assert result == "<em>None</em>"
+
+ @pytest.mark.parametrize(
+ ("bool_value", "expected"),
+ [
+ (True, "True"),
+ (False, "False"),
+ ],
+ )
+ def test_bool_renders_as_true_false_not_int(self, bool_value: bool, expected: str):
+ """Guards the bool-before-int match-arm ordering: bool is a subclass of int, so a reorder would render True as '1'."""
+ result = render_value_html(bool_value)
+ assert result == expected
+
+ @pytest.mark.parametrize(
+ "empty_container",
+ [
+ [],
+ (),
+ {},
+ ],
+ )
+ def test_empty_containers_render_as_em_empty(self, empty_container: Any):
+ result = render_value_html(empty_container)
+ assert result == "<em>empty</em>"