当前位置: 首页>>代码示例>>Python>>正文


Python TestFactory.create_operation方法代码示例

本文整理汇总了Python中tvb.tests.framework.core.test_factory.TestFactory.create_operation方法的典型用法代码示例。如果您正苦于以下问题:Python TestFactory.create_operation方法的具体用法?Python TestFactory.create_operation怎么用?Python TestFactory.create_operation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tvb.tests.framework.core.test_factory.TestFactory的用法示例。


在下文中一共展示了TestFactory.create_operation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bct_all

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
    def test_bct_all(self):
        """
        Iterate all BCT algorithms and execute them.
        """
        for adapter_instance in self.bct_adapters:
            algorithm = adapter_instance.stored_adapter
            operation = TestFactory.create_operation(algorithm=algorithm, test_user=self.test_user,
                                                     test_project=self.test_project,
                                                     operation_status=model.STATUS_STARTED)
            self.assertEqual(model.STATUS_STARTED, operation.status)
            ### Launch BCT algorithm
            submit_data = {algorithm.parameter_name: self.connectivity.gid}
            try:
                OperationService().initiate_prelaunch(operation, adapter_instance, {}, **submit_data)
                if algorithm.classname in BCTTest.EXPECTED_TO_FAIL_VALIDATION:
                    raise Exception("Algorithm %s was expected to throw input validation "
                                    "exception, but did not!" % (algorithm.classname,))

                operation = dao.get_operation_by_id(operation.id)
                ### Check that operation status after execution is success.
                self.assertEqual(STATUS_FINISHED, operation.status)
                ### Make sure at least one result exists for each BCT algorithm
                results = dao.get_generic_entity(model.DataType, operation.id, 'fk_from_operation')
                self.assertTrue(len(results) > 0)

            except InvalidParameterException, excep:
                ## Some algorithms are expected to throw validation exception.
                if algorithm.classname not in BCTTest.EXPECTED_TO_FAIL_VALIDATION:
                    raise excep
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:31,代码来源:bct_test.py

示例2: test_get_linkable_projects

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
    def test_get_linkable_projects(self):
        """
        Test for retrieving the projects for a given user.
        """
        initial_projects = self.project_service.retrieve_projects_for_user(self.test_user.id)[0]
        self.assertEqual(len(initial_projects), 0, "Database was not reset!")
        test_proj = []
        user1 = TestFactory.create_user("another_user")
        for i in range(4):
            test_proj.append(TestFactory.create_project(self.test_user if i < 3 else user1, 'test_proj' + str(i)))

        project_storage = self.structure_helper.get_project_folder(test_proj[0])

        operation = TestFactory.create_operation(test_user=self.test_user, test_project=test_proj[0])

        project_storage = os.path.join(project_storage, str(operation.id))
        os.makedirs(project_storage)
        datatype = dao.store_entity(model.DataType(module="test_data", subject="subj1", 
                                                   state="test_state", operation_id=operation.id))
        linkable = self.project_service.get_linkable_projects_for_user(self.test_user.id, str(datatype.id))[0]
        self.assertEqual(len(linkable), 2, "Wrong count of link-able projects!")
        proj_names = [project.name for project in linkable]
        self.assertTrue(test_proj[1].name in proj_names)
        self.assertTrue(test_proj[2].name in proj_names)
        self.assertFalse(test_proj[3].name in proj_names)    
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:27,代码来源:project_service_test.py

示例3: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def setUp(self):
     """
     Reset the database before each test.
     """
     self.clean_database()
     self.flow_service = FlowService()
     self.test_user = TestFactory.create_user()
     self.test_project = TestFactory.create_project(admin=self.test_user)
     self.operation = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:11,代码来源:mapping_test.py

示例4: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def setUp(self):
     """
     Sets up the environment for running the tests;
     creates a `FigureController` and an operation
     """
     self.init()
     self.figure_c = FigureController()
     self.operation = TestFactory.create_operation(test_user=self.test_user,
                                                   test_project=self.test_project)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:11,代码来源:figure_controller_test.py

示例5: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def setUp(self):
     """
     Set up any additionally needed parameters.
     """
     self.clean_database()
     super(GenshiTestNDimensionArray, self).setUp()
     self.test_user = TestFactory.create_user()
     self.test_project = TestFactory.create_project(self.test_user)
     self.operation = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:11,代码来源:genshi_test.py

示例6: test_store_image_from_operation

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
    def test_store_image_from_operation(self):
        # test that image can be retrieved from operation
        test_operation = TestFactory.create_operation(test_user=self.user, test_project=self.project)

        self.figure_service.store_result_figure(self.project, self.user, "png",
                                                IMG_DATA, operation_id=test_operation.id)
        figures = dao.get_figures_for_operation(test_operation.id)
        self.assertEqual(1, len(figures))
        image_path = self.files_helper.get_images_folder(self.project.name)
        image_path = os.path.join(image_path, figures[0].file_path)
        self.assertCanReadImage(image_path)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:13,代码来源:figure_service_test.py

