Skip to content

Commit df64ded

Browse files
authored
Merge pull request #35 from Peyman-N/testing_number_of_subjects
introducing new tests
2 parents 3bb6c14 + 9d865d3 commit df64ded

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

test/test_bids_examples.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@
44

55
import bids2openminds.converter
66

7-
example_dataset_labels = ("ds003", "ds000247", "eeg_cbm", "asl001")
7+
example_dataset = [("ds003", 13), ("ds000247", 6),
8+
("eeg_cbm", 20), ("asl001", 1), ("eeg_rest_fmri", 3)]
89

9-
@pytest.mark.parametrize("dataset_label", example_dataset_labels)
10-
def test_example_datasets(dataset_label):
10+
11+
@pytest.mark.parametrize("dataset_label,dataset_number_subject", example_dataset)
12+
def test_example_datasets(dataset_label, dataset_number_subject):
1113
test_dir = os.path.join("bids-examples", dataset_label)
1214
bids2openminds.converter.convert(test_dir)
1315
c = Collection()
1416
c.load(os.path.join(test_dir, "openminds.jsonld"))
17+
18+
subject_numbers = 0
19+
for item in c:
20+
if item.type_ == 'https://openminds.ebrains.eu/core/Subject':
21+
subject_numbers += 1
22+
assert dataset_number_subject == subject_numbers

test/test_example_datasets_click.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,34 @@
33
from bids2openminds.converter import convert_click
44
from click.testing import CliRunner
55

6-
(test_data_set,number_of_openminds_files)= ("ds003",98)
6+
(test_data_set, number_of_openminds_files) = ("ds003", 98)
7+
78

89
def test_example_datasets_click():
9-
test_dir = os.path.join("bids-examples",test_data_set)
10+
test_dir = os.path.join("bids-examples", test_data_set)
1011
runner = CliRunner()
1112
result = runner.invoke(convert_click, [test_dir])
1213
assert result.exit_code == 0
1314
c = Collection()
1415
c.load(os.path.join(test_dir, "openminds.jsonld"))
1516

16-
#todo This section has a problem which have been solved in pull request number 32
17-
""" def test_example_datasets_click_seperate_files():
17+
18+
def test_example_datasets_click_seperate_files():
1819
test_dir = os.path.join("bids-examples", test_data_set)
1920
runner = CliRunner()
20-
result = runner.invoke(convert_click, ["--multiple-file",test_dir])
21+
result = runner.invoke(convert_click, ["--multiple-files", test_dir])
2122
assert result.exit_code == 0
22-
path_openminds=os.path.join(test_dir, "openminds")
23-
numer_of_files=len(os.listdir(path_openminds))
24-
assert numer_of_files==number_of_openminds_files """
23+
path_openminds = os.path.join(test_dir, "openminds")
24+
numer_of_files = len(os.listdir(path_openminds))
25+
assert numer_of_files == number_of_openminds_files
26+
2527

2628
def test_example_datasets_click_output_location():
2729
test_dir = os.path.join("bids-examples", test_data_set)
30+
openminds_file = os.path.join("bids-examples", "test_openminds.jsonld")
2831
runner = CliRunner()
29-
result = runner.invoke(convert_click, ["-o","test_openminds.jsonld",test_dir])
32+
result = runner.invoke(
33+
convert_click, ["-o", openminds_file, test_dir])
3034
assert result.exit_code == 0
3135
c = Collection()
32-
c.load("test_openminds.jsonld")
36+
c.load(openminds_file)

0 commit comments

Comments
 (0)