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


Python TestFactory.create_user方法代码示例

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


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

示例1: _store_users_happy_flow

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

示例2: _store_users_raises_exception

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

示例3: _store_users_nested

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

示例4: test_retrieve_1project_3usr

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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]
     assert len(projects) == 1, "Projects not retrieved properly!"
     projects = self.project_service.retrieve_projects_for_user(member1.id, 1)[0]
     assert len(projects) == 1, "Projects not retrieved properly!"
     projects = self.project_service.retrieve_projects_for_user(member2.id, 1)[0]
     assert len(projects) == 1, "Projects not retrieved properly!"
开发者ID:maedoc,项目名称:tvb-framework,代码行数:16,代码来源:project_service_test.py

示例5: test_validate_valid

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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")
     assert not 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)
     assert user_after_validation.validated, "User should be validated."
     assert cherrypy.session[common.KEY_MESSAGE_TYPE] == common.TYPE_INFO
开发者ID:maedoc,项目名称:tvb-framework,代码行数:16,代码来源:users_controller_test.py

示例6: transactional_setup_method

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

示例7: test_get_linkable_projects

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

示例8: transactional_setup_method

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

示例9: setup_method

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

示例10: setup_method

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

示例11: transactional_setup_method

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

示例12: test_create_project_happy_flow

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_user [as 别名]
 def test_create_project_happy_flow(self):
     """
     Standard flow for creating a new project.
     """
     user1 = TestFactory.create_user('test_user1')
     user2 = TestFactory.create_user('test_user2')
     initial_projects = dao.get_projects_for_user(self.test_user.id)
     assert len(initial_projects) == 0, "Database reset probably failed!"
     TestFactory.create_project(self.test_user, 'test_project', users=[user1.id, user2.id])
     resulting_projects = dao.get_projects_for_user(self.test_user.id)
     assert len(resulting_projects) == 1, "Project with valid data not inserted!"
     project = resulting_projects[0]
     if project.name == "test_project":
         assert project.description == "description", "Description do no match"
         users_for_project = dao.get_members_of_project(project.id)
         for user in users_for_project:
             assert user.id in [user1.id, user2.id], "Users not stored properly."
     assert os.path.exists(os.path.join(TvbProfile.current.TVB_STORAGE, FilesHelper.PROJECTS_FOLDER,
                                                 "test_project")), "Folder for project was not created"
开发者ID:maedoc,项目名称:tvb-framework,代码行数:21,代码来源:project_service_test.py

示例13: test_edit_entity_forget_commit

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.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)
     assert edited_user.username == 'new_name',\
                      "User should be edited but it is not. Expected 'new_name' got %s" % edited_user.username
开发者ID:maedoc,项目名称:tvb-framework,代码行数:12,代码来源:transactional_test.py

示例14: setup_method

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

示例15: test_retrieve_3projects_3usr

# 需要导入模块: from tvb.tests.framework.core.factory import TestFactory [as 别名]
# 或者: from tvb.tests.framework.core.factory.TestFactory import create_user [as 别名]
 def test_retrieve_3projects_3usr(self):
     """
     Three users, 3 projects. Structure of db:
     proj1: {admin: user1, members: [user2, user3]}
     proj2: {admin: user2, members: [user1]}
     proj3: {admin: user3, members: [user1, user2]}
     Check valid project returns for all the users.
     """
     member1 = TestFactory.create_user("member1")
     member2 = TestFactory.create_user("member2")
     member3 = TestFactory.create_user("member3")
     TestFactory.create_project(member1, 'TestProject1', users=[member2.id, member3.id])
     TestFactory.create_project(member2, 'TestProject2', users=[member1.id])
     TestFactory.create_project(member3, 'TestProject3', users=[member1.id, member2.id])
     projects = self.project_service.retrieve_projects_for_user(member1.id, 1)[0]
     assert len(projects) == 3, "Projects not retrieved properly!"
     projects = self.project_service.retrieve_projects_for_user(member2.id, 1)[0]
     assert len(projects) == 3, "Projects not retrieved properly!"
     projects = self.project_service.retrieve_projects_for_user(member3.id, 1)[0]
     assert len(projects) == 2, "Projects not retrieved properly!"
开发者ID:maedoc,项目名称:tvb-framework,代码行数:22,代码来源:project_service_test.py


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