From e25e94740faefdff090369402b553393ca728a72 Mon Sep 17 00:00:00 2001
From: Alexander Schlemmer <alexander@mail-schlemmer.de>
Date: Wed, 4 May 2022 17:16:01 +0200
Subject: [PATCH] TST: finished integration test

---
 .../test_use_case_simple_presentation.py      |  24 +-
 .../use_case_simple_presentation/cfood.yml    | 212 ++++++++----------
 2 files changed, 113 insertions(+), 123 deletions(-)

diff --git a/integrationtests/test_use_case_simple_presentation.py b/integrationtests/test_use_case_simple_presentation.py
index 17da8951..2e8153a2 100644
--- a/integrationtests/test_use_case_simple_presentation.py
+++ b/integrationtests/test_use_case_simple_presentation.py
@@ -45,8 +45,8 @@ def test_complete_crawler(clear_database):
 
     # Insert the data:
     for path in [
-            "/opt/caosdb/mnt/extroot/base/SimulationData",
-            "/opt/caosdb/mnt/extroot/base/DataAnalysis"]:
+            "/opt/caosdb/mnt/extroot/use_case_simple_presentation/ExperimentalData",
+            "/opt/caosdb/mnt/extroot/use_case_simple_presentation/DataAnalysis"]:
         loadpath(
             path=path,
             include=None,
@@ -64,5 +64,21 @@ def test_complete_crawler(clear_database):
                  True,
                  "/extroot")
 
-    res = db.execute_query("FIND Record MonodomainTissueSimulationRun")
-    assert len(res) > 0
+    res = db.execute_query("FIND Record Experiment")
+    assert len(res) == 1
+    assert res[0].get_property("identifier").value == "crawlertest"
+    assert res[0].get_property("date").value == "2022-03-16"
+
+    lf = db.File(id=res[0].get_property("mdfile").value).retrieve()
+    assert lf.path == "/ExperimentalData/data.md"
+
+    assert res[0].get_property("alpha").value == 16.0
+    assert res[0].get_property("alpha").unit == "km"
+
+    res_da = db.execute_query("FIND Record DataAnalysis")
+    assert len(res_da) == 1
+    assert res_da[0].get_property("sources").value[0] == res[0].id
+
+    lf = db.File(id=res_da[0].get_property("mdfile").value).retrieve()
+    assert lf.path == "/DataAnalysis/results.md"
+
diff --git a/integrationtests/use_case_simple_presentation/cfood.yml b/integrationtests/use_case_simple_presentation/cfood.yml
index 840072fd..9cc1bc29 100644
--- a/integrationtests/use_case_simple_presentation/cfood.yml
+++ b/integrationtests/use_case_simple_presentation/cfood.yml
@@ -7,135 +7,109 @@ Definitions:
   #include "description.yml"
 
 Converters: {}
-  
-ExperimentalData:  # name of the converter
+
+extroot:
   type: Directory
-  match: ExperimentalData
+  match: extroot
   subtree:
-    DataFile:
-      type: MarkdownFile
-      match: ^data\.md$
-
-      records:
-        mdfile:
-          parents: []
-          role: File
-          path: $DataFile
-          file: $DataFile
-
-        Experiment:
-          mdfile: $mdfile
-
-            
+    ExperimentalData:  # name of the converter
+      type: Directory
+      match: ExperimentalData
       subtree:
-        date:
-          type: DictTextElement
-          match_name: date
-          match_value: (?P<date>.+)
-          records:
-            Experiment:
-              date: $date
-        identifier:
-          type: DictTextElement
-          match_name: identifier
-          match_value: (?P<identifier>.+)
-          records:
-            Experiment:
-              identifier: $identifier
-        parameter_alpha:
-          type: DictTextElement
-          match_name: alpha
-          match_value: (?P<alpha>[0-9]+)
-          records:
-            Experiment:
-              alpha: $alpha
-        
-#           description:
-#             type: DictTextElement
-#             match_value: (?P<description>.*)
-#             match_name: description
-#             records:
-#               SimulationActivity:
-#                 description: $description
-#           responsible_single:
-#             type: DictTextElement
-#             match_name: responsible
-#             match_value: &person_regexp ((?P<first_name>.+) )?(?P<last_name>.+)
-#               records: &responsible_records
-#                 Person: 
-#                   first_name: $first_name
-#                   last_name: $last_name
-#                   SimulationActivity:
-#                     responsible: +$Person
+        DataFile:
+          type: MarkdownFile
+          match: ^data\.md$
 
