Skip to content
Snippets Groups Projects
Commit 7c06040e authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

WIP: Begin inttest

parent a3bc82fb
No related branches found
No related tags found
3 merge requests!160STY: styling,!141FIX: Resolve referneces to existing entities correctly,!140New f fix merge
......@@ -20,6 +20,7 @@ from pytest import fixture, mark
import caosdb as db
from caosdb.cached import cache_clear
from caosadvancedtools.models.parser import parse_model_from_string
from caoscrawler.crawl import Crawler
from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter
......@@ -208,3 +209,153 @@ def test_issue_83(clear_database):
assert len(retrieved_referencing3.get_property(referenced_type.name).value) == 2
assert retrieved_target1.id in retrieved_referencing3.get_property(referenced_type.name).value
assert retrieved_target2.id in retrieved_referencing3.get_property(referenced_type.name).value
def test_indiscale_113(clear_database):
"""Somewhat mysterious failures to resolve references in
split_into_inserts_and_updates, see
https://gitlab.indiscale.com/caosdb/src/caosdb-crawler/-/issues/113
"""
# Create and insert minimal datamodel
datamodel_str = """
Dataset:
recommended_properties:
Title:
datatype: TEXT
Abstract:
datatype: TEXT
Event:
Published Dataset:
inherit_from_suggested:
- Dataset
obligatory_properties:
DOI:
datatype: TEXT
Event:
obligatory_properties:
Start datetime:
datatype: DATETIME
longitude:
datatype: DOUBLE
latitude:
datatype: DOUBLE
recommended_properties:
label:
datatype: TEXT
Basis:
Campaign:
Basis:
Campaign:
recommended_properties:
Basis:
"""
model = parse_model_from_string(datamodel_str)
model.sync_data_model(noquestion=True)
# Register identifiables for Dataset (title), Published Dataset (DOI), Event
# (Start datetime, latitude, longitude, label), Basis (name), and Campaign
# (name).
ident = CaosDBIdentifiableAdapter()
ident.register_identifiable("Dataset", db.RecordType().add_parent(
name="Dataset").add_property(name="title"))
ident.register_identifiable("Published Dataset", db.RecordType(
).add_parent(name="Published Dataset").add_property(name="DOI"))
ident.register_identifiable("Event", db.RecordType().add_parent(name="Event").add_property(name="longitude").add_property(
name="latitude").add_property(name="Start datetime").add_property(name="label"))
ident.register_identifiable("Basis", db.RecordType().add_parent(
name="Basis").add_property(name="name"))
ident.register_identifiable("Campaign", db.RecordType().add_parent(
name="Campaign").add_property(name="name"))
crawler = Crawler(identifiableAdapter=ident)
xmls = ["""<Record>
<Parent name="Published Dataset"/>
<Property name="Title" importance="FIX" flag="inheritance:FIX">Chemical analysis from sediment cores in the area of a landslide scar close to the airport of Nice</Property>
<Property name="Abstract" importance="FIX" flag="inheritance:FIX">Submarine groundwater discharge (SGD), the flow of fresh and saline groundwater from the seabed into the coastal ocean, has been intensively investigated in the recent years. This research has usually been restricted to shallow water and intertidal areas, whereas knowledge about groundwater seepage in deeper water is mainly limited to point sources from karstic aquifers. In this study we observed submarine groundwater seepage and a subterranean estuary in sediments at water depths of 20-44 m located within the Ligurian Margin, western Mediterranean Sea. Here, a catastrophic submarine landslide occurred near the Nice airport (French Ligurian coast) in the fall of 1979 after a period of heavy rainfall. During two research cruises, gravity cores were recovered in and around the area of the landslide scar. Pore water samples collected from sediment cores indicated sediments containing freshwater within the landslide scar. Pore water profiles of selected ions, such as chloride, ammonium, manganese, sulfate and barium were used to assess transport and reaction processes within the sediment. A 1-dimensional transport model indicates in most cores upward pore water velocities of 2.3-8.8 cm/yr. This study shows that submarine groundwater seepage along the French Mediterranean coastline can occur at water depths reaching 44 m.</Property>
<Property name="DOI" importance="FIX" flag="inheritance:FIX">https://doi.org/10.1594/PANGAEA.882187</Property>
<Property name="Dataset" datatype="LIST&lt;Dataset&gt;" importance="FIX" flag="inheritance:FIX">
<Value>&lt;Record&gt;
&lt;Parent name="Published Dataset"/&gt;
&lt;Property name="Title" importance="FIX" flag="inheritance:FIX"&gt;(Appendix 3) Different saturation index analysis from sediment cores in the area of a landslide scar close to the airport of Nice&lt;/Property&gt;
&lt;Property name="Abstract" importance="FIX" flag="inheritance:FIX"/&gt;
&lt;Property name="DOI" importance="FIX" flag="inheritance:FIX"&gt;https://doi.org/10.1594/PANGAEA.882184&lt;/Property&gt;
&lt;Property name="Event" datatype="LIST&amp;lt;Event&amp;gt;" importance="FIX" flag="inheritance:FIX"&gt;
&lt;Value&gt;GeoB13952&lt;/Value&gt;
&lt;/Property&gt;
&lt;/Record&gt;
</Value>
</Property>
</Record>""", """<Record>
<Parent name="Published Dataset"/>
<Property name="Title" importance="FIX" flag="inheritance:FIX">(Appendix 3) Different saturation index analysis from sediment cores in the area of a landslide scar close to the airport of Nice</Property>
<Property name="Abstract" importance="FIX" flag="inheritance:FIX"/>
<Property name="DOI" importance="FIX" flag="inheritance:FIX">https://doi.org/10.1594/PANGAEA.882184</Property>
<Property name="Event" datatype="LIST&lt;Event&gt;" importance="FIX" flag="inheritance:FIX">
<Value>GeoB13952</Value>
</Property>
</Record>""", """<Record name="GeoB13952">
<Parent name="Event"/>
<Property name="label" importance="FIX" flag="inheritance:FIX">GeoB13952</Property>
<Property name="Start datetime" importance="FIX" flag="inheritance:FIX">2009-07-03T07:52:36</Property>
<Property name="longitude" importance="FIX" flag="inheritance:FIX">7.22225</Property>
<Property name="latitude" importance="FIX" flag="inheritance:FIX">43.6438</Property>
<Property name="Basis" importance="FIX" flag="inheritance:FIX">Poseidon</Property>
<Property name="Campaign" importance="FIX" flag="inheritance:FIX">POS386</Property>
</Record>""", """<Record name="GeoB13952">
<Parent name="Event"/>
<Property name="label" importance="FIX" flag="inheritance:FIX">GeoB13952</Property>
<Property name="Start datetime" importance="FIX" flag="inheritance:FIX">2009-07-03T07:52:36</Property>
<Property name="longitude" importance="FIX" flag="inheritance:FIX">7.22225</Property>
<Property name="latitude" importance="FIX" flag="inheritance:FIX">43.6438</Property>
<Property name="Basis" importance="FIX" flag="inheritance:FIX">Poseidon</Property>
<Property name="Campaign" importance="FIX" flag="inheritance:FIX">POS386</Property>
</Record>""", """<Record>
<Parent name="Published Dataset"/>
<Property name="Title" importance="FIX" flag="inheritance:FIX">(Appendix 3) Different saturation index analysis from sediment cores in the area of a landslide scar close to the airport of Nice</Property>
<Property name="Abstract" importance="FIX" flag="inheritance:FIX"/>
<Property name="DOI" importance="FIX" flag="inheritance:FIX">https://doi.org/10.1594/PANGAEA.882184</Property>
<Property name="Event" datatype="LIST&lt;Event&gt;" importance="FIX" flag="inheritance:FIX">
<Value>GeoB13952</Value>
</Property>
</Record>""", """<Record name="GeoB13952">
<Parent name="Event"/>
<Property name="label" importance="FIX" flag="inheritance:FIX">GeoB13952</Property>
<Property name="Start datetime" importance="FIX" flag="inheritance:FIX">2009-07-03T07:52:36</Property>
<Property name="longitude" importance="FIX" flag="inheritance:FIX">7.22225</Property>
<Property name="latitude" importance="FIX" flag="inheritance:FIX">43.6438</Property>
<Property name="Basis" importance="FIX" flag="inheritance:FIX">Poseidon</Property>
<Property name="Campaign" importance="FIX" flag="inheritance:FIX">POS386</Property>
</Record>""", """<Record name="Poseidon">
<Parent name="Basis"/>
</Record>""", """<Record name="POS386">
<Parent name="Campaign"/>
<Property name="Basis" importance="FIX" flag="inheritance:FIX">Poseidon</Property>
</Record>"""
]
# recs = db.Container().extend([db.common.models.parse_xml(xml_rec) for xml_rec in xmls])
basis = db.Record(name="Poseidon").add_parent(name="Basis")
campaign = db.Record(name="POS386").add_parent(name="Campaign").add_property(name="Basis", value=basis)
event = db.Record(name="GeoB13952").add_parent(name="Event").add_property(name="label", value="GeoB13952")
event.add_property(name="Start datetime", value="2009-07-03T07:52:36")
event.add_property(name="longitude", value=7.22225)
event.add_property(name="latitude", value=43.6438)
event.add_property(name="Basis", value=basis)
event.add_property(name="Campaign", value=campaign)
ds_child = db.Record().add_parent(name="Published Dataset")
ds_child.add_property(name="Title", value="(Appendix 3) Different saturation index analysis from sediment cores in the area of a landslide scar close to the airport of Nice")
ds_child.add_property(name="Abstract")
ds_child.add_property(name="DOI", value="https://doi.org/10.1594/PANGAEA.882184")
ds_child.add_property(name="Event", value=[event], datatype=db.LIST("Event"))
ds_parent = db.Record().add_parent(name="Published Dataset")
ds_parent.add_property(name="Title", value="Chemical analysis from sediment cores in the area of a landslide scar close to the airport of Nice")
ds_parent.add_property(name="Abstract", value="Submarine groundwater discharge (SGD), the flow of fresh and saline groundwater from the seabed into the coastal ocean, has been intensively investigated in the recent years. This research has usually been restricted to shallow water and intertidal areas, whereas knowledge about groundwater seepage in deeper water is mainly limited to point sources from karstic aquifers. In this study we observed submarine groundwater seepage and a subterranean estuary in sediments at water depths of 20-44 m located within the Ligurian Margin, western Mediterranean Sea. Here, a catastrophic submarine landslide occurred near the Nice airport (French Ligurian coast) in the fall of 1979 after a period of heavy rainfall. During two research cruises, gravity cores were recovered in and around the area of the landslide scar. Pore water samples collected from sediment cores indicated sediments containing freshwater within the landslide scar. Pore water profiles of selected ions, such as chloride, ammonium, manganese, sulfate and barium were used to assess transport and reaction processes within the sediment. A 1-dimensional transport model indicates in most cores upward pore water velocities of 2.3-8.8 cm/yr. This study shows that submarine groundwater seepage along the French Mediterranean coastline can occur at water depths reaching 44 m.")
ds_parent.add_property(name="DOI", value="https://doi.org/10.1594/PANGAEA.882187")
ds_parent.add_property(name="Dataset", datatype=db.LIST("Dataset"), value=ds_child)
# multiples are necessary
recs = [ds_parent, ds_child, event, event, ds_child, event, basis, campaign]
ins, ups = crawler.synchronize(crawled_data=recs, unique_names=False)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment