Skip to content
Snippets Groups Projects
Commit ae87fa1e authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

TST: fix int test

parent 3d253fac
Branches
Tags
1 merge request!2ENH: Folder
...@@ -3,10 +3,16 @@ ...@@ -3,10 +3,16 @@
## Testing ## Testing
Requires `bidsconverter` module: https://gitlab.indiscale.com/caosdb/src/crawler-converters/bids-converter Requires `bidsconverter` module: https://gitlab.indiscale.com/caosdb/src/crawler-converters/bids-converter
### Unit Tests
Run `pytest unittests` Run `pytest unittests`
### Integration Tests
After you started a server with the `test-profile` (see `integrationtests` folder) After you started a server with the `test-profile` (see `integrationtests` folder)
you can run `pytest -x .` in `integrationtest`. you can run `pytest -x .` in `integrationtest`.
### Manual Tests
You can crawl examples from the `bids-examples` submodule:
## Usage ## 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. into your cfood.
...@@ -21,7 +21,8 @@ default: ...@@ -21,7 +21,8 @@ default:
# extroot: From where files are copied/symlinked. This is a # extroot: From where files are copied/symlinked. This is a
# list of `NAME: PATH` pairs or a single path. # list of `NAME: PATH` pairs or a single path.
extroot: extroot:
"": "../../bids-examples/" "examples": "../../bids-examples/"
"valid_dataset": "../../unittests/test_data/valid_dataset/"
# #
# "base": "/path/to/base/dir" # "base": "/path/to/base/dir"
# "other": "/path/to/other" # "other": "/path/to/other"
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
import sys import sys
import json import json
import logging
import pytest import pytest
import os import os
...@@ -65,14 +66,15 @@ def test_folders(clear_database, usemodel): ...@@ -65,14 +66,15 @@ def test_folders(clear_database, usemodel):
# Load and register converter packages: # Load and register converter packages:
converter_registry = crawler.load_converters(crawler_definition) converter_registry = crawler.load_converters(crawler_definition)
# print("DictIntegerElement" in converter_registry)
logger = logging.getLogger("caoscrawler")
logger.setLevel(logging.DEBUG)
records = crawler.start_crawling( records = crawler.start_crawling(
Directory('valid_dataset', rfp("../unittests/test_data/valid_dataset")), Directory('valid_dataset', rfp("../unittests/test_data/valid_dataset")),
crawler_definition, crawler_definition,
converter_registry converter_registry
) )
crawler.save_debug_data("prov.yml")
files = [fi for fi in records if isinstance(fi, db.File)] files = [fi for fi in records if isinstance(fi, db.File)]
for fi in files: for fi in files:
fi.file = __file__ fi.file = __file__
...@@ -88,5 +90,5 @@ def test_folders(clear_database, usemodel): ...@@ -88,5 +90,5 @@ def test_folders(clear_database, usemodel):
assert len(funcs) == 30 assert len(funcs) == 30
assert len(anats) == 10 assert len(anats) == 10
for el in funcs: for el in funcs:
assert (len(el.get_property("RawData").value) == 2 assert (len(el.get_property("FunctionalImagingDataFile").value) == 2
or len(el.get_property("RawData").value) == 3) or len(el.get_property("FunctionalImagingDataFile").value) == 3)
...@@ -92,7 +92,7 @@ metadata: ...@@ -92,7 +92,7 @@ metadata:
definition: definition:
${parent}_datafile: ${parent}_datafile:
type: SimpleFile 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]+)$ 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: records:
someFile: someFile:
...@@ -384,7 +384,7 @@ project_level: ...@@ -384,7 +384,7 @@ project_level:
Subject: Subject:
Session: +$Session Session: +$Session
subtree: subtree:
func: func:
type: BIDSFUNCDirectory type: BIDSFUNCDirectory
match: ^(?P<datatype>func)$ match: ^(?P<datatype>func)$
subtree: subtree:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment