Skip to content
Snippets Groups Projects

Draft: Synchronization with existing IDs

Open Alexander Schlemmer requested to merge f-existing-file-id into dev
1 file
+ 31
0
Compare changes
  • Side-by-side
  • Inline
@@ -434,3 +434,34 @@ def test_issue_14(clear_database):
@@ -434,3 +434,34 @@ def test_issue_14(clear_database):
records = db.execute_query("FIND Record")
records = db.execute_query("FIND Record")
assert len(records) == 1
assert len(records) == 1
assert records[0].get_property("RT2").value == f_test.id
assert records[0].get_property("RT2").value == f_test.id
 
 
 
def test_issue_existing_file_id(clear_database):
 
"""
 
Issue title: Synchronization with IDs fails
 
 
https://gitlab.indiscale.com/caosdb/src/caosdb-crawler/-/issues/174
 
"""
 
 
rt1 = db.RecordType(name="RT1")
 
rt2 = db.RecordType(name="RT2").insert()
 
rt1.add_property(rt2, importance=db.OBLIGATORY)
 
rt1.insert()
 
 
r = db.Record()
 
r.add_parent(rt1)
 
with tempfile.NamedTemporaryFile() as tmpf:
 
f = db.File(name="test_parent", path="parent_test/file.txt", file=tmpf.name)
 
f.insert()
 
 
f2 = db.File(name="test_parent", path="parent_test/file.txt", file=tmpf.name)
 
f2.id = f.id
 
 
f2.add_parent(rt2)
 
r.add_property(name="RT2", value=f2)
 
 
ident = CaosDBIdentifiableAdapter()
 
ident.register_identifiable("RT1", db.RecordType().add_parent(
 
name="RT1").add_property(name="RT2"))
 
crawler = Crawler(identifiableAdapter=ident)
 
crawler.synchronize(crawled_data=[f2, r])
Loading