本文整理汇总了Python中lms.djangoapps.teams.tests.factories.CourseTeamFactory.add_user方法的典型用法代码示例。如果您正苦于以下问题:Python CourseTeamFactory.add_user方法的具体用法?Python CourseTeamFactory.add_user怎么用?Python CourseTeamFactory.add_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lms.djangoapps.teams.tests.factories.CourseTeamFactory
的用法示例。
在下文中一共展示了CourseTeamFactory.add_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_team_discussion_id_not_cohorted
# 需要导入模块: from lms.djangoapps.teams.tests.factories import CourseTeamFactory [as 别名]
# 或者: from lms.djangoapps.teams.tests.factories.CourseTeamFactory import add_user [as 别名]
def test_team_discussion_id_not_cohorted(self, mock_request):
team = CourseTeamFactory(course_id=self.course.id)
team.add_user(self.student) # pylint: disable=no-member
self.call_view(mock_request, team.discussion_topic_id, self.student, None)
self._assert_comments_service_called_without_group_id(mock_request)
示例2: TeamMembershipTest
# 需要导入模块: from lms.djangoapps.teams.tests.factories import CourseTeamFactory [as 别名]
# 或者: from lms.djangoapps.teams.tests.factories.CourseTeamFactory import add_user [as 别名]
class TeamMembershipTest(SharedModuleStoreTestCase):
"""Tests for the TeamMembership model."""
shard = 4
def setUp(self):
"""
Set up tests.
"""
super(TeamMembershipTest, self).setUp()
self.user1 = UserFactory.create(username='user1')
self.user2 = UserFactory.create(username='user2')
self.user3 = UserFactory.create(username='user3')
for user in (self.user1, self.user2, self.user3):
CourseEnrollmentFactory.create(user=user, course_id=COURSE_KEY1)
CourseEnrollmentFactory.create(user=self.user1, course_id=COURSE_KEY2)
self.team1 = CourseTeamFactory(course_id=COURSE_KEY1, team_id='team1')
self.team2 = CourseTeamFactory(course_id=COURSE_KEY2, team_id='team2')
self.team_membership11 = self.team1.add_user(self.user1)
self.team_membership12 = self.team1.add_user(self.user2)
self.team_membership21 = self.team2.add_user(self.user1)
def test_membership_last_activity_set(self):
current_last_activity = self.team_membership11.last_activity_at
# Assert that the first save in the setUp sets a value.
self.assertIsNotNone(current_last_activity)
self.team_membership11.save()
# Verify that we only change the last activity_at when it doesn't
# already exist.
self.assertEqual(self.team_membership11.last_activity_at, current_last_activity)
def test_team_size_delete_membership(self):
"""Test that the team size field is correctly updated when deleting a
team membership.
"""
self.assertEqual(self.team1.team_size, 2)
self.team_membership11.delete()
team = CourseTeam.objects.get(id=self.team1.id)
self.assertEqual(team.team_size, 1)
def test_team_size_create_membership(self):
"""Test that the team size field is correctly updated when creating a
team membership.
"""
self.assertEqual(self.team1.team_size, 2)
self.team1.add_user(self.user3)
team = CourseTeam.objects.get(id=self.team1.id)
self.assertEqual(team.team_size, 3)
@ddt.data(
(None, None, None, 3),
('user1', None, None, 2),
('user1', [COURSE_KEY1], None, 1),
('user1', None, 'team1', 1),
('user2', None, None, 1),
)
@ddt.unpack
def test_get_memberships(self, username, course_ids, team_id, expected_count):
self.assertEqual(
CourseTeamMembership.get_memberships(username=username, course_ids=course_ids, team_id=team_id).count(),
expected_count
)
@ddt.data(
('user1', COURSE_KEY1, True),
('user2', COURSE_KEY1, True),
('user2', COURSE_KEY2, False),
)
@ddt.unpack
def test_user_in_team_for_course(self, username, course_id, expected_value):
user = getattr(self, username)
self.assertEqual(
CourseTeamMembership.user_in_team_for_course(user, course_id),
expected_value
)