Skip to content

Commit

Permalink
Merge pull request openMetadataInitiative#35 from Peyman-N/testing_nu…
Browse files Browse the repository at this point in the history
…mber_of_subjects

introducing new tests
  • Loading branch information
apdavison authored Apr 30, 2024
2 parents 3bb6c14 + 9d865d3 commit df64ded
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
14 changes: 11 additions & 3 deletions test/test_bids_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

import bids2openminds.converter

example_dataset_labels = ("ds003", "ds000247", "eeg_cbm", "asl001")
example_dataset = [("ds003", 13), ("ds000247", 6),
("eeg_cbm", 20), ("asl001", 1), ("eeg_rest_fmri", 3)]

@pytest.mark.parametrize("dataset_label", example_dataset_labels)
def test_example_datasets(dataset_label):

@pytest.mark.parametrize("dataset_label,dataset_number_subject", example_dataset)
def test_example_datasets(dataset_label, dataset_number_subject):
test_dir = os.path.join("bids-examples", dataset_label)
bids2openminds.converter.convert(test_dir)
c = Collection()
c.load(os.path.join(test_dir, "openminds.jsonld"))

subject_numbers = 0
for item in c:
if item.type_ == 'https://openminds.ebrains.eu/core/Subject':
subject_numbers += 1
assert dataset_number_subject == subject_numbers
24 changes: 14 additions & 10 deletions test/test_example_datasets_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,34 @@
from bids2openminds.converter import convert_click
from click.testing import CliRunner

(test_data_set,number_of_openminds_files)= ("ds003",98)
(test_data_set, number_of_openminds_files) = ("ds003", 98)


def test_example_datasets_click():
test_dir = os.path.join("bids-examples",test_data_set)
test_dir = os.path.join("bids-examples", test_data_set)
runner = CliRunner()
result = runner.invoke(convert_click, [test_dir])
assert result.exit_code == 0
c = Collection()
c.load(os.path.join(test_dir, "openminds.jsonld"))

#todo This section has a problem which have been solved in pull request number 32
""" def test_example_datasets_click_seperate_files():

def test_example_datasets_click_seperate_files():
test_dir = os.path.join("bids-examples", test_data_set)
runner = CliRunner()
result = runner.invoke(convert_click, ["--multiple-file",test_dir])
result = runner.invoke(convert_click, ["--multiple-files", test_dir])
assert result.exit_code == 0
path_openminds=os.path.join(test_dir, "openminds")
numer_of_files=len(os.listdir(path_openminds))
assert numer_of_files==number_of_openminds_files """
path_openminds = os.path.join(test_dir, "openminds")
numer_of_files = len(os.listdir(path_openminds))
assert numer_of_files == number_of_openminds_files


def test_example_datasets_click_output_location():
test_dir = os.path.join("bids-examples", test_data_set)
openminds_file = os.path.join("bids-examples", "test_openminds.jsonld")
runner = CliRunner()
result = runner.invoke(convert_click, ["-o","test_openminds.jsonld",test_dir])
result = runner.invoke(
convert_click, ["-o", openminds_file, test_dir])
assert result.exit_code == 0
c = Collection()
c.load("test_openminds.jsonld")
c.load(openminds_file)

0 comments on commit df64ded

Please sign in to comment.