示例7: test_viewoperations

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def test_viewoperations(self):
     """ 
     Test the viewoperations from projectcontroller.
     """
     operation = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
     result_dict = self.project_c.viewoperations(self.test_project.id)
     operation_list = result_dict["operationsList"]
     self.assertEqual(len(operation_list), 1)
     self.assertEqual(operation_list[0]["id"], str(operation.id))
     self.assertTrue("no_filter_selected" in result_dict)
     self.assertTrue("total_op_count" in result_dict)
开发者ID:lcosters,项目名称:tvb-framework,代码行数:13,代码来源:project_controller_test.py

示例8: test_get_filtered_by_column

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
    def test_get_filtered_by_column(self):
        """
        Test the filter function when retrieving dataTypes with a filter
        after a column from a class specific table (e.g. DATA_arraywrapper).
        """
        operation_1 = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
        operation_2 = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)

        one_dim_array = numpy.arange(5)
        two_dim_array = numpy.array([[1, 2], [2, 3], [1, 4]])
        self._store_float_array(one_dim_array, "John Doe 1", operation_1.id)
        self._store_float_array(one_dim_array, "John Doe 2", operation_1.id)
        self._store_float_array(two_dim_array, "John Doe 3", operation_2.id)

        count = self.flow_service.get_available_datatypes(self.test_project.id, "tvb.datatypes.arrays.MappedArray")[1]
        self.assertEqual(count, 3, "Problems with inserting data")
        first_filter = FilterChain(fields=[FilterChain.datatype + '._nr_dimensions'], operations=["=="], values=[1])
        count = self.flow_service.get_available_datatypes(self.test_project.id,
                                                          "tvb.datatypes.arrays.MappedArray", first_filter)[1]
        self.assertEqual(count, 2, "Data was not filtered")

        second_filter = FilterChain(fields=[FilterChain.datatype + '._nr_dimensions'], operations=["=="], values=[2])
        filtered_data = self.flow_service.get_available_datatypes(self.test_project.id,
                                                                  "tvb.datatypes.arrays.MappedArray", second_filter)[0]
        self.assertEqual(len(filtered_data), 1, "Data was not filtered")
        self.assertEqual(filtered_data[0][3], "John Doe 3")

        third_filter = FilterChain(fields=[FilterChain.datatype + '._length_1d'], operations=["=="], values=[3])
        filtered_data = self.flow_service.get_available_datatypes(self.test_project.id,
                                                                  "tvb.datatypes.arrays.MappedArray", third_filter)[0]
        self.assertEqual(len(filtered_data), 1, "Data was not filtered correct")
        self.assertEqual(filtered_data[0][3], "John Doe 3")
        try:
            if os.path.exists('One_dim.txt'):
                os.remove('One_dim.txt')
            if os.path.exists('Two_dim.txt'):
                os.remove('Two_dim.txt')
            if os.path.exists('One_dim-1.txt'):
                os.remove('One_dim-1.txt')
        except Exception:
            pass
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:43,代码来源:flow_service_test.py

示例9: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def setUp(self):
     """
     Reset the database before each test.
     """
     self.import_service = ImportService()
     self.flow_service = FlowService()
     self.project_service = ProjectService()
     
     self.test_user = TestFactory.create_user()
     self.test_project = TestFactory.create_project(self.test_user, name="GeneratedProject", description="test_desc")
     self.operation = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
     self.adapter_instance = TestFactory.create_adapter(test_project=self.test_project)
     TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project)
     self.zip_path = None 
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:16,代码来源:import_service_test.py

示例10: test_get_operation_details

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def test_get_operation_details(self):
     """
     Verifies result dictionary has the expected keys / values after call to
     `get_operation_details(...`
     """
     operation = TestFactory.create_operation(test_user=self.test_user,
                                              test_project=self.test_project,
                                              parameters='{"test" : "test"}')
     result_dict = self.project_c.get_operation_details(operation.gid)
     self.assertEqual(result_dict['entity_gid'], operation.gid)
     self.assertEqual(result_dict['nodeType'], 'operation')
     operation_dict = result_dict['nodeFields'][0]
     self.assertEqual(operation_dict['burst_name']['value'], '')
     self.assertEqual(operation_dict['count']['value'], 1)
     self.assertEqual(operation_dict['gid']['value'], operation.gid)
     self.assertEqual(operation_dict['operation_id']['value'], operation.id)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:18,代码来源:project_controller_test.py

