Skip to content
Snippets Groups Projects
Commit a0855542 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

MAINT: Remove now obsolete _validate_definition

parent e7b65817
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!163F dict heuristic
......@@ -824,27 +824,10 @@ class PropertiesFromDictConverter(DictElementConverter):
"""
def _validate_definition(self):
if "record_from_dict" not in self.definition or self.definition["record_from_dict"] is None:
raise ValueError(
"You need to specify the (root) record, the properties of "
f"which will be set from the dict in converter {self.name}."
)
if not "variable_name" in self.definition["record_from_dict"] or not self.definition["record_from_dict"]["variable_name"]:
raise ValueError(
f"The root record in converter {self.name} needs to have a "
"`variable_name` by which it is accessed in the subtree."
)
def __init__(self, definition: dict, name: str, converter_registry: dict,
referenced_record_callback: Optional[callable] = None):
super().__init__(definition, name, converter_registry)
self._validate_definition()
self.referenced_record_callback = referenced_record_callback
def _recursively_create_records(self, subdict: dict, root_record: db.Record,
......
......@@ -802,31 +802,6 @@ def test_properties_from_dict_basic(converter_registry):
assert author_rec.get_property("full_name").value == "Some Author"
def test_properties_from_dict_errors(converter_registry):
with pytest.raises(ValueError) as ve:
pdfc = PropertiesFromDictConverter(
definition={
},
name="TestConverter",
converter_registry=converter_registry
)
assert "You need to specify the (root) record" in str(ve.value)
with pytest.raises(ValueError) as ve:
pdfc = PropertiesFromDictConverter(
definition={
"record_from_dict": {}
},
name="TestConverter",
converter_registry=converter_registry
)
assert "needs to have a `variable_name`" in str(ve.value)
def test_properties_from_dict_callable(converter_registry):
def convert_some_values(rec: db.Record):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment