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
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()
def test_submit_noise_configuration_happy(self, connectivity_factory): self.init() self.noise_c = NoiseConfigurationController() self.connectivity = connectivity_factory() SimulatorController().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': ModelsEnum.GENERIC_2D_OSCILLATOR.get_class().__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