Skip to content

Commit

Permalink
dropping nose tests from circle ci (all in pytest now)
Browse files Browse the repository at this point in the history
  • Loading branch information
edickie committed May 31, 2019
1 parent 7ac66dc commit 55ef455
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 129 deletions.
25 changes: 0 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,6 @@ jobs:
- "/home/venv"
key: deps1-{{ .Branch }}-{{ checksum "/home/ciftify/cifti_requirements.txt" }}

nose:
docker:
- image: mmanogaran/ciftify_ci:0.1
environment:
NOSE_XUNIT_FILE: /home/outputs/nose/nose_result.xml
steps:
- restore_cache:
keys:
- v1-repo-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- deps1-{{ .Branch }}-{{ checksum "/home/ciftify/cifti_requirements.txt" }}
- deps1
- run:
name: run tests
command: |
source /home/venv/bin/activate
mkdir -p /home/outputs/nose/
nosetests --with-xunit -w /homeciftify
- store_artifacts:
path: /home/outputs/nose
destination: nose
- store_test_results:
path: /home/outputs

pytest:
docker:
- image: mmanogaran/ciftify_ci:0.1
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_cifti_vis_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import importlib
import random

from mock import patch
from unittest.mock import patch

vis_map = importlib.import_module('ciftify.bin.cifti_vis_map')

Expand Down
9 changes: 4 additions & 5 deletions tests/test_cifti_vis_recon_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
import logging
import importlib
import random
import pytest

from mock import patch, MagicMock, mock_open
from nose.tools import raises
from unittest.mock import patch, MagicMock, mock_open

recon = importlib.import_module('ciftify.bin.cifti_vis_recon_all')

logging.disable(logging.CRITICAL)

class TestUserSettings(unittest.TestCase):

@raises(SystemExit)
def test_exits_gracefully_when_user_supplies_undefined_qc_mode(self):
arguments = {'<subject>': 'some_subject',
'<QCmode>': 'new_mode',
'--temp-dir': None}
recon.UserSettings(arguments)
assert False
with pytest.raises(SystemExit):
recon.UserSettings(arguments)

class TestModifyTemplateContents(unittest.TestCase):

Expand Down
39 changes: 16 additions & 23 deletions tests/test_ciftify_clean_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pandas as pd
import json

from nose.tools import raises
from mock import patch
import pytest
from unittest.mock import patch

