From 86ea110315cc4a436b1e2ac07e26c66a663356ca Mon Sep 17 00:00:00 2001 From: Stijn de Boer Date: Fri, 8 Dec 2023 14:24:54 +0100 Subject: [PATCH] Add a basic test --- pytest_tests/test_normative.py | 53 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/pytest_tests/test_normative.py b/pytest_tests/test_normative.py index 1a5e0b04..2d50981e 100644 --- a/pytest_tests/test_normative.py +++ b/pytest_tests/test_normative.py @@ -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' \ No newline at end of file