From ae87fa1e6b260a2f309f6a8a06749e4b982bd250 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 16:44:09 +0100
Subject: [PATCH] TST: fix int test

---
 README_SETUP.md                                     |  8 +++++++-
 integrationtests/test-profile/profile.yml           |  3 ++-
 integrationtests/test_bids_folderstructure_cfood.py | 10 ++++++----
 src/bids-cfood/cfood.yml                            |  4 ++--
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/README_SETUP.md b/README_SETUP.md
index 84fdfab..c93d774 100644
--- a/README_SETUP.md
+++ b/README_SETUP.md
@@ -3,10 +3,16 @@
 ## Testing
 Requires `bidsconverter` module: https://gitlab.indiscale.com/caosdb/src/crawler-converters/bids-converter
 
+### Unit Tests
 Run `pytest unittests`
+
+### Integration Tests
 After you started a server with the `test-profile` (see `integrationtests` folder) 
 you can run `pytest -x .` in `integrationtest`.
 
+### Manual Tests
+You can crawl examples from the `bids-examples` submodule:
+
 ## Usage
-You will need to copy the cfood definition `./src/bids-cfood/dataset_description_cfood.yml`
+You will need to copy (parts of) the cfood definition `./src/bids-cfood/cfood.yml`
 into your cfood.
diff --git a/integrationtests/test-profile/profile.yml b/integrationtests/test-profile/profile.yml
index 3bde561..a02cdeb 100644
--- a/integrationtests/test-profile/profile.yml
+++ b/integrationtests/test-profile/profile.yml
@@ -21,7 +21,8 @@ default:
     # extroot: From where files are copied/symlinked.  This is a
     # list of `NAME: PATH` pairs or a single path.  
     extroot:
-      "": "../../bids-examples/"
+      "examples": "../../bids-examples/"
+      "valid_dataset": "../../unittests/test_data/valid_dataset/"
     #
     #  "base": "/path/to/base/dir"
     #  "other": "/path/to/other"
diff --git a/integrationtests/test_bids_folderstructure_cfood.py b/integrationtests/test_bids_folderstructure_cfood.py
index f96eef7..a43d7f3 100644
--- a/integrationtests/test_bids_folderstructure_cfood.py
+++ b/integrationtests/test_bids_folderstructure_cfood.py
@@ -23,6 +23,7 @@
 
 import sys
 import json
+import logging
 import pytest
 import os
 
@@ -65,14 +66,15 @@ def test_folders(clear_database, usemodel):
 
     # Load and register converter packages:
     converter_registry = crawler.load_converters(crawler_definition)
-    # print("DictIntegerElement" in converter_registry)
 
+    logger = logging.getLogger("caoscrawler")
+    logger.setLevel(logging.DEBUG)
     records = crawler.start_crawling(
         Directory('valid_dataset', rfp("../unittests/test_data/valid_dataset")),
         crawler_definition,
         converter_registry
     )
-
+    crawler.save_debug_data("prov.yml")
     files = [fi for fi in records if isinstance(fi, db.File)]
     for fi in files:
         fi.file = __file__
@@ -88,5 +90,5 @@ def test_folders(clear_database, usemodel):
     assert len(funcs) == 30
     assert len(anats) == 10
     for el in funcs:
-        assert (len(el.get_property("RawData").value) == 2
-                or len(el.get_property("RawData").value) == 3)
+        assert (len(el.get_property("FunctionalImagingDataFile").value) == 2
+                or len(el.get_property("FunctionalImagingDataFile").value) == 3)
diff --git a/src/bids-cfood/cfood.yml b/src/bids-cfood/cfood.yml
index d5abf87..5070378 100644
--- a/src/bids-cfood/cfood.yml
+++ b/src/bids-cfood/cfood.yml
@@ -92,7 +92,7 @@ metadata:
     definition:
       ${parent}_datafile:
         type: SimpleFile
-        debug_match: True
+        debug_match: False
         match: ^sub-(?P<sub>[a-zA-Z0-9]+)(_ses-(?P<ses>[a-zA-Z0-9]+))?((_task-(?P<task>[a-zA-Z0-9]+))|(_acq-(?P<acq>[a-zA-Z0-9]+))|(_run-(?P<run>[a-zA-Z0-9]+))|(_space-(?P<space>[a-zA-Z0-9]+))|(_recording-(?P<recording>[a-zA-Z0-9]+)))*(_(?P<suffix>${suffix}))?\.(?P<extension>[.a-zA-Z0-9]+)$
         records:
           someFile:
@@ -384,7 +384,7 @@ project_level:
             Subject:
               Session: +$Session
           subtree:
-            func: 
+            func:
               type: BIDSFUNCDirectory
               match: ^(?P<datatype>func)$
               subtree:
-- 
GitLab