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


Python TestFactory.create_operation方法代码示例

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


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

示例1: test_bct_all

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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)
            assert 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 TestBCT.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.
                assert 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')
                assert len(results) > 0

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

示例2: test_get_linkable_projects

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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]
        assert 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]
        assert len(linkable) == 2, "Wrong count of link-able projects!"
        proj_names = [project.name for project in linkable]
        assert test_proj[1].name in proj_names
        assert test_proj[2].name in proj_names
        assert not test_proj[3].name in proj_names
开发者ID:maedoc,项目名称:tvb-framework,代码行数:27,代码来源:project_service_test.py

示例3: setup_method

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
 def setup_method(self):
     """
     Set up any additionally needed parameters.
     """
     self.clean_database()
     super(TestGenshiNDimensionArray, self).setup_method()
     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:the-virtual-brain,项目名称:tvb-framework,代码行数:11,代码来源:genshi_test.py

示例4: transactional_setup_method

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
 def transactional_setup_method(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:maedoc,项目名称:tvb-framework,代码行数:11,代码来源:figure_controller_test.py

示例5: setup_method

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
 def setup_method(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:maedoc,项目名称:tvb-framework,代码行数:11,代码来源:mapping_test.py

示例6: test_store_image_from_operation

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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)
        assert 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:maedoc,项目名称:tvb-framework,代码行数:13,代码来源:figure_service_test.py

示例7: test_viewoperations

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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']
     assert len(operation_list) == 1
     assert operation_list[0]['id'] == str(operation.id)
     assert 'no_filter_selected' in result_dict
     assert 'total_op_count' in result_dict
开发者ID:maedoc,项目名称:tvb-framework,代码行数:14,代码来源:project_controller_test.py

示例8: transactional_setup_method

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
 def transactional_setup_method(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()
     TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project)
     self.zip_path = None 
开发者ID:maedoc,项目名称:tvb-framework,代码行数:16,代码来源:import_service_test.py

示例9: test_get_operation_details

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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)
     assert result_dict['entity_gid'] == operation.gid
     assert result_dict['nodeType'] == 'operation'
     operation_dict = result_dict['nodeFields'][0]
     assert operation_dict['burst_name']['value'] == ''
     assert operation_dict['count']['value'] == 1
     assert operation_dict['gid']['value'] == operation.gid
     assert operation_dict['operation_id']['value'] == operation.id
开发者ID:maedoc,项目名称:tvb-framework,代码行数:18,代码来源:project_controller_test.py

示例10: transactional_setup_method

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
    def transactional_setup_method(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:maedoc,项目名称:tvb-framework,代码行数:18,代码来源:simulator_adapter_test.py

示例11: transactional_setup_method

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
    def transactional_setup_method(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)
        assert 0 == result, "There should be no data type in DB"
        result = self.count_all_entities(Project)
        assert 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()
开发者ID:maedoc,项目名称:tvb-framework,代码行数:20,代码来源:remove_test.py

示例12: test_prepare_inputs_datatype

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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():
            assert expected_name in kwargs
            assert isinstance(kwargs[expected_name], expected_type)
        assert len(self.EXPECTED_FILTERED_SET3) == len(kwargs)

        assert 2 == len(kwargs["surface_parameters"])
        assert isinstance(kwargs["surface_parameters"]["att1"], int)
        assert isinstance(kwargs["surface_parameters"]["att2"], float)
开发者ID:maedoc,项目名称:tvb-framework,代码行数:22,代码来源:abcadapter_test.py

示例13: _create_value_wrapper

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
 def _create_value_wrapper(test_user, test_project=None):
     """
     Creates a ValueWrapper dataType, and the associated parent Operation.
     This is also used in ProjectStructureTest.
     """
     if test_project is None:
         test_project = TestFactory.create_project(test_user, 'test_proj')
     operation = TestFactory.create_operation(test_user=test_user, test_project=test_project)
     value_wrapper = ValueWrapper(data_value=5.0, data_name="my_value")
     value_wrapper.type = "ValueWrapper"
     value_wrapper.module = "tvb.datatypes.mapped_values"
     value_wrapper.subject = "John Doe"
     value_wrapper.state = "RAW_STATE"
     value_wrapper.set_operation_id(operation.id)
     adapter_instance = StoreAdapter([value_wrapper])
     OperationService().initiate_prelaunch(operation, adapter_instance, {})
     all_value_wrappers = FlowService().get_available_datatypes(test_project.id,
                                                                "tvb.datatypes.mapped_values.ValueWrapper")[0]
     if len(all_value_wrappers) != 1:
         raise Exception("Should be only one value wrapper.")
     result_vw = ABCAdapter.load_entity_by_gid(all_value_wrappers[0][2])
     return test_project, result_vw.gid, operation.gid
开发者ID:maedoc,项目名称:tvb-framework,代码行数:24,代码来源:project_service_test.py

示例14: _create_operations_with_inputs

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_operation [as 别名]
    def _create_operations_with_inputs(self, is_group_parent=False):
        """
        Method used for creating a complex tree of operations.

        If 'if_group_parent' is True then a new group will be created and one of its entries it will be used as
        input for the returned operations.
        """
        group_dts, root_op_group_id = TestFactory.create_group(self.test_user, self.test_project)
        if is_group_parent:
            datatype_gid = group_dts[0].gid
        else:
            datatype_gid = TestProjectService._create_value_wrapper(self.test_user, self.test_project)[1]

        parameters = json.dumps({"param_name": datatype_gid})

        ops = []
        for i in range(4):
            ops.append(TestFactory.create_operation(test_user=self.test_user, test_project=self.test_project))
            if i in [1, 3]:
                ops[i].visible = False
            ops[i].parameters = parameters
            ops[i] = dao.store_entity(ops[i])
            
        #groups
        _, ops_group = TestFactory.create_group(self.test_user, self.test_project)
        ops_group = dao.get_operations_in_group(ops_group)
        assert 2 == len(ops_group)
        ops_group[0].parameters = parameters
        ops_group[0] = dao.store_entity(ops_group[0])
        ops_group[1].visible = False
        ops_group[1].parameters = parameters
        ops_group[1] = dao.store_entity(ops_group[1])

        ops.extend(ops_group)
        if is_group_parent:
            dt_group = dao.get_datatypegroup_by_op_group_id(root_op_group_id)
            return ops, dt_group.id
        return ops, datatype_gid
开发者ID:maedoc,项目名称:tvb-framework,代码行数:40,代码来源:project_structure_test.py


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