diff --git a/src/uwtools/tests/config/test_support.py b/src/uwtools/tests/config/test_support.py index ad9b051b1..f70b95560 100644 --- a/src/uwtools/tests/config/test_support.py +++ b/src/uwtools/tests/config/test_support.py @@ -88,6 +88,11 @@ def loader(self): # demonstrate that those nodes' convert() methods return representations in the type specified # by the tag. + @mark.parametrize("value, expected", [("False", False), ("True", True)]) + def test_bool_values(self, expected, loader, value): + ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!bool", value=value)) + assert ts.convert() == expected + def test_datetime_no(self, loader): ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!datetime", value="foo")) with raises(ValueError): @@ -100,6 +105,16 @@ def test_datetime_ok(self, loader): assert ts.convert() == datetime(2024, 8, 9, 12, 22, 42) self.comp(ts, "!datetime '2024-08-09 12:22:42'") + def test_dict_no(self, loader): + ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!dict", value="42")) + with raises(TypeError): + ts.convert() + + def test_dict_ok(self, loader): + ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!dict", value="{a0: 0, a1: 1}")) + assert ts.convert() == {"a0": 0, "a1": 1} + self.comp(ts, "!dict '{a0: 0, a1: 1}'") + def test_float_no(self, loader): ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!float", value="foo")) with raises(ValueError): @@ -120,6 +135,16 @@ def test_int_ok(self, loader): assert ts.convert() == 42 self.comp(ts, "!int '42'") + def test_list_no(self, loader): + ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!list", value="null")) + with raises(TypeError): + ts.convert() + + def test_list_ok(self, loader): + ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!list", value="[1, 2, 3,]")) + assert ts.convert() == [1, 2, 3] + self.comp(ts, "!list '[1, 2, 3,]'") + def test___repr__(self, loader): ts = support.UWYAMLConvert(loader, yaml.ScalarNode(tag="!int", value="42")) assert str(ts) == "!int 42"