Skip to content

Commit

Permalink
issue #693 add test for search_list_for_dict_key
Browse files Browse the repository at this point in the history
  • Loading branch information
ElienVandermaesenVITO committed Jan 9, 2025
1 parent 53936a6 commit ece05dc
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
normalize_crs,
repr_truncate,
rfc3339,
search_list_for_dict_key,
str_truncate,
to_bbox_dict,
url_join,
Expand Down Expand Up @@ -1055,3 +1056,41 @@ def test_normalize_crs_succeeds_with_correct_projstring(self, epsg_input, expect
def test_normalize_crs_handles_incorrect_crs(self, epsg_input, use_pyproj):
with pytest.raises(ValueError):
normalize_crs(epsg_input, use_pyproj=use_pyproj)

@pytest.mark.parametrize(
"list_with_dicts",
[
[
{"x1": "y1"},
{"x2": "y2"},
{"x3": "y3"},
{"x3": "y3"},
]
],
)
@pytest.mark.parametrize(("key", "expected"), [("x1", "y1"), ("x2", "y2"), ("x4", None)])
def test_search_list_for_dict_key(self, list_with_dicts, key, expected):
assert search_list_for_dict_key(list_with_dicts, key) == expected

@pytest.mark.parametrize(
"list_with_dicts",
[
[
{"x1": "y1"},
{"x2": "y2"},
{"x3": "y3"},
{"x3": "y4"},
{"x2": "y1"},
]
],
)
@pytest.mark.parametrize(
"key",
[
"x2",
"x3",
],
)
def test_search_list_for_dict_key_value_error(self, list_with_dicts, key):
with pytest.raises(ValueError):
search_list_for_dict_key(list_with_dicts, key)

0 comments on commit ece05dc

Please sign in to comment.