refactor: Move InstructorFactory helper to common/
This commit is contained in:
@@ -26,6 +26,7 @@ from common.djangoapps.student.models import (
|
||||
UserStanding
|
||||
)
|
||||
from common.djangoapps.student.roles import GlobalStaff
|
||||
from common.djangoapps.student.roles import CourseInstructorRole
|
||||
from common.djangoapps.student.roles import CourseStaffRole
|
||||
|
||||
# Factories are self documenting
|
||||
@@ -242,6 +243,20 @@ class GlobalStaffFactory(UserFactory):
|
||||
GlobalStaff().add_users(self)
|
||||
|
||||
|
||||
class InstructorFactory(UserFactory):
|
||||
"""
|
||||
Given a course Location, returns a User object with instructor
|
||||
permissions for `course`.
|
||||
"""
|
||||
last_name = 'Instructor'
|
||||
|
||||
@factory.post_generation
|
||||
def course_key(self, _create, extracted, **kwargs):
|
||||
if extracted is None:
|
||||
raise ValueError('Must specify a CourseKey for a course instructor user')
|
||||
CourseInstructorRole(extracted).add_users(self)
|
||||
|
||||
|
||||
class StaffFactory(UserFactory):
|
||||
"""
|
||||
Given a course Location, returns a User object with staff
|
||||
|
||||
@@ -8,7 +8,6 @@ import six
|
||||
from django.test import TestCase
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from lms.djangoapps.courseware.tests.factories import InstructorFactory
|
||||
from common.djangoapps.student.roles import (
|
||||
CourseBetaTesterRole,
|
||||
CourseInstructorRole,
|
||||
@@ -20,6 +19,7 @@ from common.djangoapps.student.roles import (
|
||||
RoleCache
|
||||
)
|
||||
from common.djangoapps.student.tests.factories import AnonymousUserFactory
|
||||
from common.djangoapps.student.tests.factories import InstructorFactory
|
||||
from common.djangoapps.student.tests.factories import StaffFactory
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
|
||||
|
||||
Reference in New Issue
Block a user