Skip to content
Snippets Groups Projects
Commit ab1e6de7 authored by florian's avatar florian
Browse files

WIP: Unittest

parent a87ed23f
No related branches found
No related tags found
2 merge requests!91Release 0.3,!62Fix merge conflict in split_into_inserts_and_updates
......@@ -22,7 +22,10 @@
from pytest import mark
import caosdb as db
from caoscrawler.crawl import Crawler
from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter
from caoscrawler.structure_elements import DictElement
from test_tool import rfp
......@@ -68,3 +71,40 @@ def test_issue_10():
assert records[0].parents[0].name == "TestRec"
assert records[0].get_property("float_prop") is not None
assert float(records[0].get_property("float_prop").value) == 4.0
def test_issue_39():
"""Test for merge conflicts in
`crawl.Crawler.split_into_inserts_and_updates` (see
https://gitlab.com/caosdb/caosdb-crawler/-/issues/39).
"""
crawler = Crawler(debug=True)
# For trying and failing to retrieve remotely identified records
def _fake_retrieve(*args, **kwargs):
return None
ident = CaosDBIdentifiableAdapter()
# identifiable property is just name for both Record Types
ident.register_identifiable("RT_A", db.RecordType().add_parent(
name="RT_A").add_property(name="name"))
ident.register_identifiable("RT_B", db.RecordType().add_parent(
name="RT_B").add_property(name="name"))
# overwrite retrieve
ident.retrieve_identified_record_for_identifiable = _fake_retrieve
crawler.identifiableadapter = ident
# a1 (has id) references b1 (has no id)
a1 = db.Record(name="A", id=101).add_parent(name="RT_A")
b1 = db.Record(name="B").add_parent(name="RT_B")
# a2 (no id) references b2 (has id)
a2 = db.Record(name="A").add_parent(name="RT_A")
b2 = db.Record(name="B", id=102).add_parent(name="RT_B")
flat_list = [b2, a2, a1, b1]
ins, ups = crawler.split_into_inserts_and_updates(flat_list)
print(ins)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment