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


Python RandomUserPartitionScheme.get_group_for_user方法代码示例

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


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

示例1: test_get_group_for_user

# 需要导入模块: from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme [as 别名]
# 或者: from openedx.core.djangoapps.user_api.partition_schemes.RandomUserPartitionScheme import get_group_for_user [as 别名]
    def test_get_group_for_user(self):
        # get a group assigned to the user
        group1_id = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition)

        # make sure we get the same group back out every time
        for __ in range(10):
            group2_id = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition)
            self.assertEqual(group1_id, group2_id)
开发者ID:189140879,项目名称:edx-platform,代码行数:10,代码来源:test_partition_schemes.py

示例2: test_empty_partition

# 需要导入模块: from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme [as 别名]
# 或者: from openedx.core.djangoapps.user_api.partition_schemes.RandomUserPartitionScheme import get_group_for_user [as 别名]
 def test_empty_partition(self):
     empty_partition = UserPartition(
         self.TEST_ID,
         'Test Partition',
         'for testing purposes',
         [],
         scheme=RandomUserPartitionScheme
     )
     # get a group assigned to the user
     with self.assertRaisesRegexp(UserPartitionError, "Cannot assign user to an empty user partition"):
         RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, empty_partition)
开发者ID:189140879,项目名称:edx-platform,代码行数:13,代码来源:test_partition_schemes.py

示例3: test_user_in_deleted_group

# 需要导入模块: from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme [as 别名]
# 或者: from openedx.core.djangoapps.user_api.partition_schemes.RandomUserPartitionScheme import get_group_for_user [as 别名]
    def test_user_in_deleted_group(self):
        # get a group assigned to the user - should be group 0 or 1
        old_group = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition)
        self.assertIn(old_group.id, [0, 1])

        # Change the group definitions! No more group 0 or 1
        groups = [Group(3, 'Group 3'), Group(4, 'Group 4')]
        user_partition = UserPartition(self.TEST_ID, 'Test Partition', 'for testing purposes', groups)

        # Now, get a new group using the same call - should be 3 or 4
        new_group = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, user_partition)
        self.assertIn(new_group.id, [3, 4])

        # We should get the same group over multiple calls
        new_group_2 = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, user_partition)
        self.assertEqual(new_group, new_group_2)
开发者ID:189140879,项目名称:edx-platform,代码行数:18,代码来源:test_partition_schemes.py

示例4: test_get_group_for_user_with_assign

# 需要导入模块: from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme [as 别名]
# 或者: from openedx.core.djangoapps.user_api.partition_schemes.RandomUserPartitionScheme import get_group_for_user [as 别名]
    def test_get_group_for_user_with_assign(self):
        """
        Make sure get_group_for_user returns None if no group is already
        assigned to a user instead of assigning/creating a group automatically
        """
        # We should not get any group because assign is False which will
        # protect us from automatically creating a group for user
        group = RandomUserPartitionScheme.get_group_for_user(
            self.MOCK_COURSE_ID, self.user, self.user_partition, assign=False
        )

        self.assertIsNone(group)

        # We should get a group automatically assigned to user
        group = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition)

        self.assertIsNotNone(group)
开发者ID:189140879,项目名称:edx-platform,代码行数:19,代码来源:test_partition_schemes.py

示例5: test_change_group_name

# 需要导入模块: from openedx.core.djangoapps.user_api.partition_schemes import RandomUserPartitionScheme [as 别名]
# 或者: from openedx.core.djangoapps.user_api.partition_schemes.RandomUserPartitionScheme import get_group_for_user [as 别名]
    def test_change_group_name(self):
        # Changing the name of the group shouldn't affect anything
        # get a group assigned to the user - should be group 0 or 1
        old_group = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, self.user_partition)
        self.assertIn(old_group.id, [0, 1])

        # Change the group names
        groups = [Group(0, 'Group 0'), Group(1, 'Group 1')]
        user_partition = UserPartition(
            self.TEST_ID,
            'Test Partition',
            'for testing purposes',
            groups,
            scheme=RandomUserPartitionScheme
        )

        # Now, get a new group using the same call
        new_group = RandomUserPartitionScheme.get_group_for_user(self.MOCK_COURSE_ID, self.user, user_partition)
        self.assertEqual(old_group.id, new_group.id)
开发者ID:189140879,项目名称:edx-platform,代码行数:21,代码来源:test_partition_schemes.py


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