1
1
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2
2
# vi: set ft=python sts=4 ts=4 sw=4 et:
3
3
4
- from nipype .testing import (assert_equal , assert_true , assert_almost_equal ,
5
- skipif , utils )
6
- from nipype .workflows .rsfmri .fsl import resting
4
+ from .....testing import (assert_equal , assert_true , assert_almost_equal ,
5
+ skipif , utils )
6
+ from .....interfaces import fsl
7
+
8
+ from ..resting import create_resting_preproc
7
9
8
10
import unittest
9
11
import mock
12
+ from mock import MagicMock
10
13
import nibabel as nb
11
14
import numpy as np
12
15
import os
13
16
17
+ def mock_node_factory (* args , ** kwargs ):
18
+ mock = MagicMock ()
19
+ mock .name = kwargs ['name' ] if 'name' in kwargs .keys () else ''
20
+ if 'interface' in kwargs .keys ():
21
+ mock = mock .create_autospec (kwargs ['interface' ], instance = True )
22
+ mock .iterables = None
23
+ return mock
24
+
14
25
class TestResting (unittest .TestCase ):
15
26
16
27
in_filenames = {
@@ -27,11 +38,15 @@ def setUp(self):
27
38
utils .save_toy_nii (self .fake_data , self .in_filenames ['in_file' ])
28
39
29
40
@skipif (True )
30
- def test_create_resting_preproc (self ):
41
+ @mock .patch ('nipype.pipeline.engine.Workflow._write_report_info' )
42
+ @mock .patch ('nipype.workflows.rsfmri.fsl.resting.create_realign_flow' ,
43
+ side_effect = mock_node_factory )
44
+ @mock .patch ('nipype.pipeline.engine.Node' , side_effect = mock_node_factory )
45
+ def test_create_resting_preproc (self , mock_Node , mock_realign_wf , nothing ):
31
46
# setup
32
47
print (np .random .randint (0 , 10 , (2 , 2 , 2 , 5 )))
33
48
# run
34
- wf = resting . create_resting_preproc ()
49
+ wf = create_resting_preproc ()
35
50
wf .run ()
36
51
37
52
# assert
0 commit comments