Commit 7652a119 authored by liadomide's avatar liadomide

TVB-2598 Cleanup

parent a16b39e0
......@@ -32,11 +32,9 @@
.. moduleauthor:: Bogdan Neacsa <bogdan.neacsa@codemart.ro>
"""
from tvb.core.neocom import h5
from uuid import UUID
from tvb.tests.framework.core.base_testcase import TransactionalTestCase
from tvb.core.entities.file.files_helper import FilesHelper
from tvb.adapters.visualizers.time_series import TimeSeriesDisplay
from tvb.tests.framework.core.factory import TestFactory
class TestTimeSeries(TransactionalTestCase):
......@@ -44,30 +42,14 @@ class TestTimeSeries(TransactionalTestCase):
Unit-tests for Time Series Viewer.
"""
def transactional_setup_method(self):
"""
Sets up the environment for running the tests;
creates a test user, a test project, a connectivity and a surface;
imports a CFF data-set
"""
self.test_user = TestFactory.create_user('Time_Series_User')
self.test_project = TestFactory.create_project(self.test_user, 'Time_Series_Project')
def transactional_teardown_method(self):
"""
Clean-up tests data
"""
FilesHelper().remove_project_structure(self.test_project.name)
def test_launch(self, time_series_index_factory):
"""
Check that all required keys are present in output from BrainViewer launch.
"""
time_series_index = time_series_index_factory()
time_series = h5.load_from_index(time_series_index)
viewer = TimeSeriesDisplay()
view_model = viewer.get_view_model_class()()
view_model.time_series = time_series.gid
view_model.time_series = UUID(time_series_index.gid)
result = viewer.launch(view_model)
expected_keys = ['t0', 'shape', 'preview', 'labelsStateVar', 'labelsModes',
'mainContent', 'labels', 'labels_json', 'figsize', 'dt']
......
......@@ -29,12 +29,13 @@
#
from os import path
from uuid import UUID
from mock import patch
from tvb.adapters.creators.stimulus_creator import RegionStimulusCreator
from tvb.adapters.datatypes.db.patterns import StimuliRegionIndex
from tvb.adapters.datatypes.db.surface import SurfaceIndex
from tvb.adapters.simulator.simulator_adapter import SimulatorAdapterModel, CortexViewModel
from tvb.adapters.uploaders.sensors_importer import SensorsImporterForm, SensorsImporterModel
from tvb.adapters.uploaders.sensors_importer import SensorsImporterModel
from tvb.basic.profile import TvbProfile
import numpy
import tvb_data
......@@ -171,22 +172,21 @@ class TestSimulationController(BaseTransactionalControllerTest, helper.CPWebCase
zip_path = path.join(path.dirname(tvb_data.__file__), 'connectivity', 'connectivity_66.zip')
TestFactory.import_zip_connectivity(self.test_user, self.test_project, zip_path)
connectivity_index = TestFactory.get_entity(self.test_project, ConnectivityIndex)
connectivity = h5.load_from_index(connectivity_index)
weight_array = numpy.zeros(connectivity.number_of_regions)
weight_array = numpy.zeros(connectivity_index.number_of_regions)
region_stimulus_creator = RegionStimulusCreator()
view_model = region_stimulus_creator.get_view_model_class()()
view_model.connectivity = connectivity.gid
view_model.connectivity = UUID(connectivity_index.gid)
view_model.weight = weight_array
view_model.temporal = TemporalApplicableEquation()
view_model.temporal.parameters['a'] = 1.0
view_model.temporal.parameters['b'] = 2.0
FlowService().fire_operation(region_stimulus_creator, self.test_user, self.test_project.id, view_model=view_model)
FlowService().fire_operation(region_stimulus_creator, self.test_user, self.test_project.id,
view_model=view_model)
region_stimulus_index = TestFactory.get_entity(self.test_project, StimuliRegionIndex)
region_stimulus = h5.load_from_index(region_stimulus_index)
self.sess_mock['_region_stimuli'] = region_stimulus.gid
self.sess_mock['_region_stimuli'] = UUID(region_stimulus_index.gid)
with patch('cherrypy.session', self.sess_mock, create=True):
common.add2session(common.KEY_SIMULATOR_CONFIG, self.session_stored_simulator)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment