-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,24 @@ | ||
import pytest_tests | ||
from pcntoolkit.normative import load_response_vars | ||
from pcntoolkit.dataio import fileio | ||
# from dataio import fileio | ||
import pytest | ||
import sys | ||
from unittest import mock | ||
from pcntoolkit.normative import get_args | ||
|
||
import numpy as np | ||
def test_get_args(): | ||
# Define the test arguments | ||
test_args = ['program_name', 'responses', '-f', 'estimate', '-m', 'maskfile', '-c', 'covfile', '-k', '5', '-t', 'testcov', '-r', 'testresp', '-a', 'gpr', '-x', 'configparam'] | ||
|
||
def create_dummy_data(): | ||
# Create a dummy 3D array for the datafile | ||
data = np.random.rand(10, 10, 10) | ||
|
||
# Create a dummy 3D array for the maskfile | ||
mask = np.ones((10, 10, 10)) | ||
|
||
return data, mask | ||
|
||
# Use the function to create the dummy data | ||
data, mask = create_dummy_data() | ||
|
||
# Store the dummy data on disk | ||
datafile = 'test_data.nii.gz' | ||
maskfile = 'test_mask.nii.gz' | ||
fileio.save_nifti(data, datafile) | ||
fileio.save_nifti(mask, maskfile) | ||
|
||
|
||
def test_load_response_vars(): | ||
|
||
# Call the function with the test inputs | ||
Y, volmask,my_str = load_response_vars(datafile, maskfile, vol=True) | ||
# Replace sys.argv with the test arguments | ||
with mock.patch.object(sys, 'argv', test_args): | ||
# Call the function with the test arguments | ||
args = get_args() | ||
|
||
# Assert that the function returns the expected results | ||
# This will depend on what you expect the function to return | ||
# For example, you might check that Y and volmask are not None | ||
assert Y is not None | ||
assert volmask is not None | ||
assert my_str == 'test' | ||
assert args.responses == 'responses' | ||
assert args.func == 'estimate' | ||
assert args.maskfile == 'maskfile' | ||
assert args.covfile == 'covfile' | ||
assert args.cvfolds == '5' | ||
assert args.testcov == 'testcov' | ||
assert args.testresp == 'testresp' | ||
assert args.alg == 'gpr' | ||
assert args.configparam == 'configparam' |