def test_draw_discrete_exploration(self, datatype_group_factory, define_attributes): """ Test that Discrete PSE is getting launched and correct fields are prepared. """ self.dt_group = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_discrete_exploration( self.dt_group.gid, 'burst', None, None) assert result['available_metrics'] == list( define_attributes['DATATYPE_MEASURE_METRIC']) assert result['color_metric'] == list( define_attributes['DATATYPE_MEASURE_METRIC'])[0] assert result['size_metric'] is None assert define_attributes['RANGE_1'][1] == json.loads( result['labels_x']) assert define_attributes['RANGE_2'][1] == json.loads( result['labels_y']) data = json.loads(result['d3_data']) assert len(data) == len(define_attributes['RANGE_1'][1]) for row in data.values(): assert len(row) == len(define_attributes['RANGE_2'][1]) for entry in row.values(): assert entry['dataType'] == 'Datatype2' for key in ['Gid', 'color_weight', 'operationId', 'tooltip']: assert key in entry
def setUp(self): """ Sets up the environment for testing; creates a datatype group and a Parameter Exploration Controller """ self.init() self.dt_group = DatatypesFactory().create_datatype_group() self.controller = ParameterExplorationController()
class TestExplorationController(BaseTransactionalControllerTest): """ Unit tests ParameterExplorationController """ # def transactional_setup_method(self): # """ # Sets up the environment for testing; # creates a datatype group and a Parameter Exploration Controller # """ # self.init() # self.dt_group = DatatypesFactory().create_datatype_group() # self.controller = ParameterExplorationController() def transactional_teardown_method(self): """ Cleans the testing environment """ self.cleanup() def test_draw_discrete_exploration(self, datatype_group_factory, define_attributes): """ Test that Discrete PSE is getting launched and correct fields are prepared. """ self.dt_group = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_discrete_exploration( self.dt_group.gid, 'burst', None, None) assert result['available_metrics'] == list( define_attributes['DATATYPE_MEASURE_METRIC']) assert result['color_metric'] == list( define_attributes['DATATYPE_MEASURE_METRIC'])[0] assert result['size_metric'] is None assert define_attributes['RANGE_1'][1] == json.loads( result['labels_x']) assert define_attributes['RANGE_2'][1] == json.loads( result['labels_y']) data = json.loads(result['d3_data']) assert len(data) == len(define_attributes['RANGE_1'][1]) for row in data.values(): assert len(row) == len(define_attributes['RANGE_2'][1]) for entry in row.values(): assert entry['dataType'] == 'Datatype2' for key in ['Gid', 'color_weight', 'operationId', 'tooltip']: assert key in entry def test_draw_isocline_exploration(self, datatype_group_factory, define_attributes): """ Test that isocline PSE gets launched. """ self.dt_group = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_isocline_exploration(self.dt_group.gid) assert isinstance(result['canvasName'], str) assert isinstance(result['xAxisName'], str) assert isinstance(result['url_base'], str) assert list(define_attributes['DATATYPE_MEASURE_METRIC'] ) == result['available_metrics']
def test_draw_isocline_exploration(self, datatype_group_factory): """ Test that isocline PSE gets launched. """ self.dt_group, _ = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_isocline_exploration(self.dt_group.gid) assert isinstance(result['canvasName'], str) assert isinstance(result['xAxisName'], str) assert isinstance(result['url_base'], str) assert result['available_metrics'] == ['v']
class ExplorationControllerTest(BaseTransactionalControllerTest): """ Unit tests ParameterExplorationController """ def setUp(self): """ Sets up the environment for testing; creates a datatype group and a Parameter Exploration Controller """ self.init() self.dt_group = DatatypesFactory().create_datatype_group() self.controller = ParameterExplorationController() def tearDown(self): """ Cleans the testing environment """ self.cleanup() def test_draw_discrete_exploration(self): """ Test that Discrete PSE is getting launched and correct fields are prepared. """ result = self.controller.draw_discrete_exploration( self.dt_group.gid, 'burst', None, None) self.assertTrue(result['available_metrics'] == DatatypesFactory.DATATYPE_MEASURE_METRIC.keys()) self.assertEqual(result['color_metric'], DatatypesFactory.DATATYPE_MEASURE_METRIC.keys()[0]) self.assertEqual(result['size_metric'], None) self.assertEqual(DatatypesFactory.RANGE_1[1], json.loads(result['labels_x'])) self.assertEqual(DatatypesFactory.RANGE_2[1], json.loads(result['labels_y'])) data = json.loads(result['d3_data']) self.assertEqual(len(data), len(DatatypesFactory.RANGE_1[1])) for row in data.values(): self.assertEqual(len(row), len(DatatypesFactory.RANGE_2[1])) for entry in row.values(): self.assertEqual(entry['dataType'], 'Datatype2') for key in ['Gid', 'color_weight', 'operationId', 'tooltip']: self.assertTrue(key in entry) def test_draw_isocline_exploration(self): """ Test that isocline PSE gets launched. """ result = self.controller.draw_isocline_exploration( self.dt_group.gid, 500, 600) self.assertTrue(DatatypesFactory.DATATYPE_MEASURE_METRIC.keys()[0] in result['figureNumbers']) self.assertTrue(result['isAdapter']) self.assertEqual(DatatypesFactory.DATATYPE_MEASURE_METRIC, result['metrics']) self.assertTrue(result['showFullToolbar'])
def test_draw_isocline_exploration(self, datatype_group_factory, define_attributes): """ Test that isocline PSE gets launched. """ self.dt_group = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_isocline_exploration(self.dt_group.gid) assert isinstance(result['canvasName'], str) assert isinstance(result['xAxisName'], str) assert isinstance(result['url_base'], str) assert list(define_attributes['DATATYPE_MEASURE_METRIC'] ) == result['available_metrics']
class ExplorationControllerTest(BaseTransactionalControllerTest): """ Unit tests ParameterExplorationController """ def setUp(self): """ Sets up the environment for testing; creates a datatype group and a Parameter Exploration Controller """ self.init() self.dt_group = DatatypesFactory().create_datatype_group() self.controller = ParameterExplorationController() def tearDown(self): """ Cleans the testing environment """ self.cleanup() def test_draw_discrete_exploration(self): """ Test that Discrete PSE is getting launched and correct fields are prepared. """ result = self.controller.draw_discrete_exploration(self.dt_group.gid, 'burst', None, None) self.assertTrue(result['available_metrics'] == DatatypesFactory.DATATYPE_MEASURE_METRIC.keys()) self.assertEqual(result['color_metric'], DatatypesFactory.DATATYPE_MEASURE_METRIC.keys()[0]) self.assertEqual(result['size_metric'], None) self.assertEqual(DatatypesFactory.RANGE_1[1], json.loads(result['labels_x'])) self.assertEqual(DatatypesFactory.RANGE_2[1], json.loads(result['labels_y'])) data = json.loads(result['d3_data']) self.assertEqual(len(data), len(DatatypesFactory.RANGE_1[1])) for row in data.values(): self.assertEqual(len(row), len(DatatypesFactory.RANGE_2[1])) for entry in row.values(): self.assertEqual(entry['dataType'], 'Datatype2') for key in ['Gid', 'color_weight', 'operationId', 'tooltip']: self.assertTrue(key in entry) def test_draw_isocline_exploration(self): """ Test that isocline PSE gets launched. """ result = self.controller.draw_isocline_exploration(self.dt_group.gid) self.assertTrue(isinstance(result['canvasName'], (str, unicode))) self.assertTrue(isinstance(result['xAxisName'], (str, unicode))) self.assertTrue(isinstance(result['url_base'], (str, unicode))) self.assertEqual(DatatypesFactory.DATATYPE_MEASURE_METRIC.keys(), result['available_metrics'])
class TestExplorationController(BaseTransactionalControllerTest): """ Unit tests ParameterExplorationController """ def transactional_setup_method(self): self.clean_database() self.init() def transactional_teardown_method(self): """ Cleans the testing environment """ self.cleanup() def test_draw_discrete_exploration(self, datatype_group_factory): """ Test that Discrete PSE is getting launched and correct fields are prepared. """ self.dt_group, _ = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_discrete_exploration( self.dt_group.gid, 'burst', 'v', 'v') assert result['available_metrics'] == ["v"] assert result['color_metric'] == "v" assert result['size_metric'] == "v" assert [1, 3, 5] == json.loads(result['labels_x']) assert [0.1, 0.4] == json.loads(result['labels_y']) data = json.loads(result['d3_data']) assert len(data) == 3 for row in data.values(): assert len(row) == 2 for entry in row.values(): assert entry['dataType'] == 'TimeSeriesIndex' for key in ['Gid', 'color_weight', 'operationId', 'tooltip']: assert key in entry def test_draw_isocline_exploration(self, datatype_group_factory): """ Test that isocline PSE gets launched. """ self.dt_group, _ = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_isocline_exploration(self.dt_group.gid) assert isinstance(result['canvasName'], str) assert isinstance(result['xAxisName'], str) assert isinstance(result['url_base'], str) assert result['available_metrics'] == ['v']
def test_draw_discrete_exploration(self, datatype_group_factory): """ Test that Discrete PSE is getting launched and correct fields are prepared. """ self.dt_group = datatype_group_factory() self.controller = ParameterExplorationController() result = self.controller.draw_discrete_exploration(self.dt_group.gid, 'burst', 'v', 'v') assert result['available_metrics'] == ["v"] assert result['color_metric'] == "v" assert result['size_metric'] == "v" assert [1, 3, 5] == json.loads(result['labels_x']) assert [0.1, 0.4] == json.loads(result['labels_y']) data = json.loads(result['d3_data']) assert len(data) == 3 for row in data.values(): assert len(row) == 2 for entry in row.values(): assert entry['dataType'] == 'TimeSeriesIndex' for key in ['Gid', 'color_weight', 'operationId', 'tooltip']: assert key in entry
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()