-#             responsible_list:
-#               type: DictListElement
-#               match_name: responsible
-#               subtree:
-#                 Person:
-#                   type: TextElement
-#                   match: *person_regexp
-#                   records: *responsible_records
+          records:
+            mdfile:
+              parents: []
+              role: File
+              path: $DataFile
+              file: $DataFile
 
-DataAnalysis:
-  type: Directory
-  match: DataAnalysis
-  subtree:
-    DataFile:
-      type: MarkdownFile
-      match: ^results\.md$
+            Experiment:
+              mdfile: $mdfile
 
-      records:
-        mdfile:
-          parents: []
-          role: File
-          path: $DataFile
-          file: $DataFile
 
-        Experiment: {}
-        
-        DataAnalysis:
-          mdfile: $mdfile
-          sources: +$Experiment
-          
-        
+          subtree:
+            date:
+              type: DictTextElement
+              match_name: date
+              match_value: (?P<date>.+)
+              records:
+                Experiment:
+                  date: $date
+            identifier:
+              type: DictTextElement
+              match_name: identifier
+              match_value: (?P<identifier>.+)
+              records:
+                Experiment:
+                  identifier: $identifier
+            parameter_alpha:
+              type: DictTextElement
+              match_name: alpha
+              match_value: (?P<alpha>[0-9]+)
+              records:
+                Experiment:
+                  alpha: $alpha
 
-            
+    DataAnalysis:
+      type: Directory
+      match: DataAnalysis
       subtree:
-        date:
-          type: DictTextElement
-          match_name: date
-          match_value: (?P<date>.+)
-          records:
-            DataAnalysis:
-              date: $date
-        identifier:
-          type: DictTextElement
-          match_name: identifier
-          match_value: (?P<identifier>.+)
-          records:
-            DataAnalysis:
-              identifier: $identifier
+        DataFile:
+          type: MarkdownFile
+          match: ^results\.md$
 
-        frequency:
-          type: DictTextElement
-          match_name: frequency
-          match_value: (?P<frequency>[0-9]+)
           records:
+            mdfile:
+              parents: []
+              role: File
+              path: $DataFile
+              file: $DataFile
+
+            Experiment: {}
+
             DataAnalysis:
-              frequency: $frequency
+              mdfile: $mdfile
+              sources: +$Experiment
 
-        source_date:
-          type: DictTextElement
-          match_name: source_date
-          match_value: (?P<source_date>.+)
-          records:
-            Experiment:
-              date: $source_date
-        source_identifier:
-          type: DictTextElement
-          match_name: source_identifier
-          match_value: (?P<source_identifier>.+)
-          records:
-            Experiment:
-              identifier: $source_identifier
+          subtree:
+            date:
+              type: DictTextElement
+              match_name: date
+              match_value: (?P<date>.+)
+              records:
+                DataAnalysis:
+                  date: $date
+            identifier:
+              type: DictTextElement
+              match_name: identifier
+              match_value: (?P<identifier>.+)
+              records:
+                DataAnalysis:
+                  identifier: $identifier
+
+            frequency:
+              type: DictTextElement
+              match_name: frequency
+              match_value: (?P<frequency>[0-9]+)
+              records:
+                DataAnalysis:
+                  frequency: $frequency
+
+            source_date:
+              type: DictTextElement
+              match_name: source_date
+              match_value: (?P<source_date>.+)
+              records:
+                Experiment:
+                  date: $source_date
+            source_identifier:
+              type: DictTextElement
+              match_name: source_identifier
+              match_value: (?P<source_identifier>.+)
+              records:
+                Experiment:
+                  identifier: $source_identifier
-- 
GitLab