예제 #1
0
class TestSurfaceStimulusController(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceStimulusController """
    def transactional_setup_method(self):
        self.clean_database()
        self.init()
        self.surface_s_c = SurfaceStimulusController()

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

    def test_step_1(self):
        self.surface_s_c.step_1_submit(1, 1)
        result_dict = self.surface_s_c.step_1()
        expected_keys = [
            'temporalPlotInputList', 'spatialPlotInputList', 'baseUrl',
            'definedFocalPoints', 'mainContent', 'surfaceStimulusSelectForm',
            'surfaceStimulusCreateForm'
        ]
        assert all(x in result_dict for x in expected_keys)
        assert result_dict[
            'mainContent'] == 'spatial/stimulus_surface_step1_main'
        assert result_dict[
            'next_step_url'] == '/spatial/stimulus/surface/step_1_submit'

    def test_step_2(self, surface_index_factory):
        surface_index = surface_index_factory()
        self.surface_s_c.step_1_submit(1, 1)
        context = get_from_session(KEY_SURFACE_STIMULI)
        context.surface = surface_index.gid
        result_dict = self.surface_s_c.step_2()
        expected_keys = [
            'urlVerticesPick', 'urlVertices', 'urlTrianglesPick',
            'urlTriangles', 'urlNormalsPick', 'urlNormals', 'baseUrl',
            'surfaceGID', 'mainContent', 'loadExistentEntityUrl',
            'surfaceStimulusSelectForm', 'definedFocalPoints'
        ]
        assert all(x in result_dict for x in expected_keys)
        assert result_dict[
            'next_step_url'] == '/spatial/stimulus/surface/step_2_submit'
        assert result_dict[
            'mainContent'] == 'spatial/stimulus_surface_step2_main'
        assert result_dict[
            'loadExistentEntityUrl'] == '/spatial/stimulus/surface/load_surface_stimulus'
예제 #2
0
class SurfaceStimulusControllerTest(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceStimulusController """
    def setUp(self):
        self.init()
        self.surface_s_c = SurfaceStimulusController()

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

    def test_step_1(self):
        self.surface_s_c.step_1_submit(1, 1)
        result_dict = self.surface_s_c.step_1()
        expected_keys = [
            'temporalPlotInputList', 'temporalFieldsPrefixes',
            'temporalEquationViewerUrl', 'spatialPlotInputList',
            'spatialFieldsPrefixes', 'spatialEquationViewerUrl',
            'selectedFocalPoints', 'mainContent', 'existentEntitiesInputList'
        ]
        map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        self.assertEqual(result_dict['mainContent'],
                         'spatial/stimulus_surface_step1_main')
        self.assertEqual(result_dict['next_step_url'],
                         '/spatial/stimulus/surface/step_1_submit')

    def test_step_2(self):
        _, surface = DatatypesFactory().create_surface()
        self.surface_s_c.step_1_submit(1, 1)
        context = get_from_session(KEY_SURFACE_CONTEXT)
        context.equation_kwargs[SURFACE_PARAMETER] = surface.gid
        result_dict = self.surface_s_c.step_2()
        expected_keys = [
            'urlVerticesPick', 'urlVertices', 'urlTrianglesPick',
            'urlTriangles', 'urlNormalsPick', 'urlNormals', 'surfaceGID',
            'mainContent', 'loadExistentEntityUrl',
            'existentEntitiesInputList', 'definedFocalPoints'
        ]
        map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        self.assertEqual(result_dict['next_step_url'],
                         '/spatial/stimulus/surface/step_2_submit')
        self.assertEqual(result_dict['mainContent'],
                         'spatial/stimulus_surface_step2_main')
        self.assertEqual(result_dict['loadExistentEntityUrl'],
                         '/spatial/stimulus/surface/load_surface_stimulus')
class TestSurfaceStimulusController(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceStimulusController """
    def transactional_setup_method(self):
        self.init()
        self.surface_s_c = SurfaceStimulusController()

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

    def test_step_1(self):
        self.surface_s_c.step_1_submit(1, 1)
        result_dict = self.surface_s_c.step_1()
        expected_keys = [
            'temporalPlotInputList', 'temporalFieldsPrefixes',
            'temporalEquationViewerUrl', 'spatialPlotInputList',
            'spatialFieldsPrefixes', 'spatialEquationViewerUrl',
            'selectedFocalPoints', 'mainContent', 'existentEntitiesInputList'
        ]
        assert all(x in result_dict for x in expected_keys)
        assert result_dict[
            'mainContent'] == 'spatial/stimulus_surface_step1_main'
        assert result_dict[
            'next_step_url'] == '/spatial/stimulus/surface/step_1_submit'

    def test_step_2(self, surface_factory):
        _, surface = surface_factory
        self.surface_s_c.step_1_submit(1, 1)
        context = get_from_session(KEY_SURFACE_CONTEXT)
        context.equation_kwargs[SURFACE_PARAMETER] = surface.gid
        result_dict = self.surface_s_c.step_2()
        expected_keys = [
            'urlVerticesPick', 'urlVertices', 'urlTrianglesPick',
            'urlTriangles', 'urlNormalsPick', 'urlNormals', 'surfaceGID',
            'mainContent', 'loadExistentEntityUrl',
            'existentEntitiesInputList', 'definedFocalPoints'
        ]
        assert all(x in result_dict for x in expected_keys)
        assert result_dict[
            'next_step_url'] == '/spatial/stimulus/surface/step_2_submit'
        assert result_dict[
            'mainContent'] == 'spatial/stimulus_surface_step2_main'
        assert result_dict[
            'loadExistentEntityUrl'] == '/spatial/stimulus/surface/load_surface_stimulus'
class SurfaceStimulusControllerTest(BaseTransactionalControllerTest):
    """ Unit tests for SurfaceStimulusController """
    
    def setUp(self):
        self.init()
        self.surface_s_c = SurfaceStimulusController()


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


    def test_step_1(self):
        self.surface_s_c.step_1_submit(1, 1)
        result_dict = self.surface_s_c.step_1()
        expected_keys = ['temporalPlotInputList', 'temporalFieldsPrefixes', 'temporalEquationViewerUrl',
                         'spatialPlotInputList', 'spatialFieldsPrefixes', 'spatialEquationViewerUrl',
                         'selectedFocalPoints', 'mainContent', 'existentEntitiesInputList']
        map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        self.assertEqual(result_dict['mainContent'], 'spatial/stimulus_surface_step1_main')
        self.assertEqual(result_dict['next_step_url'], '/spatial/stimulus/surface/step_1_submit')
        
     
    def test_step_2(self):
        _, surface = DatatypesFactory().create_surface()
        self.surface_s_c.step_1_submit(1, 1)
        context = get_from_session(KEY_SURFACE_CONTEXT)
        context.equation_kwargs[SURFACE_PARAMETER] = surface.gid
        result_dict = self.surface_s_c.step_2()
        expected_keys = ['urlVerticesPick', 'urlVertices', 'urlTrianglesPick', 'urlTriangles',
                         'urlNormalsPick', 'urlNormals', 'surfaceGID', 'mainContent', 
                         'loadExistentEntityUrl', 'existentEntitiesInputList', 'definedFocalPoints']
        map(lambda x: self.assertTrue(x in result_dict), expected_keys)
        self.assertEqual(result_dict['next_step_url'], '/spatial/stimulus/surface/step_2_submit')
        self.assertEqual(result_dict['mainContent'], 'spatial/stimulus_surface_step2_main')
        self.assertEqual(result_dict['loadExistentEntityUrl'], '/spatial/stimulus/surface/load_surface_stimulus')