Skip to content

Commit

Permalink
#234: Fix missing brackets on include filter logic
Browse files Browse the repository at this point in the history
- `join()` only accepts iterables, not multiple strings
- This commit also adds a test case to cover this
  • Loading branch information
MRichards99 committed May 24, 2021
1 parent b18da3b commit 2961b18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion datagateway_api/common/icat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ def _extract_filter_fields(self, field):
self._extract_filter_fields(".".join((key, element)))
elif isinstance(element, list):
for sub_element in element:
self._extract_filter_fields(".".join(key, sub_element))
self._extract_filter_fields(
".".join((key, sub_element)),
)
elif isinstance(element, dict):
for (
inner_element_key,
Expand Down
7 changes: 6 additions & 1 deletion test/icat/filters/test_include_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ class TestICATIncludeFilter:
"investigationUsers.user.userGroups",
"investigationUsers.investigation",
},
id="Complex use case used similarly in DataGateway",
id="complex use case used similarly in DataGateway",
),
pytest.param(
{"investigationUsers": [["investigation.datasets"]]},
{"investigationUsers.investigation.datasets"},
id="dictionary with nested list value",
),
],
)
Expand Down

0 comments on commit 2961b18

Please sign in to comment.