Skip to content

Commit ece05dc

Browse files
issue #693 add test for search_list_for_dict_key
1 parent 53936a6 commit ece05dc

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/test_util.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
normalize_crs,
3434
repr_truncate,
3535
rfc3339,
36+
search_list_for_dict_key,
3637
str_truncate,
3738
to_bbox_dict,
3839
url_join,
@@ -1055,3 +1056,41 @@ def test_normalize_crs_succeeds_with_correct_projstring(self, epsg_input, expect
10551056
def test_normalize_crs_handles_incorrect_crs(self, epsg_input, use_pyproj):
10561057
with pytest.raises(ValueError):
10571058
normalize_crs(epsg_input, use_pyproj=use_pyproj)
1059+
1060+
@pytest.mark.parametrize(
1061+
"list_with_dicts",
1062+
[
1063+
[
1064+
{"x1": "y1"},
1065+
{"x2": "y2"},
1066+
{"x3": "y3"},
1067+
{"x3": "y3"},
1068+
]
1069+
],
1070+
)
1071+
@pytest.mark.parametrize(("key", "expected"), [("x1", "y1"), ("x2", "y2"), ("x4", None)])
1072+
def test_search_list_for_dict_key(self, list_with_dicts, key, expected):
1073+
assert search_list_for_dict_key(list_with_dicts, key) == expected
1074+
1075+
@pytest.mark.parametrize(
1076+
"list_with_dicts",
1077+
[
1078+
[
1079+
{"x1": "y1"},
1080+
{"x2": "y2"},
1081+
{"x3": "y3"},
1082+
{"x3": "y4"},
1083+
{"x2": "y1"},
1084+
]
1085+
],
1086+
)
1087+
@pytest.mark.parametrize(
1088+
"key",
1089+
[
1090+
"x2",
1091+
"x3",
1092+
],
1093+
)
1094+
def test_search_list_for_dict_key_value_error(self, list_with_dicts, key):
1095+
with pytest.raises(ValueError):
1096+
search_list_for_dict_key(list_with_dicts, key)

0 commit comments

Comments
 (0)