|
9 | 9 | import numpy as np |
10 | 10 | import pandas as pd |
11 | 11 | import pytest |
| 12 | +from packaging.version import Version |
12 | 13 |
|
13 | 14 | from cubids.cubids import CuBIDS |
14 | 15 | from cubids.metadata_merge import merge_json_into_json, merge_without_overwrite |
|
22 | 23 | file_hash, |
23 | 24 | get_data, |
24 | 25 | ) |
25 | | -from cubids.validator import build_validator_call, parse_validator_output, run_validator |
| 26 | +from cubids.validator import ( |
| 27 | + build_validator_call, |
| 28 | + parse_validator_output, |
| 29 | + run_validator, |
| 30 | + get_bids_validator_version, |
| 31 | + extract_summary_info, |
| 32 | + update_dataset_description, |
| 33 | + bids_validator_version, |
| 34 | +) |
26 | 35 |
|
27 | 36 | COMPLETE_KEY_GROUPS = [ |
28 | 37 | "acquisition-HASC55AP_datatype-dwi_suffix-dwi", |
@@ -1028,6 +1037,47 @@ def test_validator(tmp_path): |
1028 | 1037 | assert isinstance(parsed, pd.DataFrame) |
1029 | 1038 |
|
1030 | 1039 |
|
| 1040 | +def bids_validator_version(tmp_path): |
| 1041 | + """Test validator.bids_validator_version.""" |
| 1042 | + # Get the BIDS validator version |
| 1043 | + validator_version = get_bids_validator_version() |
| 1044 | + # Extract schemaVersion |
| 1045 | + summary_info = extract_summary_info(decoded) |
| 1046 | + |
| 1047 | + |
| 1048 | +def test_bids_version(tmp_path): |
| 1049 | + """Test workflows.bids_version.""" |
| 1050 | + data_root = get_data(tmp_path) |
| 1051 | + bids_dir = Path(data_root) / "complete" |
| 1052 | + |
| 1053 | + # Ensure the test directory exists |
| 1054 | + assert bids_dir.exists() |
| 1055 | + |
| 1056 | + # test the validator in valid dataset |
| 1057 | + call = build_validator_call(bids_dir) |
| 1058 | + ret = run_validator(call) |
| 1059 | + |
| 1060 | + assert ret.returncode == 0 |
| 1061 | + |
| 1062 | + decoded = ret.stdout.decode("UTF-8") |
| 1063 | + |
| 1064 | + # Get the BIDS validator version |
| 1065 | + validator_version = Version(get_bids_validator_version()["ValidatorVersion"]) |
| 1066 | + # Extract schemaVersion |
| 1067 | + schema_version = Version(extract_summary_info(decoded)["SchemaVersion"]) |
| 1068 | + |
| 1069 | + # Set baseline versions to compare against |
| 1070 | + min_validator_version = Version("2.0.0") |
| 1071 | + min_schema_version = Version("0.11.3") |
| 1072 | + |
| 1073 | + assert ( |
| 1074 | + validator_version >= min_validator_version |
| 1075 | + ), f"Validator version {validator_version} is less than minimum {min_validator_version}" |
| 1076 | + assert ( |
| 1077 | + schema_version >= min_schema_version |
| 1078 | + ), f"Schema version {schema_version} is less than minimum {min_schema_version}" |
| 1079 | + |
| 1080 | + |
1031 | 1081 | def test_docker(): |
1032 | 1082 | """Verify that docker is installed and the user has permission to run docker images. |
1033 | 1083 |
|
|
0 commit comments