def test_save(self, mock_writegeo):
     """ Test the save method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     out_file = "/my/path/mock_destination"
     surf.save(out_file)
 def test_labelize(self):
     """ Test the labelize method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     surf.vertices += 1
     label_array, nb_of_labels = surf.labelize(shape=(3, 3, 3))
     self.assertEqual(6, nb_of_labels)
 def test_savevtk(self, mock_vtkpoint, mock_vtkcell, mock_vtkuarray,
                  mock_vtktriangle, mock_vtkpoly, mock_vtkwrite):
     """ Test the save vtk method.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     out_file = "/my/path/mock_destination"
     surf.save_vtk(out_file, inflated=True)
 def test_normal_execution(self):
     """ Test the normal behaviour of the function.
     """
     # Test execution
     surf = TriSurface(**self.kwargs)
     self.assertTrue(numpy.allclose(self.kwargs["vertices"], surf.vertices))
     self.assertTrue(
         numpy.allclose(self.kwargs["triangles"], surf.triangles))
     self.assertTrue(
         numpy.allclose(self.kwargs["inflated_vertices"],
                        surf.inflated_vertices))
     self.assertEqual(surf.shape(), (6, 18, 8))
    def test_voxelize(self, mock_vtkpoint, mock_vtkpoly, mock_poly,
                      mock_vtkslect, mock_vtkutil, mock_vtkwrite):
        """ Test the voxelize vtk method.
        """
        # Set the mocked functions returned values
        mock_poly.return_value = object()
        mock_vtkutil.numpy_support.vtk_to_numpy.return_value = numpy.ones(
            (3, 3, 3), dtype=int)

        # Test execution
        surf = TriSurface(**self.kwargs)
        out_file = "/my/path/mock_destination"
        inside_array = surf.voxelize(shape=(3, 3, 3), tol=0)
        self.assertTrue(
            numpy.allclose(
                inside_array,
                mock_vtkutil.numpy_support.vtk_to_numpy.return_value))