示例11: test_get_operation_details

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def test_get_operation_details(self):
     """
     Verifies result dictionary has the expected keys / values after call to
     `get_operation_details(...`
     """
     operation = TestFactory.create_operation(
         test_user=self.test_user, test_project=self.test_project, parameters='{"test" : "test"}'
     )
     result_dict = self.project_c.get_operation_details(operation.gid)
     self.assertEqual(result_dict["entity_gid"], operation.gid)
     self.assertEqual(result_dict["nodeType"], "operation")
     operation_dict = result_dict["nodeFields"][0]
     self.assertEqual(operation_dict["burst_name"]["value"], "")
     self.assertEqual(operation_dict["count"]["value"], 1)
     self.assertEqual(operation_dict["gid"]["value"], operation.gid)
     self.assertEqual(operation_dict["operation_id"]["value"], operation.id)
开发者ID:lcosters,项目名称:tvb-framework,代码行数:18,代码来源:project_controller_test.py

示例12: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
    def setUp(self):
        """
        Reset the database before each test.
        """
        initialize_storage()
        self.datatypes_factory = DatatypesFactory()
        self.test_user = self.datatypes_factory.get_user()
        self.test_project = self.datatypes_factory.get_project()
        self.connectivity = self.datatypes_factory.create_connectivity(self.CONNECTIVITY_NODES)[1]

        algorithm = dao.get_algorithm_by_module(SIMULATOR_MODULE, SIMULATOR_CLASS)
        self.simulator_adapter = ABCAdapter.build_adapter(algorithm)
        self.operation = TestFactory.create_operation(algorithm, self.test_user, self.test_project,
                                                      model.STATUS_STARTED, json.dumps(SIMULATOR_PARAMETERS))

        SIMULATOR_PARAMETERS['connectivity'] = self.connectivity.gid
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:18,代码来源:simulator_adapter_test.py

示例13: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
    def setUp(self):
        """
        Prepare the database before each test.
        """
        self.import_service = ImportService()
        self.flow_service = FlowService()
        self.project_service = ProjectService()
        self.test_user = TestFactory.create_user()

        self.delete_project_folders()
        result = self.count_all_entities(DataType)
        self.assertEqual(0, result, "There should be no data type in DB")
        result = self.count_all_entities(Project)
        self.assertEqual(0, result)

        self.test_project = TestFactory.import_default_project(self.test_user)
        self.operation = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
        self.adapter_instance = TestFactory.create_adapter(test_project=self.test_project)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:20,代码来源:remove_test.py

示例14: test_prepare_inputs_datatype

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def test_prepare_inputs_datatype(self):
     """
     Test for ABCAdapter.prepare_ui_inputs method when submitting DataType with sub-attributes.
     """
     parent_op = TestFactory.create_operation()
     test_entity = dao.store_entity(model.DataType(operation_id=parent_op.id))
     dataset_3 = {}
     for key, value in self.SUBMIT_DATASET_3.iteritems():
         dataset_3[key.replace("$GID$", test_entity.gid)] = value.replace("$GID$", test_entity.gid)
         
     kwargs = self.test_adapter.prepare_ui_inputs(dataset_3)
     
     for expected_name, expected_type in self.EXPECTED_FILTERED_SET3.iteritems():
         self.assertTrue(expected_name in kwargs)
         self.assertTrue(isinstance(kwargs[expected_name], expected_type))
     self.assertEqual(len(self.EXPECTED_FILTERED_SET3), len(kwargs))
     
     self.assertEqual(2, len(kwargs["surface_parameters"]))
     self.assertTrue(isinstance(kwargs["surface_parameters"]["att1"], int))
     self.assertTrue(isinstance(kwargs["surface_parameters"]["att2"], float))
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:22,代码来源:abcadapter_test.py

示例15: test_write_operation_metadata

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_operation [as 别名]
 def test_write_operation_metadata(self):
     """
     Test that a correct XML is created for an operation.
     """
     operation = TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project)
     expected_file = self.files_helper.get_operation_meta_file_path(self.PROJECT_NAME, operation.id)
     self.assertFalse(os.path.exists(expected_file))
     self.files_helper.write_operation_metadata(operation)
     self.assertTrue(os.path.exists(expected_file))
     operation_meta = XMLReader(expected_file).read_metadata()
     loaded_operation = model.Operation(None, None, None, None)
     loaded_operation.from_dict(operation_meta, dao)
     expected_dict = operation.to_dict()[1]
     found_dict = loaded_operation.to_dict()[1]
     for key, value in expected_dict.iteritems():
         self.assertEqual(str(value), str(found_dict[key]))
     # Now validate that operation metaData can be also updated
     self.assertNotEqual("new_group_name", found_dict['user_group'])
     self.files_helper.update_operation_metadata(self.PROJECT_NAME, "new_group_name", operation.id) 
     found_dict = XMLReader(expected_file).read_metadata()  
     self.assertEqual("new_group_name", found_dict['user_group'])
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:23,代码来源:files_helper_test.py


注:本文中的tvb.tests.framework.core.test_factory.TestFactory.create_operation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。