diff --git a/src/newcrawler/crawl.py b/src/newcrawler/crawl.py index 6cf0ea9d09b349992380b3bd817cb97462108a28..3940f305de3155ce3d3c716a2882c11601984cfa 100644 --- a/src/newcrawler/crawl.py +++ b/src/newcrawler/crawl.py @@ -233,11 +233,11 @@ class Crawler(object): if not identical: break for key in comp[0]["properties"]: - for attribute in ("datatype", "importance"): - if ("datatype" in comp[0]["properties"][key] and - comp[0]["properties"][key]["datatype"] is not None and - comp[1]["properties"][key]["datatype"] != - comp[1]["properties"][key]["datatype"]): + for attribute in ("datatype", "importance", "unit"): + if (attribute in comp[0]["properties"][key] and + comp[0]["properties"][key][attribute] is not None and + comp[0]["properties"][key][attribute] != + comp[1]["properties"][key][attribute]): identical = False break @@ -251,7 +251,6 @@ class Crawler(object): del updateList[i] continue else: - breakpoint() pass return (insertList, updateList) diff --git a/unittests/test_tool.py b/unittests/test_tool.py index 26525c0d5b51bab1f921532809b176dba6a609b8..13bca20ec96d41fb0fc29f631fed06eaed6952e7 100755 --- a/unittests/test_tool.py +++ b/unittests/test_tool.py @@ -290,6 +290,27 @@ def test_crawler_update_list(crawler, ident): assert len(insl) == 0 assert len(updl) == 0 +def test_identifiable_update(crawler, ident): + # change one value in updateList and then run the synchronization: + meas = [r for r in crawler.updateList if r.parents[0].name == "Measurement"][0] + meas.get_property("responsible").value = [] + insl, updl = crawler.synchronize(crawler.updateList) + assert len(updl) == 1 + +def test_identifiable_update2(crawler, ident): + # change one unit in updateList and then run the synchronization: + meas = [r for r in crawler.updateList if r.parents[0].name == "Measurement"][0] + meas.get_property("description").unit = "cm" + insl, updl = crawler.synchronize(crawler.updateList) + assert len(updl) == 1 + +def test_identifiable_update3(crawler, ident): + # change values of multiple records in updateList and then run the synchronization: + meas = [r for r in crawler.updateList if r.parents[0].name == "Measurement"] + meas[0].get_property("responsible").value = [] + meas[3].get_property("responsible").value = [] + insl, updl = crawler.synchronize(crawler.updateList) + assert len(updl) == 2 def test_identifiable_adapter(): query = IdentifiableAdapter.create_query_for_identifiable(