def setUp(self):
     """
     Sets up the environment for testing;
     creates a `BurstController`
     """
     BaseControllersTest.init(self)
     self.burst_c = BurstController()
    def setUp(self):
        """
        Sets up the environment for testing
        creates a `NoiseConfigurationController`
        """
        self.init()
        self.noise_c = NoiseConfigurationController()
        _, self.connectivity = DatatypesFactory().create_connectivity()
        BurstController().index()

        stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]

        new_params = {}
        for key, val in SIMULATOR_PARAMETERS.iteritems():
            new_params[key] = {'value': val}
        new_params['connectivity'] = {'value': self.connectivity.gid}

        # Simulate selection of a specific integration  from the ui
        new_params[PARAM_INTEGRATOR] = {'value': EulerStochastic.__name__}
        new_params[PARAM_MODEL] = {'value': Generic2dOscillator.__name__}
        new_params[INTEGRATOR_PARAMETERS + '_option_EulerStochastic_noise'] = {
            'value': Additive.__name__
        }
        stored_burst.simulator_configuration = new_params

        self.noise_c.index()
Beispiel #3
0
 def setup_method(self):
     """
     Sets up the environment for testing;
     creates a `FlowController`
     """
     self.init()
     self.flow_c = FlowController()
     self.burst_c = BurstController()
     self.operation_service = OperationService()
Beispiel #4
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
 def transactional_setup_fixture(self, connectivity_factory,
                                 surface_factory):
     self.init()
     self.surface_m_p_c = SurfaceModelParametersController()
     BurstController().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
 def transactional_setup_fixture(self, connectivity_factory):
     """
     Sets up the environment for testing;
     creates a `RegionsModelParametersController` and a connectivity
     """
     self.init()
     self.region_m_p_c = RegionsModelParametersController()
     BurstController().index()
     stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
     _, self.connectivity = connectivity_factory
     new_params = {}
     for key, val in SIMULATOR_PARAMETERS.items():
         new_params[key] = {'value': val}
     new_params['connectivity'] = {'value': self.connectivity.gid}
     stored_burst.simulator_configuration = new_params
     self._setup_dynamic()
Beispiel #7
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 = __import__(str(module), globals(), locals(), ["__init__"])
        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(BurstController(), "/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(SimulatorController(), "/api/simulator/", 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 ----------------

    #### HTTP Server is fired now ######  
    cherrypy.engine.start()
    def test_submit_noise_configuration_happy(self, connectivity_factory):
        self.init()
        self.noise_c = NoiseConfigurationController()
        _, self.connectivity = connectivity_factory()
        BurstController().index()

        stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]

        new_params = {}
        for key, val in SIMULATOR_PARAMETERS.items():
            new_params[key] = {'value': val}
        new_params['connectivity'] = {'value': self.connectivity.gid}

        # Simulate selection of a specific integration  from the ui
        new_params[PARAM_INTEGRATOR] = {'value': EulerStochastic.__name__}
        new_params[PARAM_MODEL] = {'value': Generic2dOscillator.__name__}
        new_params[INTEGRATOR_PARAMETERS + '_option_EulerStochastic_noise'] = {'value': Additive.__name__}
        stored_burst.simulator_configuration = new_params
        """
        Submit noise configuration writes the noise array on the required key in the burst configuration
        """
        # a noise configuration in the format expected by submit. Assumes Generic2dOscillator model.
        nodes_range = list(range(self.connectivity.number_of_regions))
        noise_in = [{'V': 1.0, 'W': 2.0} for _ in nodes_range]
        noise_in = json.dumps(noise_in)

        # expected noise array in burst config
        expected_noise_arr = [[1.0 for _ in nodes_range], [2.0 for _ in nodes_range]]

        self._expect_redirect('/burst/', self.noise_c.submit, noise_in)

        simulator_configuration = cherrypy.session[common.KEY_BURST_CONFIG].simulator_configuration
        nsig_key = 'integrator_parameters_option_EulerStochastic_noise_parameters_option_Additive_nsig'
        actual_noise_arr = json.loads(simulator_configuration[nsig_key]['value'])

        assert expected_noise_arr == actual_noise_arr