from nibabel import Nifti1Image
import numpy as np
Expand Down Expand Up @@ -72,7 +72,6 @@ def test_that_updated_arg_is_present(self, mock_readable, mock_writable, mock_js
assert settings.detrend == True, "detrend not set to config val"


@raises(SystemExit)
@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
@patch('ciftify.utils.check_output_writable', return_value = True)
def test_exist_gracefully_if_json_not_readable(self, mock_readable, mock_writable):
Expand All @@ -82,23 +81,20 @@ def test_exist_gracefully_if_json_not_readable(self, mock_readable, mock_writabl
missing_json = '/wrong/path/missing.json'
arguments['--clean-config'] = missing_json


settings = ciftify_clean_img.UserSettings(arguments)

assert False
with pytest.raises(SystemExit):
settings = ciftify_clean_img.UserSettings(arguments)


@raises(SystemExit)
@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
@patch('ciftify.utils.check_output_writable', return_value = True)
def test_exists_gracefully_if_input_is_gifti(self, mock_readable, mock_writable):


arguments = copy.deepcopy(self.docopt_args)
arguments['<func_input>'] = '/path/to/input/func.L.func.gii'
settings = ciftify_clean_img.UserSettings(arguments)
with pytest.raises(SystemExit):
settings = ciftify_clean_img.UserSettings(arguments)

assert False


@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
Expand All @@ -123,14 +119,13 @@ def test_nifti_input_returned_correctly(self, mock_readable, mock_writable):
assert settings.func.path == '/path/to/input/myfunc.nii.gz'


@raises(SystemExit)
def test_exists_gracefully_if_output_not_writable(self):

wrong_func = '/wrong/path/to/input/myfunc.nii.gz'
arguments = copy.deepcopy(self.docopt_args)
arguments['<func_input>'] = wrong_func
settings = ciftify_clean_img.UserSettings(arguments)
assert False
with pytest.raises(SystemExit):
settings = ciftify_clean_img.UserSettings(arguments)


@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
Expand All @@ -153,16 +148,15 @@ def test_proper_output_returned_for_cifti(self, mock_readable, mock_writable):
settings = ciftify_clean_img.UserSettings(arguments)
assert settings.output_func == '/path/to/input/myfunc_clean_s0.dtseries.nii'

@raises(SystemExit)
@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
@patch('ciftify.utils.check_output_writable', return_value = True)
def test_exits_when_confounds_tsv_not_given(self, mock_readable, mock_writable):

arguments = copy.deepcopy(self.docopt_args)
arguments['--cf-cols'] = 'one,two,three'
arguments['--confounds-tsv'] = None
settings = ciftify_clean_img.UserSettings(arguments)
assert False
with pytest.raises(SystemExit):
settings = ciftify_clean_img.UserSettings(arguments)

@patch('pandas.read_csv', return_value = pd.DataFrame(columns = ['one', 'two', 'three']))
@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
Expand Down Expand Up @@ -214,18 +208,18 @@ def test_bandpass_filter_returns_float_if_float(self, mock_readable, mock_writab
assert settings.high_pass == 3.14


@raises(SystemExit)

@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
@patch('ciftify.utils.check_output_writable', return_value = True)
def test_exists_gracefully_if_filter_not_float(self, mock_readable, mock_writable):

arguments = copy.deepcopy(self.docopt_args)
arguments['--high-pass'] = 'three'
settings = ciftify_clean_img.UserSettings(arguments)
assert False
with pytest.raises(SystemExit):
settings = ciftify_clean_img.UserSettings(arguments)



@raises(SystemExit)
@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
@patch('ciftify.utils.check_output_writable', return_value = True)
def test_exists_gracefully_if_surfaces_not_present(self, mock_readable, mock_writable):
Expand All @@ -234,9 +228,8 @@ def test_exists_gracefully_if_surfaces_not_present(self, mock_readable, mock_wri
arguments['<func_input>'] = '/path/to/input/myfunc.dtseries.nii'
arguments['--smooth-fwhm'] = 8
arguments['--left-surface'] = None

settings = ciftify_clean_img.UserSettings(arguments)
assert False
with pytest.raises(SystemExit):
settings = ciftify_clean_img.UserSettings(arguments)


@patch('ciftify.utils.check_input_readable', side_effect = _check_input_readble_side_effect)
Expand Down
32 changes: 14 additions & 18 deletions tests/test_ciftify_recon_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import os
from docopt import docopt

from mock import patch
from nose.tools import raises
from unittest.mock import patch
import pytest
import ciftify.utils

logging.disable(logging.CRITICAL)
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_fs_root_dir_set_to_user_value_when_given(self, mock_exists,

assert settings.fs_root_dir == self.arguments['--fs-subjects-dir']

@raises(SystemExit)

@patch('ciftify.config.find_ciftify_global')
@patch('ciftify.config.find_freesurfer_data')
@patch('os.path.exists')
Expand All @@ -241,10 +241,9 @@ def test_exits_when_no_fs_dir_given_and_cannot_find_shell_value(self,
args_copy['--fs-subjects-dir'] = None
# Just in case the shell environment has the variable set...
mock_fs.return_value = None
with pytest.raises(SystemExit):
settings = ciftify_recon_all.Settings(args_copy)

settings = ciftify_recon_all.Settings(args_copy)
# Should never reach this line
assert False

@patch('ciftify.config.find_ciftify_global')
@patch('ciftify.bin.ciftify_recon_all.WorkFlowSettings._WorkFlowSettings__read_settings')
Expand Down Expand Up @@ -309,7 +308,6 @@ def test_msm_config_set_to_default_when_user_config_not_given(self,

assert settings.msm_config is not None

@raises(SystemExit)
@patch('ciftify.config.find_ciftify_global')
@patch('os.path.exists')
def test_sys_exit_raised_when_user_msm_config_doesnt_exist(self, mock_exists,
Expand All @@ -326,11 +324,10 @@ def test_sys_exit_raised_when_user_msm_config_doesnt_exist(self, mock_exists,
args['--surf-reg'] = 'MSMSulc'
args['--MSM-config'] = user_config

settings = ciftify_recon_all.Settings(args)
# Test should never reach this line
assert False
with pytest.raises(SystemExit):
settings = ciftify_recon_all.Settings(args)


@raises(SystemExit)
@patch('ciftify.config.find_ciftify_global')
@patch('os.path.exists')
def test_sys_exit_raised_when_nonlin_xfm_given_alone(self, mock_exists,
Expand All @@ -340,11 +337,10 @@ def test_sys_exit_raised_when_nonlin_xfm_given_alone(self, mock_exists,
mock_exists.side_effect = lambda path: False if path == self.subworkdir else True
args = copy.deepcopy(self.arguments)
args['--read-non-lin-xfm'] = '/some/file'
settings = ciftify_recon_all.Settings(args)
# Test should never reach this line
assert False
with pytest.raises(SystemExit):
settings = ciftify_recon_all.Settings(args)


@raises(SystemExit)
@patch('ciftify.config.find_ciftify_global')
@patch('os.path.exists')
def test_sys_exit_raised_when_lin_xfm_given_alone(self, mock_exists,
Expand All @@ -354,9 +350,9 @@ def test_sys_exit_raised_when_lin_xfm_given_alone(self, mock_exists,
mock_exists.side_effect = lambda path: False if path == self.subworkdir else True
args = copy.deepcopy(self.arguments)
args['--read-lin-premat'] = '/some/file'
settings = ciftify_recon_all.Settings(args)
# Test should never reach this line
assert False
with pytest.raises(SystemExit):
settings = ciftify_recon_all.Settings(args)


@patch('ciftify.utils.check_input_readable')
@patch('os.path.exists')
Expand Down
19 changes: 8 additions & 11 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from subprocess import CalledProcessError
import pkg_resources

from mock import patch
from nose.tools import raises
from unittest.mock import patch
import pytest

import ciftify.config

Expand Down Expand Up @@ -94,21 +94,19 @@ def test_workbench_path_new_line_is_removed(self, mock_out):

class TestWBCommandVersion(unittest.TestCase):

@raises(EnvironmentError)
@patch('ciftify.config.find_workbench')
def test_error_raised_if_not_found(self, mock_find):
mock_find.return_value = None

version = ciftify.config.wb_command_version()
with pytest.raises(EnvironmentError):
version = ciftify.config.wb_command_version()

class TestFreesurferVersion(unittest.TestCase):

@raises(EnvironmentError)
@patch('ciftify.config.find_freesurfer')
def test_raises_error_when_not_found(self, mock_find):
mock_find.return_value = None

version = ciftify.config.freesurfer_version()
with pytest.raises(EnvironmentError):
version = ciftify.config.freesurfer_version()

@patch('ciftify.config.find_freesurfer')
def test_doesnt_crash_if_build_stamp_txt_not_found(self, mock_find):
Expand Down Expand Up @@ -162,12 +160,11 @@ def test_returns_none_if_fsldir_unset_and_which_fails(self, mock_which):

class TestFSLVersion(unittest.TestCase):

@raises(EnvironmentError)
@patch('ciftify.config.find_fsl')
def test_raises_error_when_not_found(self, mock_find):
mock_find.return_value = None

version = ciftify.config.fsl_version()
with pytest.raises(EnvironmentError):
version = ciftify.config.fsl_version()

@patch('ciftify.config.find_fsl')
def test_doesnt_crash_if_version_info_not_found(self, mock_find):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import unittest

from mock import MagicMock, mock_open, patch
from unittest.mock import MagicMock, mock_open, patch

from ciftify import html
import ciftify.qc_config
Expand Down
27 changes: 10 additions & 17 deletions tests/test_niio.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import shutil
import random

from nose.tools import raises
from mock import patch
import pytest
from unittest.mock import patch

import ciftify.niio as niio

Expand Down Expand Up @@ -83,37 +83,30 @@ def test_returns_basename_even_when_full_path_given(self):
assert mr_type == 'cifti'
assert mr_base == 'subject1_data'

@raises(SystemExit)
def test_raises_exception_with_unrecognized_filetype(self):
file_name = 'subject1_data.txt'

mr_type, mr_base = niio.determine_filetype(file_name)
with pytest.raises(SystemExit):
mr_type, mr_base = niio.determine_filetype(file_name)

class TestLoadNii(unittest.TestCase):

@raises(SystemExit)
def test_exits_gracefully_if_nifti_cannot_be_read(self):
path = '/some/path/fake_nifti.nii.gz'
with pytest.raises(SystemExit):
niio.load_nifti(path)

niio.load_nifti(path)

# Should never reach here
assert False

class TestLoadCifti(unittest.TestCase):

@raises(SystemExit)
def test_exits_gracefully_if_cifti_cannot_be_read(self):
path = '/some/path/subject.data.dscalar.nii'
with pytest.raises(SystemExit):
niio.load_cifti(path)

niio.load_cifti(path)
assert False

class TestLoadGiiData(unittest.TestCase):

@raises(SystemExit)
def test_exits_gracefully_if_gifti_cannot_be_read(self):
path = '/some/path/subject.data.shape.gii'

niio.load_gii_data(path)
assert False
with pytest.raises(SystemExit):
niio.load_gii_data(path)
Loading

0 comments on commit 55ef455

Please sign in to comment.