def transactional_setup_fixture(self, region_mapping_index_factory):
     self.init()
     self.surface_m_p_c = SurfaceModelParametersController()
     SimulatorController().index()
     simulator = cherrypy.session[common.KEY_SIMULATOR_CONFIG]
     region_mapping_index = region_mapping_index_factory()
     simulator.connectivity = region_mapping_index.fk_connectivity_gid
     simulator.surface = CortexViewModel()
     simulator.surface.surface_gid = region_mapping_index.fk_surface_gid
     simulator.surface.region_mapping_data = region_mapping_index.gid
 def transactional_setup_fixture(self, connectivity_factory, surface_factory):
     self.init()
     self.surface_m_p_c = SurfaceModelParametersController()
     SimulatorController().index()
     stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
     _, self.connectivity = connectivity_factory
     _, self.surface = surface_factory
     new_params = {}
     for key, val in SIMULATOR_PARAMETERS.items():
         new_params[key] = {'value': val}
     new_params['connectivity'] = {'value': self.connectivity.gid}
     new_params['surface'] = {'value': self.surface.gid}
     stored_burst.simulator_configuration = new_params
Beispiel #3
0
 def transactional_setup_method(self):
     self.init()
     self.surface_m_p_c = SurfaceModelParametersController()
     BurstController().index()
     stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
     datatypes_factory = DatatypesFactory()
     _, self.connectivity = datatypes_factory.create_connectivity()
     _, self.surface = datatypes_factory.create_surface()
     new_params = {}
     for key, val in SIMULATOR_PARAMETERS.iteritems():
         new_params[key] = {'value': val}
     new_params['connectivity'] = {'value': self.connectivity.gid}
     new_params['surface'] = {'value': self.surface.gid}
     stored_burst.simulator_configuration = new_params
class TestSurfaceModelParametersController(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceModelParametersController """
    
    def transactional_setup_method(self):
        self.init()
        self.surface_m_p_c = SurfaceModelParametersController()
        BurstController().index()
        stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
        datatypes_factory = DatatypesFactory()
        _, self.connectivity = datatypes_factory.create_connectivity()
        _, self.surface = datatypes_factory.create_surface()
        new_params = {}
        for key, val in SIMULATOR_PARAMETERS.iteritems():
            new_params[key] = {'value': val}
        new_params['connectivity'] = {'value': self.connectivity.gid}
        new_params['surface'] = {'value': self.surface.gid}
        stored_burst.simulator_configuration = new_params


    def transactional_teardown_method(self):
        """ Cleans the testing environment """
        self.cleanup()


    def test_edit_model_parameters(self):
        result_dict = self.surface_m_p_c.edit_model_parameters()
        expected_keys = ['urlNormals', 'urlNormalsPick', 'urlTriangles', 'urlTrianglesPick', 
                         'urlVertices', 'urlVerticesPick', 'mainContent', 'inputList',
                         'equationViewerUrl', 'equationsPrefixes', 'data', 'brainCenter',
                         'applied_equations']
        # map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        assert all(x in result_dict for x in expected_keys)
        assert result_dict['equationViewerUrl'] == '/spatial/modelparameters/surface/get_equation_chart'
        assert result_dict['mainContent'] == 'spatial/model_param_surface_main'
Beispiel #5
0
class TestSurfaceModelParametersController(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceModelParametersController """
    def transactional_setup_method(self):
        self.init()
        self.surface_m_p_c = SurfaceModelParametersController()
        BurstController().index()
        stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
        datatypes_factory = DatatypesFactory()
        _, self.connectivity = datatypes_factory.create_connectivity()
        _, self.surface = datatypes_factory.create_surface()
        new_params = {}
        for key, val in SIMULATOR_PARAMETERS.iteritems():
            new_params[key] = {'value': val}
        new_params['connectivity'] = {'value': self.connectivity.gid}
        new_params['surface'] = {'value': self.surface.gid}
        stored_burst.simulator_configuration = new_params

    def transactional_teardown_method(self):
        """ Cleans the testing environment """
        self.cleanup()

    def test_edit_model_parameters(self):
        result_dict = self.surface_m_p_c.edit_model_parameters()
        expected_keys = [
            'urlNormals', 'urlNormalsPick', 'urlTriangles', 'urlTrianglesPick',
            'urlVertices', 'urlVerticesPick', 'mainContent', 'inputList',
            'equationViewerUrl', 'equationsPrefixes', 'data', 'brainCenter',
            'applied_equations'
        ]
        # map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        assert all(x in result_dict for x in expected_keys)
        assert result_dict[
            'equationViewerUrl'] == '/spatial/modelparameters/surface/get_equation_chart'
        assert result_dict['mainContent'] == 'spatial/model_param_surface_main'
class TestSurfaceModelParametersController(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceModelParametersController """

    @pytest.fixture()
    def transactional_setup_fixture(self, region_mapping_index_factory):
        self.init()
        self.surface_m_p_c = SurfaceModelParametersController()
        SimulatorController().index()
        simulator = cherrypy.session[common.KEY_SIMULATOR_CONFIG]
        region_mapping_index = region_mapping_index_factory()
        simulator.connectivity = region_mapping_index.fk_connectivity_gid
        simulator.surface = CortexViewModel()
        simulator.surface.surface_gid = region_mapping_index.fk_surface_gid
        simulator.surface.region_mapping_data = region_mapping_index.gid


    def transactional_teardown_method(self):
        """ Cleans the testing environment """
        self.clean_database()
        self.cleanup()


    def test_edit_model_parameters(self, transactional_setup_fixture):
        result_dict = self.surface_m_p_c.edit_model_parameters()
        expected_keys = ['urlNormals', 'urlNormalsPick', 'urlTriangles', 'urlTrianglesPick', 
                         'urlVertices', 'urlVerticesPick', 'mainContent', 'parametersEquationPlotForm',
                         'baseUrl', 'equationsPrefixes', 'brainCenter', 'applied_equations']
        # map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        assert all(x in result_dict for x in expected_keys)
        assert result_dict['baseUrl'] == '/spatial/modelparameters/surface'
        assert result_dict['mainContent'] == 'spatial/model_param_surface_main'
    def test_edit_model_parameters(self, region_mapping_index_factory):
        self.init()
        surface_m_p_c = SurfaceModelParametersController()
        simulator_controller = SimulatorController()
        simulator_controller.index()
        simulator = simulator_controller.context.simulator
        region_mapping_index = region_mapping_index_factory()
        simulator.connectivity = region_mapping_index.fk_connectivity_gid
        simulator.surface = CortexViewModel()
        simulator.surface.surface_gid = region_mapping_index.fk_surface_gid
        simulator.surface.region_mapping_data = region_mapping_index.gid

        result_dict = surface_m_p_c.edit_model_parameters()
        expected_keys = ['urlNormals', 'urlNormalsPick', 'urlTriangles', 'urlTrianglesPick',
                         'urlVertices', 'urlVerticesPick', 'mainContent', 'parametersEquationPlotForm',
                         'baseUrl', 'equationsPrefixes', 'brainCenter', 'applied_equations']
        # map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        assert all(x in result_dict for x in expected_keys)
        assert result_dict['baseUrl'] == '/spatial/modelparameters/surface'
        assert result_dict['mainContent'] == 'spatial/model_param_surface_main'
 def transactional_setup_method(self):
     self.init()
     self.surface_m_p_c = SurfaceModelParametersController()
     BurstController().index()
     stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
     datatypes_factory = DatatypesFactory()
     _, self.connectivity = datatypes_factory.create_connectivity()
     _, self.surface = datatypes_factory.create_surface()
     new_params = {}
     for key, val in SIMULATOR_PARAMETERS.iteritems():
         new_params[key] = {'value': val}
     new_params['connectivity'] = {'value': self.connectivity.gid}
     new_params['surface'] = {'value': self.surface.gid}
     stored_burst.simulator_configuration = new_params
Beispiel #9
0
def init_cherrypy(arguments=None):
    #### Mount static folders from modules marked for introspection
    arguments = arguments or []
    CONFIGUER = TvbProfile.current.web.CHERRYPY_CONFIGURATION
    for module in arguments:
        module_inst = importlib.import_module(str(module))
        module_path = os.path.dirname(os.path.abspath(module_inst.__file__))
        CONFIGUER["/static_" + str(module)] = {'tools.staticdir.on': True,
                                               'tools.staticdir.dir': '.',
                                               'tools.staticdir.root': module_path}

    #### Mount controllers, and specify the root URL for them.
    cherrypy.tree.mount(BaseController(), "/", config=CONFIGUER)
    cherrypy.tree.mount(UserController(), "/user/", config=CONFIGUER)
    cherrypy.tree.mount(ProjectController(), "/project/", config=CONFIGUER)
    cherrypy.tree.mount(FigureController(), "/project/figure/", config=CONFIGUER)
    cherrypy.tree.mount(FlowController(), "/flow/", config=CONFIGUER)
    cherrypy.tree.mount(SettingsController(), "/settings/", config=CONFIGUER)
    cherrypy.tree.mount(HelpController(), "/help/", config=CONFIGUER)
    cherrypy.tree.mount(SimulatorController(), "/burst/", config=CONFIGUER)
    cherrypy.tree.mount(ParameterExplorationController(), "/burst/explore/", config=CONFIGUER)
    cherrypy.tree.mount(DynamicModelController(), "/burst/dynamic/", config=CONFIGUER)
    cherrypy.tree.mount(SpatioTemporalController(), "/spatial/", config=CONFIGUER)
    cherrypy.tree.mount(RegionsModelParametersController(), "/burst/modelparameters/regions/", config=CONFIGUER)
    cherrypy.tree.mount(SurfaceModelParametersController(), "/spatial/modelparameters/surface/", config=CONFIGUER)
    cherrypy.tree.mount(RegionStimulusController(), "/spatial/stimulus/region/", config=CONFIGUER)
    cherrypy.tree.mount(SurfaceStimulusController(), "/spatial/stimulus/surface/", config=CONFIGUER)
    cherrypy.tree.mount(LocalConnectivityController(), "/spatial/localconnectivity/", config=CONFIGUER)
    cherrypy.tree.mount(NoiseConfigurationController(), "/burst/noise/", config=CONFIGUER)
    cherrypy.tree.mount(HPCController(), "/hpc/", config=CONFIGUER)

    cherrypy.config.update(CONFIGUER)

    # ----------------- Register additional request handlers -----------------
    # This tool checks for MAX upload size
    cherrypy.tools.upload = Tool('on_start_resource', RequestHandler.check_upload_size)
    # This tools clean up files on disk (mainly after export)
    cherrypy.tools.cleanup = Tool('on_end_request', RequestHandler.clean_files_on_disk)
    # ----------------- End register additional request handlers ----------------

    # Register housekeeping job
    if TvbProfile.current.hpc.IS_HPC_RUN and TvbProfile.current.hpc.CAN_RUN_HPC:
        cherrypy.engine.housekeeper = cherrypy.process.plugins.BackgroundTask(
            TvbProfile.current.hpc.BACKGROUND_JOB_INTERVAL, HPCOperationService.check_operations_job)
        cherrypy.engine.housekeeper.start()

    # HTTP Server is fired now ######
    cherrypy.engine.start()