Skip to content
Snippets Groups Projects
Commit 66e15b8f authored by florian's avatar florian
Browse files

ENH: Raise an error in case of unknown filter rules

parent 13045060
No related branches found
No related tags found
2 merge requests!53Release 0.1,!39F children filter
Pipeline #28720 passed
......@@ -337,6 +337,11 @@ class Converter(object):
group: str, rule: str):
"""Filter children according to regexp `expr` and `rule`."""
if rule not in FILTER_FUNCTIONS:
raise RuntimeError(
f"{rule} is not a known filter rule. Only {list(FILTER_FUNCTIONS.keys())} are implemented."
)
to_be_filtered = []
unmatched_children = []
......
......@@ -329,3 +329,22 @@ def test_filter_children_of_directory(converter_registry):
assert children[0].name == "test_2022-01-01.json"
assert children[1].__class__ == File
assert children[1].name == "some_other_file.csv"
dc = DirectoryConverter(
definition={
"match": "(.*)",
"filter": {
"expr": "test_(?P<date>[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}).json",
"group": "date",
"rule": "does_not_exist"
}
},
name="TestBrokenDirectoryConverter",
converter_registry=converter_registry
)
m = dc.match(test_dir)
assert m is not None
with pytest.raises(RuntimeError):
children = dc.create_children(None, test_dir)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment