The get_course_members API returns a dict of users associated with a course. This is a potentially expensive operation on a large course, so there is a control in place to limit its cost. If a course has more than settings.COURSE_MEMBER_API_ENROLLMENT_LIMIT enrollments, then the function raises an OverEnrollmentLimitException. This API was added to help implement the LTI 1.3 Names and Roles Provisioning service. Jira references: [BD-24] [BB-2726] [TNL-7330] Pull request: #25843 Co-authored-by: Giovanni Cimolin da Silva <giovannicimolin@gmail.com>
58 lines
1.5 KiB
Python
58 lines
1.5 KiB
Python
"""
|
|
Common mixins for Course API Tests
|
|
"""
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
from common.djangoapps.student.tests.factories import UserFactory, CourseEnrollmentFactory, CourseAccessRoleFactory
|
|
from xmodule.modulestore.tests.factories import ToyCourseFactory
|
|
|
|
TEST_PASSWORD = 'edx'
|
|
|
|
|
|
class CourseApiFactoryMixin:
|
|
"""
|
|
Mixin to allow creation of test courses and users.
|
|
"""
|
|
|
|
@staticmethod
|
|
def create_course(**kwargs):
|
|
"""
|
|
Create a course for use in test cases
|
|
"""
|
|
|
|
return ToyCourseFactory.create(
|
|
end=datetime(2015, 9, 19, 18, 0, 0),
|
|
enrollment_start=datetime(2015, 6, 15, 0, 0, 0),
|
|
enrollment_end=datetime(2015, 7, 15, 0, 0, 0),
|
|
emit_signals=True,
|
|
**kwargs
|
|
)
|
|
|
|
@staticmethod
|
|
def create_user(username, is_staff):
|
|
"""
|
|
Create a user as identified by username, email, password and is_staff.
|
|
"""
|
|
return UserFactory(
|
|
username=username,
|
|
email=f'{username}@example.com',
|
|
password=TEST_PASSWORD,
|
|
is_staff=is_staff
|
|
)
|
|
|
|
@staticmethod
|
|
def create_enrollment(**kwargs):
|
|
"""
|
|
Create a CourseEnrollment to use in tests.
|
|
"""
|
|
return CourseEnrollmentFactory(**kwargs)
|
|
|
|
@staticmethod
|
|
def create_courseaccessrole(**kwargs):
|
|
"""
|
|
Create a CourseAccessRole to use in tests.
|
|
"""
|
|
return CourseAccessRoleFactory(**kwargs)
|