From 39a73d9909b1186873b8314aacb47c60d38031b2 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <alexander@mail-schlemmer.de> Date: Thu, 20 Jan 2022 14:09:10 +0100 Subject: [PATCH] TST: added another test for insertion instead of update of identifiables --- integrationtests/test.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/integrationtests/test.py b/integrationtests/test.py index a5654fb5..b84e9f88 100755 --- a/integrationtests/test.py +++ b/integrationtests/test.py @@ -153,14 +153,46 @@ def test_identifiable_update(clear_database, usemodel, ident, crawler): cr = Crawler(debug=True, identifiableAdapter=ident) crawl_standard_test_directory(cr) + # Test the addition of a single property: l = cr.updateList for record in l: - if record.parents[0].name == "Measurement": + if (record.parents[0].name == "Measurement" and + record.get_property("date").value == "2020-01-03"): # maybe a bit weird, but add an email address to a measurement record.add_property(name="email", value="testperson@testaccount.test") print("one change") break - breakpoint() ins, ups = cr.synchronize() assert len(ins) == 0 assert len(ups) == 1 + + + # Test the change within one property: + cr = Crawler(debug=True, identifiableAdapter=ident) + crawl_standard_test_directory(cr) + l = cr.updateList + for record in l: + if (record.parents[0].name == "Measurement" and + record.get_property("date").value == "2020-01-03"): + record.add_property(name="email", value="testperson@coolmail.test") + print("one change") + break + ins, ups = cr.synchronize() + assert len(ins) == 0 + assert len(ups) == 1 + + # Changing the date should result in a new insertion: + cr = Crawler(debug=True, identifiableAdapter=ident) + crawl_standard_test_directory(cr) + l = cr.updateList + for record in l: + if (record.parents[0].name == "Measurement" and + record.get_property("date").value == "2020-01-03"): + record.add_property(name="email", value="testperson@coolmail.test") + record.get_property("date").value = "2012-01-02" + print("one change") + break + breakpoint() + ins, ups = cr.synchronize() + assert len(ins) == 1 + assert len(ups) == 0 -- GitLab