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


Python TestFactory.create_user方法代码示例

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


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

示例1: _store_users_happy_flow

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def _store_users_happy_flow(self, n_users, prefix=""):
     """
     Store users in happy flow. In this case the transaction should just be commited properly and changes
     should be visible in database.
     
     :param n_users: number of users to be stored by this method
     """
     for idx in range(n_users):
         TestFactory.create_user(prefix + 'test_user' + str(idx), 'pass', '[email protected]', True, 'test')
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:11,代码来源:transactional_test.py

示例2: _store_users_raises_exception

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def _store_users_raises_exception(self, n_users):
     """
     Store users but at the end raise an exception. In case the exception is not handled up until the
     transactional decorator, all changes should be rolled back.
     
     :param n_users: number of users to be stored by this method
     """
     for idx in range(n_users):
         TestFactory.create_user('test_user' + str(idx), 'pass', '[email protected]', True, 'test')
     raise Exception("This is just so transactional kicks in and a rollback should be done.")
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:12,代码来源:transactional_test.py

示例3: _store_users_nested

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def _store_users_nested(self, n_users, inner_trans_func):
     """
     This method stores n_users, after which it calls inner_trans_func with n_users as parameter.
     At the end it raises an exception so transaction will fail.
     All changes should be reverted regardless if inner_trans_func succeeds or fails.
     
     :param n_users: number of users to be stored both by this method and by the passed inner_trans_func
     :param inner_trans_func: either _store_users_happy_flow or _store_users_raises_exception
     """
     for idx in range(n_users):
         TestFactory.create_user('test_user_nested' + str(idx), 'pass', '[email protected]', True, 'test')
     inner_trans_func(n_users)
     raise Exception("This is just so transactional kicks in and a rollback should be done.")
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:15,代码来源:transactional_test.py

示例4: test_retrieve_1project_3usr

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def test_retrieve_1project_3usr(self):
     """
     One user as admin, two users as members, getting projects for admin and for any of
     the members should return one.
     """
     member1 = TestFactory.create_user("member1")
     member2 = TestFactory.create_user("member2")
     TestFactory.create_project(self.test_user, 'Testproject', users=[member1.id, member2.id])
     projects = self.project_service.retrieve_projects_for_user(self.test_user.id, 1)[0]
     self.assertEqual(len(projects), 1, "Projects not retrieved properly!")
     projects = self.project_service.retrieve_projects_for_user(member1.id, 1)[0]
     self.assertEqual(len(projects), 1, "Projects not retrieved properly!")
     projects = self.project_service.retrieve_projects_for_user(member2.id, 1)[0]
     self.assertEqual(len(projects), 1, "Projects not retrieved properly!")
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:16,代码来源:project_service_test.py

示例5: test_validate_valid

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def test_validate_valid(self):
     """
     Pass a valid user and test that it is actually validate.
     """
     self.test_user.role = "ADMINISTRATOR"
     self.test_user = dao.store_entity(self.test_user)
     cherrypy.session[common.KEY_USER] = self.test_user
     TestFactory.create_user(username="to_validate", validated=False)
     user_before_validation = dao.get_user_by_name("to_validate")
     self.assertFalse(user_before_validation.validated)
     self._expect_redirect('/tvb', self.user_c.validate, user_before_validation.username)
     user_after_validation = dao.get_user_by_id(user_before_validation.id)
     self.assertTrue(user_after_validation.validated, "User should be validated.")
     self.assertTrue(cherrypy.session[common.KEY_MESSAGE_TYPE] == common.TYPE_INFO)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:16,代码来源:users_controller_test.py

示例6: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def setUp(self):
     """
     Set up the context needed by the tests.
     """
     self.files_helper = FilesHelper()
     self.test_user = TestFactory.create_user()
     self.test_project = TestFactory.create_project(self.test_user, self.PROJECT_NAME)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:9,代码来源:files_helper_test.py

示例7: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
    def setUp(self):
        """ Prepare some entities to work with during tests:"""

        self.flow_service = FlowService()
        self.test_user = TestFactory.create_user()
        self.test_project = TestFactory.create_project(admin=self.test_user)
        ### Insert some starting data in the database.
        categ1 = model.AlgorithmCategory('one', True)
        self.categ1 = dao.store_entity(categ1)
        categ2 = model.AlgorithmCategory('two', rawinput=True)
        self.categ2 = dao.store_entity(categ2)

        group1 = model.AlgorithmGroup("test_module1", "classname1", categ1.id)
        self.algo_group1 = dao.store_entity(group1)
        group2 = model.AlgorithmGroup("test_module2", "classname2", categ2.id)
        self.algo_group2 = dao.store_entity(group2)
        group3 = model.AlgorithmGroup("test_module3", "classname3", categ1.id)
        self.algo_group3 = dao.store_entity(group3)

        group_v = model.AlgorithmGroup(TEST_ADAPTER_VALID_MODULE, TEST_ADAPTER_VALID_CLASS, categ2.id)
        self.algo_group_v = dao.store_entity(group_v)

        algo_v = model.Algorithm(self.algo_group_v.id, 'ident', name='', req_data='', param_name='', output='')
        self.algorithm_v = dao.store_entity(algo_v)

        algo1 = model.Algorithm(self.algo_group1.id, 'id', name='', req_data='', param_name='', output='')
        self.algorithm1 = dao.store_entity(algo1)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:29,代码来源:flow_service_test.py

示例8: test_get_linkable_projects

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [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

示例9: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def setUp(self):
     """
     Sets up the environment for running the tests;
     creates a test user and a test project, saves old configuration and imports a CFF data-set
     """
     self.test_user = TestFactory.create_user()
     self.test_project = TestFactory.create_project(self.test_user)
     TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project)
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:10,代码来源:timeseries_metrics_adapter_test.py

示例10: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def setUp(self):
     """
     Reset the database before each test.
     """
     config.EVENTS_FOLDER = ''
     self.project_service = ProjectService()
     self.structure_helper = FilesHelper()
     self.test_user = TestFactory.create_user()
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:10,代码来源:project_service_test.py

示例11: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [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

示例12: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [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

示例13: test_edit_entity_forget_commit

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def test_edit_entity_forget_commit(self):
     """
     Commit should be done automatically if you forget for some reason to do so in case of new/update/deletes.
     """
     stored_user = TestFactory.create_user('username', 'password', 'mail', True, 'role')
     user_id = stored_user.id
     self._dao_change_user_forget_commit(user_id, 'new_name')
     edited_user = dao.get_user_by_id(user_id)
     self.assertEqual(edited_user.username, 'new_name',
                      "User should be edited but it is not. Expected 'new_name' got %s" % edited_user.username)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:12,代码来源:transactional_test.py

示例14: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def setUp(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("UserRM")
     self.test_project = TestFactory.import_default_project(self.test_user)
     self.connectivity = self._get_entity(Connectivity())
     self.surface = self._get_entity(CorticalSurface())
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:12,代码来源:region_mapping_importer_test.py

示例15: setUp

# 需要导入模块: from tvb.tests.framework.core.test_factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.test_factory.TestFactory import create_user [as 别名]
 def setUp(self):
     """
     Reset the database before each test.
     """
     self.clean_database()
     initialize_storage()
     self.test_user = TestFactory.create_user()
     self.test_project = TestFactory.create_project(self.test_user)
     self.operation_service = OperationService()
     self.backup_hdd_size = TvbProfile.current.MAX_DISK_SPACE
开发者ID:lcosters,项目名称:tvb-framework,代码行数:12,代码来源:operation_service_test.py


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