Skip to content

Commit 729bfe8

Browse files
Ali-Ismail-1mdrxy
andauthored
test(core): enhance stringify_value test coverage for nested structures (#33099)
## Summary Adds test coverage for the `stringify_value` utility function to handle complex nested data structures that weren't previously tested. ## Changes - Added `test_stringify_value_nested_structures()` to `test_strings.py` - Tests nested dictionaries within lists - Tests mixed-type lists with various data types - Verifies proper stringification of complex nested structures ## Why This Matters - Fills a gap in test coverage for edge cases - Ensures `stringify_value` handles complex data structures correctly - Improves confidence in string utility functions used throughout the codebase - Low risk addition that strengthens existing test suite ## Testing ```bash uv run --group test pytest libs/core/tests/unit_tests/utils/test_strings.py::test_stringify_value_nested_structures -v ``` This test addition follows the project's testing patterns and adds meaningful coverage without introducing any breaking changes. --------- Co-authored-by: Mason Daugherty <[email protected]>
1 parent 9b624a7 commit 729bfe8

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

libs/core/tests/unit_tests/utils/test_strings.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,35 @@ def test_existing_string_functions() -> None:
4747
result = stringify_dict(data)
4848
assert "key: value" in result
4949
assert "number: 123" in result
50+
51+
52+
def test_stringify_value_nested_structures() -> None:
53+
"""Test stringifying nested structures."""
54+
# Test nested dict in list
55+
nested_data = {
56+
"users": [
57+
{"name": "Alice", "age": 25},
58+
{"name": "Bob", "age": 30},
59+
],
60+
"metadata": {"total_users": 2, "active": True},
61+
}
62+
63+
result = stringify_value(nested_data)
64+
65+
# Shoudl contain all the nested values
66+
assert "users:" in result
67+
assert "name: Alice" in result
68+
assert "name: Bob" in result
69+
assert "metadata:" in result
70+
assert "total_users: 2" in result
71+
assert "active: True" in result
72+
73+
# Test list of mixed types
74+
mixed_list = ["string", 42, {"key": "value"}, ["nested", "list"]]
75+
result = stringify_value(mixed_list)
76+
77+
assert "string" in result
78+
assert "42" in result
79+
assert "key: value" in result
80+
assert "nested" in result
81+
assert "list" in result

0 commit comments

Comments
 (0)