From f9ae5c03c00dafd5b797828421a8358bf78a070c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com>
Date: Mon, 20 Feb 2023 21:23:55 +0100
Subject: [PATCH] TST: add file to test entities

---
 .../extroot/realworld_example/dataset_cfoods.yml     | 12 +++++++-----
 .../realworld_example/schema/dataspace.schema.json   |  2 +-
 integrationtests/test_realworld_example.py           |  6 ++++--
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/integrationtests/test_data/extroot/realworld_example/dataset_cfoods.yml b/integrationtests/test_data/extroot/realworld_example/dataset_cfoods.yml
index e149c0cc..117d190b 100644
--- a/integrationtests/test_data/extroot/realworld_example/dataset_cfoods.yml
+++ b/integrationtests/test_data/extroot/realworld_example/dataset_cfoods.yml
@@ -31,11 +31,6 @@ Data:
           type: JSONFile
           match: .dataspace.json
           validate: schema/dataspace.schema.json
-          records:
-            JSONFile:
-              role: File
-              path: $dataspace_json
-              file: $dataspace_json
           subtree:
             jsondict:
               type: DictElement
@@ -158,6 +153,13 @@ Data:
                 metadata_json: &metadata_json_template
                   type: JSONFile
                   match: metadata.json
+                  records:
+                    JSONFile:
+                      parents:
+                        - JSONFile
+                      role: File
+                      path: $metadata_json_path
+                      file: $metadata_json_path
                   validate: schema/dataset.schema.json
                   subtree:
                     jsondict:
diff --git a/integrationtests/test_data/extroot/realworld_example/schema/dataspace.schema.json b/integrationtests/test_data/extroot/realworld_example/schema/dataspace.schema.json
index c6376ee4..36233230 100644
--- a/integrationtests/test_data/extroot/realworld_example/schema/dataspace.schema.json
+++ b/integrationtests/test_data/extroot/realworld_example/schema/dataspace.schema.json
@@ -9,7 +9,7 @@
       "minimum": 20000
     },
     "archived": { "type": "boolean" },
-    "JSONFile": { "type": "string" },
+    "JSONFile": { "type": "object" },
     "url": {
       "type": "string",
       "description": "link to folder on file system (CaosDB or cloud folder)"
diff --git a/integrationtests/test_realworld_example.py b/integrationtests/test_realworld_example.py
index 5542596e..4e3b349c 100644
--- a/integrationtests/test_realworld_example.py
+++ b/integrationtests/test_realworld_example.py
@@ -107,7 +107,8 @@ def test_dataset(clear_database, usemodel, addfiles):
         True,
         os.path.join(DATADIR, "provenance.yml"),
         False,
-        add_prefix="/data"
+        remove_prefix=DATADIR,
+        add_prefix="/extroot/realworld_example"
     )
 
     dataspace = db.execute_query("FIND RECORD Dataspace WITH name=35 AND dataspace_id=20002 AND "
@@ -140,7 +141,8 @@ def test_event_update(clear_database, usemodel, addfiles):
         True,
         os.path.join(DATADIR, "provenance.yml"),
         False,
-        add_prefix="/data"
+        remove_prefix=DATADIR,
+        add_prefix="/extroot/realworld_example"
     )
 
     old_dataset_rec = db.execute_query(
-- 
GitLab