Skip to content
Snippets Groups Projects

TST: add test for query and some minor changes

Merged Henrik tom Wörden requested to merge f-query into dev
1 unresolved thread
3 files
+ 55
30
Compare changes
  • Side-by-side
  • Inline

Files

+ 18
7
@@ -344,15 +344,23 @@ class Crawler(object):
if isinstance(val, db.Entity):
el.value[index] = val.id
def remove_unnecessary_updates(self, updateList: list[db.Record]):
@staticmethod
def remove_unnecessary_updates(updateList: list[db.Record],
identified_records: list[db.Record]):
"""
checks whether all relevant attributes (especially Property values) are equal
Returns (in future)
-------
update list without unecessary updates
"""
if len(updateList) != len(identified_records):
raise RuntimeError("The lists of updates and of identified records need to be of the "
"same length!")
# TODO this can now easily be changed to a function without side effect
for i in reversed(range(len(updateList))):
record = updateList[i]
identifiable = self.identifiableAdapter.retrieve_identifiable(record)
comp = compare_entities(record, identifiable)
comp = compare_entities(updateList[i], identified_records[i])
identical = True
for j in range(2):
# TODO: should be implemented elsewhere (?)
@@ -364,7 +372,8 @@ class Crawler(object):
break
for key in comp[0]["properties"]:
for attribute in ("datatype", "importance", "unit"):
# only make an update for those attributes if there is a value difference and
# the value in the updateList is not None
if attribute in comp[0]["properties"][key]:
attr_val = comp[0]["properties"][key][attribute]
other_attr_val = (comp[1]["properties"][key][attribute]
@@ -407,7 +416,9 @@ class Crawler(object):
for el in to_be_updated:
self.replace_entities_by_ids(el)
self.remove_unnecessary_updates(to_be_updated)
identified_records = [self.identifiableAdapter.retrieve_identifiable(record) for record
in to_be_updated]
self.remove_unnecessary_updates(to_be_updated, identified_records)
# TODO
# self.execute_inserts_in_list(to_be_inserted)
Loading