Commit 110719de by Sarina Canelake

StaffFactories accept `course_key`s, not `course`s. Make that clear in the interface.

parent 265fa826
...@@ -18,13 +18,13 @@ class RolesTestCase(TestCase): ...@@ -18,13 +18,13 @@ class RolesTestCase(TestCase):
""" """
def setUp(self): def setUp(self):
self.course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
self.course_loc = self.course_id.make_usage_key('course', '2012_Fall') self.course_loc = self.course_key.make_usage_key('course', '2012_Fall')
self.anonymous_user = AnonymousUserFactory() self.anonymous_user = AnonymousUserFactory()
self.student = UserFactory() self.student = UserFactory()
self.global_staff = UserFactory(is_staff=True) self.global_staff = UserFactory(is_staff=True)
self.course_staff = StaffFactory(course=self.course_id) self.course_staff = StaffFactory(course_key=self.course_key)
self.course_instructor = InstructorFactory(course=self.course_id) self.course_instructor = InstructorFactory(course_key=self.course_key)
def test_global_staff(self): def test_global_staff(self):
self.assertFalse(GlobalStaff().has_user(self.student)) self.assertFalse(GlobalStaff().has_user(self.student))
...@@ -55,20 +55,20 @@ class RolesTestCase(TestCase): ...@@ -55,20 +55,20 @@ class RolesTestCase(TestCase):
Test that giving a user a course role enables access appropriately Test that giving a user a course role enables access appropriately
""" """
self.assertFalse( self.assertFalse(
CourseStaffRole(self.course_id).has_user(self.student), CourseStaffRole(self.course_key).has_user(self.student),
"Student has premature access to {}".format(self.course_id) "Student has premature access to {}".format(self.course_key)
) )
CourseStaffRole(self.course_id).add_users(self.student) CourseStaffRole(self.course_key).add_users(self.student)
self.assertTrue( self.assertTrue(
CourseStaffRole(self.course_id).has_user(self.student), CourseStaffRole(self.course_key).has_user(self.student),
"Student doesn't have access to {}".format(unicode(self.course_id)) "Student doesn't have access to {}".format(unicode(self.course_key))
) )
# remove access and confirm # remove access and confirm
CourseStaffRole(self.course_id).remove_users(self.student) CourseStaffRole(self.course_key).remove_users(self.student)
self.assertFalse( self.assertFalse(
CourseStaffRole(self.course_id).has_user(self.student), CourseStaffRole(self.course_key).has_user(self.student),
"Student still has access to {}".format(self.course_id) "Student still has access to {}".format(self.course_key)
) )
def test_org_role(self): def test_org_role(self):
...@@ -76,67 +76,67 @@ class RolesTestCase(TestCase): ...@@ -76,67 +76,67 @@ class RolesTestCase(TestCase):
Test that giving a user an org role enables access appropriately Test that giving a user an org role enables access appropriately
""" """
self.assertFalse( self.assertFalse(
OrgStaffRole(self.course_id.org).has_user(self.student), OrgStaffRole(self.course_key.org).has_user(self.student),
"Student has premature access to {}".format(self.course_id.org) "Student has premature access to {}".format(self.course_key.org)
) )
OrgStaffRole(self.course_id.org).add_users(self.student) OrgStaffRole(self.course_key.org).add_users(self.student)
self.assertTrue( self.assertTrue(
OrgStaffRole(self.course_id.org).has_user(self.student), OrgStaffRole(self.course_key.org).has_user(self.student),
"Student doesn't have access to {}".format(unicode(self.course_id.org)) "Student doesn't have access to {}".format(unicode(self.course_key.org))
) )
# remove access and confirm # remove access and confirm
OrgStaffRole(self.course_id.org).remove_users(self.student) OrgStaffRole(self.course_key.org).remove_users(self.student)
if hasattr(self.student, '_roles'): if hasattr(self.student, '_roles'):
del self.student._roles del self.student._roles
self.assertFalse( self.assertFalse(
OrgStaffRole(self.course_id.org).has_user(self.student), OrgStaffRole(self.course_key.org).has_user(self.student),
"Student still has access to {}".format(self.course_id.org) "Student still has access to {}".format(self.course_key.org)
) )
def test_org_and_course_roles(self): def test_org_and_course_roles(self):
""" """
Test that Org and course roles don't interfere with course roles or vice versa Test that Org and course roles don't interfere with course roles or vice versa
""" """
OrgInstructorRole(self.course_id.org).add_users(self.student) OrgInstructorRole(self.course_key.org).add_users(self.student)
CourseInstructorRole(self.course_id).add_users(self.student) CourseInstructorRole(self.course_key).add_users(self.student)
self.assertTrue( self.assertTrue(
OrgInstructorRole(self.course_id.org).has_user(self.student), OrgInstructorRole(self.course_key.org).has_user(self.student),
"Student doesn't have access to {}".format(unicode(self.course_id.org)) "Student doesn't have access to {}".format(unicode(self.course_key.org))
) )
self.assertTrue( self.assertTrue(
CourseInstructorRole(self.course_id).has_user(self.student), CourseInstructorRole(self.course_key).has_user(self.student),
"Student doesn't have access to {}".format(unicode(self.course_id)) "Student doesn't have access to {}".format(unicode(self.course_key))
) )
# remove access and confirm # remove access and confirm
OrgInstructorRole(self.course_id.org).remove_users(self.student) OrgInstructorRole(self.course_key.org).remove_users(self.student)
self.assertFalse( self.assertFalse(
OrgInstructorRole(self.course_id.org).has_user(self.student), OrgInstructorRole(self.course_key.org).has_user(self.student),
"Student still has access to {}".format(self.course_id.org) "Student still has access to {}".format(self.course_key.org)
) )
self.assertTrue( self.assertTrue(
CourseInstructorRole(self.course_id).has_user(self.student), CourseInstructorRole(self.course_key).has_user(self.student),
"Student doesn't have access to {}".format(unicode(self.course_id)) "Student doesn't have access to {}".format(unicode(self.course_key))
) )
# ok now keep org role and get rid of course one # ok now keep org role and get rid of course one
OrgInstructorRole(self.course_id.org).add_users(self.student) OrgInstructorRole(self.course_key.org).add_users(self.student)
CourseInstructorRole(self.course_id).remove_users(self.student) CourseInstructorRole(self.course_key).remove_users(self.student)
self.assertTrue( self.assertTrue(
OrgInstructorRole(self.course_id.org).has_user(self.student), OrgInstructorRole(self.course_key.org).has_user(self.student),
"Student lost has access to {}".format(self.course_id.org) "Student lost has access to {}".format(self.course_key.org)
) )
self.assertFalse( self.assertFalse(
CourseInstructorRole(self.course_id).has_user(self.student), CourseInstructorRole(self.course_key).has_user(self.student),
"Student doesn't have access to {}".format(unicode(self.course_id)) "Student doesn't have access to {}".format(unicode(self.course_key))
) )
def test_get_user_for_role(self): def test_get_user_for_role(self):
""" """
test users_for_role test users_for_role
""" """
role = CourseStaffRole(self.course_id) role = CourseStaffRole(self.course_key)
role.add_users(self.student) role.add_users(self.student)
self.assertGreater(len(role.users_with_role()), 0) self.assertGreater(len(role.users_with_role()), 0)
...@@ -145,7 +145,7 @@ class RolesTestCase(TestCase): ...@@ -145,7 +145,7 @@ class RolesTestCase(TestCase):
Tests that calling add_users multiple times before a single call Tests that calling add_users multiple times before a single call
to remove_users does not result in the user remaining in the group. to remove_users does not result in the user remaining in the group.
""" """
role = CourseStaffRole(self.course_id) role = CourseStaffRole(self.course_key)
role.add_users(self.student) role.add_users(self.student)
self.assertTrue(role.has_user(self.student)) self.assertTrue(role.has_user(self.student))
# Call add_users a second time, then remove just once. # Call add_users a second time, then remove just once.
......
...@@ -54,10 +54,10 @@ class TestEmailSendFromDashboard(ModuleStoreTestCase): ...@@ -54,10 +54,10 @@ class TestEmailSendFromDashboard(ModuleStoreTestCase):
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ" course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title) self.course = CourseFactory.create(display_name=course_title)
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
# Create staff # Create staff
self.staff = [StaffFactory(course=self.course.id) self.staff = [StaffFactory(course_key=self.course.id)
for _ in xrange(STAFF_COUNT)] for _ in xrange(STAFF_COUNT)]
# Create students # Create students
......
...@@ -48,8 +48,8 @@ class TestWikiAccessBase(ModuleStoreTestCase): ...@@ -48,8 +48,8 @@ class TestWikiAccessBase(ModuleStoreTestCase):
"""Creates and returns users with instructor and staff access to course.""" """Creates and returns users with instructor and staff access to course."""
return [ return [
InstructorFactory(course=course.id), # Creates instructor_org/number/run role name InstructorFactory(course_key=course.id), # Creates instructor_org/number/run role name
StaffFactory(course=course.id), # Creates staff_org/number/run role name StaffFactory(course_key=course.id), # Creates staff_org/number/run role name
] ]
......
...@@ -23,7 +23,7 @@ class TestWikiAccessMiddleware(ModuleStoreTestCase): ...@@ -23,7 +23,7 @@ class TestWikiAccessMiddleware(ModuleStoreTestCase):
self.wiki = get_or_create_root() self.wiki = get_or_create_root()
self.course_math101 = CourseFactory.create(org='edx', number='math101', display_name='2014', metadata={'use_unique_wiki_id': 'false'}) self.course_math101 = CourseFactory.create(org='edx', number='math101', display_name='2014', metadata={'use_unique_wiki_id': 'false'})
self.course_math101_instructor = InstructorFactory(course=self.course_math101.id, username='instructor', password='secret') self.course_math101_instructor = InstructorFactory(course_key=self.course_math101.id, username='instructor', password='secret')
self.wiki_math101 = URLPath.create_article(self.wiki, 'math101', title='math101') self.wiki_math101 = URLPath.create_article(self.wiki, 'math101', title='math101')
self.client = Client() self.client = Client()
......
...@@ -196,9 +196,9 @@ def i_am_registered_for_the_course(coursenum, metadata, user='Instructor'): ...@@ -196,9 +196,9 @@ def i_am_registered_for_the_course(coursenum, metadata, user='Instructor'):
course_descriptor = world.scenario_dict['COURSE'] course_descriptor = world.scenario_dict['COURSE']
# create beta tester # create beta tester
user = BetaTesterFactory(course=course_descriptor.id) user = BetaTesterFactory(course_key=course_descriptor.id)
normal_student = UserFactory() normal_student = UserFactory()
instructor = InstructorFactory(course=course_descriptor.id) instructor = InstructorFactory(course_key=course_descriptor.id)
assert not has_access(normal_student, 'load', course_descriptor) assert not has_access(normal_student, 'load', course_descriptor)
assert has_access(user, 'load', course_descriptor) assert has_access(user, 'load', course_descriptor)
...@@ -207,7 +207,7 @@ def i_am_registered_for_the_course(coursenum, metadata, user='Instructor'): ...@@ -207,7 +207,7 @@ def i_am_registered_for_the_course(coursenum, metadata, user='Instructor'):
metadata.update({'start': datetime.datetime(1970, 1, 1, tzinfo=UTC)}) metadata.update({'start': datetime.datetime(1970, 1, 1, tzinfo=UTC)})
create_course_for_lti(coursenum, metadata) create_course_for_lti(coursenum, metadata)
course_descriptor = world.scenario_dict['COURSE'] course_descriptor = world.scenario_dict['COURSE']
user = InstructorFactory(course=course_descriptor.id) user = InstructorFactory(course_key=course_descriptor.id)
# Enroll the user in the course and log them in # Enroll the user in the course and log them in
if has_access(user, 'load', course_descriptor): if has_access(user, 'load', course_descriptor):
......
# Factories don't have __init__ methods, and are self documenting
# pylint: disable=W0232, C0111
import json import json
from functools import partial from functools import partial
import factory import factory
...@@ -23,6 +25,8 @@ from student.roles import ( ...@@ -23,6 +25,8 @@ from student.roles import (
from xmodule.modulestore.locations import SlashSeparatedCourseKey from xmodule.modulestore.locations import SlashSeparatedCourseKey
# TODO fix this (course_id and location are invalid names as constants, and course_id should really be COURSE_KEY)
# pylint: disable=invalid-name
course_id = SlashSeparatedCourseKey(u'edX', u'test_course', u'test') course_id = SlashSeparatedCourseKey(u'edX', u'test_course', u'test')
location = partial(course_id.make_usage_key, u'problem') location = partial(course_id.make_usage_key, u'problem')
...@@ -31,6 +35,11 @@ class UserProfileFactory(StudentUserProfileFactory): ...@@ -31,6 +35,11 @@ class UserProfileFactory(StudentUserProfileFactory):
courseware = 'course.xml' courseware = 'course.xml'
# For the following factories, these are disabled because we're ok ignoring the
# unused arguments create and **kwargs in the line:
# course_key(self, create, extracted, **kwargs)
# pylint: disable=unused-argument
class InstructorFactory(UserFactory): class InstructorFactory(UserFactory):
""" """
Given a course Location, returns a User object with instructor Given a course Location, returns a User object with instructor
...@@ -39,8 +48,7 @@ class InstructorFactory(UserFactory): ...@@ -39,8 +48,7 @@ class InstructorFactory(UserFactory):
last_name = "Instructor" last_name = "Instructor"
@factory.post_generation @factory.post_generation
# TODO Change this from course to course_key at next opportunity def course_key(self, create, extracted, **kwargs):
def course(self, create, extracted, **kwargs):
if extracted is None: if extracted is None:
raise ValueError("Must specify a CourseKey for a course instructor user") raise ValueError("Must specify a CourseKey for a course instructor user")
CourseInstructorRole(extracted).add_users(self) CourseInstructorRole(extracted).add_users(self)
...@@ -54,8 +62,7 @@ class StaffFactory(UserFactory): ...@@ -54,8 +62,7 @@ class StaffFactory(UserFactory):
last_name = "Staff" last_name = "Staff"
@factory.post_generation @factory.post_generation
# TODO Change this from course to course_key at next opportunity def course_key(self, create, extracted, **kwargs):
def course(self, create, extracted, **kwargs):
if extracted is None: if extracted is None:
raise ValueError("Must specify a CourseKey for a course staff user") raise ValueError("Must specify a CourseKey for a course staff user")
CourseStaffRole(extracted).add_users(self) CourseStaffRole(extracted).add_users(self)
...@@ -69,8 +76,7 @@ class BetaTesterFactory(UserFactory): ...@@ -69,8 +76,7 @@ class BetaTesterFactory(UserFactory):
last_name = "Beta-Tester" last_name = "Beta-Tester"
@factory.post_generation @factory.post_generation
# TODO Change this from course to course_key at next opportunity def course_key(self, create, extracted, **kwargs):
def course(self, create, extracted, **kwargs):
if extracted is None: if extracted is None:
raise ValueError("Must specify a CourseKey for a beta-tester user") raise ValueError("Must specify a CourseKey for a beta-tester user")
CourseBetaTesterRole(extracted).add_users(self) CourseBetaTesterRole(extracted).add_users(self)
...@@ -84,8 +90,7 @@ class OrgStaffFactory(UserFactory): ...@@ -84,8 +90,7 @@ class OrgStaffFactory(UserFactory):
last_name = "Org-Staff" last_name = "Org-Staff"
@factory.post_generation @factory.post_generation
# TODO Change this from course to course_key at next opportunity def course_key(self, create, extracted, **kwargs):
def course(self, create, extracted, **kwargs):
if extracted is None: if extracted is None:
raise ValueError("Must specify a CourseKey for an org-staff user") raise ValueError("Must specify a CourseKey for an org-staff user")
OrgStaffRole(extracted.org).add_users(self) OrgStaffRole(extracted.org).add_users(self)
...@@ -99,8 +104,7 @@ class OrgInstructorFactory(UserFactory): ...@@ -99,8 +104,7 @@ class OrgInstructorFactory(UserFactory):
last_name = "Org-Instructor" last_name = "Org-Instructor"
@factory.post_generation @factory.post_generation
# TODO Change this from course to course_key at next opportunity def course_key(self, create, extracted, **kwargs):
def course(self, create, extracted, **kwargs):
if extracted is None: if extracted is None:
raise ValueError("Must specify a CourseKey for an org-instructor user") raise ValueError("Must specify a CourseKey for an org-instructor user")
OrgInstructorRole(extracted.org).add_users(self) OrgInstructorRole(extracted.org).add_users(self)
...@@ -115,6 +119,7 @@ class GlobalStaffFactory(UserFactory): ...@@ -115,6 +119,7 @@ class GlobalStaffFactory(UserFactory):
@factory.post_generation @factory.post_generation
def set_staff(self, create, extracted, **kwargs): def set_staff(self, create, extracted, **kwargs):
GlobalStaff().add_users(self) GlobalStaff().add_users(self)
# pylint: enable=unused-argument
class StudentModuleFactory(DjangoModelFactory): class StudentModuleFactory(DjangoModelFactory):
......
...@@ -26,9 +26,8 @@ class AccessTestCase(TestCase): ...@@ -26,9 +26,8 @@ class AccessTestCase(TestCase):
self.anonymous_user = AnonymousUserFactory() self.anonymous_user = AnonymousUserFactory()
self.student = UserFactory() self.student = UserFactory()
self.global_staff = UserFactory(is_staff=True) self.global_staff = UserFactory(is_staff=True)
# TODO please change the StaffFactory and InstructorFactory parameters ASAP! self.course_staff = StaffFactory(course_key=self.course.course_key)
self.course_staff = StaffFactory(course=self.course.course_key) self.course_instructor = InstructorFactory(course_key=self.course.course_key)
self.course_instructor = InstructorFactory(course=self.course.course_key)
def test_has_access_to_course(self): def test_has_access_to_course(self):
self.assertFalse(access._has_access_to_course( self.assertFalse(access._has_access_to_course(
...@@ -144,8 +143,8 @@ class UserRoleTestCase(TestCase): ...@@ -144,8 +143,8 @@ class UserRoleTestCase(TestCase):
self.anonymous_user = AnonymousUserFactory() self.anonymous_user = AnonymousUserFactory()
self.student = UserFactory() self.student = UserFactory()
self.global_staff = UserFactory(is_staff=True) self.global_staff = UserFactory(is_staff=True)
self.course_staff = StaffFactory(course=self.course_key) self.course_staff = StaffFactory(course_key=self.course_key)
self.course_instructor = InstructorFactory(course=self.course_key) self.course_instructor = InstructorFactory(course_key=self.course_key)
def test_user_role_staff(self): def test_user_role_staff(self):
"""Ensure that user role is student for staff masqueraded as student.""" """Ensure that user role is student for staff masqueraded as student."""
......
...@@ -36,7 +36,7 @@ class TestStaffMasqueradeAsStudent(ModuleStoreTestCase, LoginEnrollmentTestCase) ...@@ -36,7 +36,7 @@ class TestStaffMasqueradeAsStudent(ModuleStoreTestCase, LoginEnrollmentTestCase)
self.graded_course = modulestore().get_course(SlashSeparatedCourseKey("edX", "graded", "2012_Fall")) self.graded_course = modulestore().get_course(SlashSeparatedCourseKey("edX", "graded", "2012_Fall"))
# Create staff account # Create staff account
self.staff = StaffFactory(course=self.graded_course.id) self.staff = StaffFactory(course_key=self.graded_course.id)
self.logout() self.logout()
# self.staff.password is the sha hash but login takes the plain text # self.staff.password is the sha hash but login takes the plain text
......
...@@ -138,11 +138,10 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -138,11 +138,10 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.course.id) CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.course.id)
CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.test_course.id) CourseEnrollmentFactory(user=self.enrolled_user, course_id=self.test_course.id)
self.staff_user = StaffFactory(course=self.course.id) self.staff_user = StaffFactory(course_key=self.course.id)
self.instructor_user = InstructorFactory( self.instructor_user = InstructorFactory(course_key=self.course.id)
course=self.course.id) self.org_staff_user = OrgStaffFactory(course_key=self.course.id)
self.org_staff_user = OrgStaffFactory(course=self.course.id) self.org_instructor_user = OrgInstructorFactory(course_key=self.course.id)
self.org_instructor_user = OrgInstructorFactory(course=self.course.id)
def test_redirection_unenrolled(self): def test_redirection_unenrolled(self):
""" """
...@@ -374,7 +373,7 @@ class TestBetatesterAccess(ModuleStoreTestCase): ...@@ -374,7 +373,7 @@ class TestBetatesterAccess(ModuleStoreTestCase):
self.content = ItemFactory(parent=self.course) self.content = ItemFactory(parent=self.course)
self.normal_student = UserFactory() self.normal_student = UserFactory()
self.beta_tester = BetaTesterFactory(course=self.course.id) self.beta_tester = BetaTesterFactory(course_key=self.course.id)
@patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False}) @patch.dict('courseware.access.settings.FEATURES', {'DISABLE_START_DATES': False})
def test_course_beta_period(self): def test_course_beta_period(self):
......
...@@ -29,19 +29,19 @@ def make_populated_course(step): # pylint: disable=unused-argument ...@@ -29,19 +29,19 @@ def make_populated_course(step): # pylint: disable=unused-argument
number='888', number='888',
display_name='Bulk Email Test Course' display_name='Bulk Email Test Course'
) )
world.bulk_email_course_id = course.id world.bulk_email_course_key = course.id
try: try:
# See if we've defined the instructor & staff user yet # See if we've defined the instructor & staff user yet
world.bulk_email_instructor world.bulk_email_instructor
except AttributeError: except AttributeError:
# Make & register an instructor for the course # Make & register an instructor for the course
world.bulk_email_instructor = InstructorFactory(course=world.bulk_email_course_id) world.bulk_email_instructor = InstructorFactory(course_key=world.bulk_email_course_key)
world.enroll_user(world.bulk_email_instructor, world.bulk_email_course_id) world.enroll_user(world.bulk_email_instructor, world.bulk_email_course_key)
# Make & register a staff member # Make & register a staff member
world.bulk_email_staff = StaffFactory(course=course.id) world.bulk_email_staff = StaffFactory(course_key=course.id)
world.enroll_user(world.bulk_email_staff, world.bulk_email_course_id) world.enroll_user(world.bulk_email_staff, world.bulk_email_course_key)
# Make & register a student # Make & register a student
world.register_by_course_key( world.register_by_course_key(
......
...@@ -43,13 +43,13 @@ def i_am_staff_or_instructor(step, role): # pylint: disable=unused-argument ...@@ -43,13 +43,13 @@ def i_am_staff_or_instructor(step, role): # pylint: disable=unused-argument
display_name='Test Course' display_name='Test Course'
) )
world.course_id = course.id world.course_key = course.id
world.role = 'instructor' world.role = 'instructor'
# Log in as the an instructor or staff for the course # Log in as the an instructor or staff for the course
if role == 'instructor': if role == 'instructor':
# Make & register an instructor for the course # Make & register an instructor for the course
world.instructor = InstructorFactory(course=world.course_id) world.instructor = InstructorFactory(course_key=world.course_key)
world.enroll_user(world.instructor, world.course_id) world.enroll_user(world.instructor, world.course_key)
world.log_in( world.log_in(
username=world.instructor.username, username=world.instructor.username,
...@@ -61,8 +61,8 @@ def i_am_staff_or_instructor(step, role): # pylint: disable=unused-argument ...@@ -61,8 +61,8 @@ def i_am_staff_or_instructor(step, role): # pylint: disable=unused-argument
else: else:
world.role = 'staff' world.role = 'staff'
# Make & register a staff member # Make & register a staff member
world.staff = StaffFactory(course=world.course_id) world.staff = StaffFactory(course_key=world.course_key)
world.enroll_user(world.staff, world.course_id) world.enroll_user(world.staff, world.course_key)
world.log_in( world.log_in(
username=world.staff.username, username=world.staff.username,
......
...@@ -196,7 +196,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -196,7 +196,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
""" """
Ensure that a staff member can't access instructor endpoints. Ensure that a staff member can't access instructor endpoints.
""" """
staff_member = StaffFactory(course=self.course.id) staff_member = StaffFactory(course_key=self.course.id)
CourseEnrollment.enroll(staff_member, self.course.id) CourseEnrollment.enroll(staff_member, self.course.id)
self.client.login(username=staff_member.username, password='test') self.client.login(username=staff_member.username, password='test')
# Try to promote to forums admin - not working # Try to promote to forums admin - not working
...@@ -225,7 +225,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -225,7 +225,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
""" """
Ensure that an instructor member can access all endpoints. Ensure that an instructor member can access all endpoints.
""" """
inst = InstructorFactory(course=self.course.id) inst = InstructorFactory(course_key=self.course.id)
CourseEnrollment.enroll(inst, self.course.id) CourseEnrollment.enroll(inst, self.course.id)
self.client.login(username=inst.username, password='test') self.client.login(username=inst.username, password='test')
...@@ -263,7 +263,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -263,7 +263,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
def setUp(self): def setUp(self):
self.request = RequestFactory().request() self.request = RequestFactory().request()
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
self.enrolled_student = UserFactory(username='EnrolledStudent', first_name='Enrolled', last_name='Student') self.enrolled_student = UserFactory(username='EnrolledStudent', first_name='Enrolled', last_name='Student')
...@@ -751,10 +751,10 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe ...@@ -751,10 +751,10 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
""" """
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
self.beta_tester = BetaTesterFactory(course=self.course.id) self.beta_tester = BetaTesterFactory(course_key=self.course.id)
CourseEnrollment.enroll( CourseEnrollment.enroll(
self.beta_tester, self.beta_tester,
self.course.id self.course.id
...@@ -1056,11 +1056,11 @@ class TestInstructorAPILevelsAccess(ModuleStoreTestCase, LoginEnrollmentTestCase ...@@ -1056,11 +1056,11 @@ class TestInstructorAPILevelsAccess(ModuleStoreTestCase, LoginEnrollmentTestCase
""" """
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
self.other_instructor = InstructorFactory(course=self.course.id) self.other_instructor = InstructorFactory(course_key=self.course.id)
self.other_staff = StaffFactory(course=self.course.id) self.other_staff = StaffFactory(course_key=self.course.id)
self.other_user = UserFactory() self.other_user = UserFactory()
def test_modify_access_noparams(self): def test_modify_access_noparams(self):
...@@ -1299,7 +1299,7 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa ...@@ -1299,7 +1299,7 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
""" """
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
self.students = [UserFactory() for _ in xrange(6)] self.students = [UserFactory() for _ in xrange(6)]
...@@ -1478,7 +1478,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase) ...@@ -1478,7 +1478,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
""" """
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
self.student = UserFactory() self.student = UserFactory()
...@@ -1616,7 +1616,7 @@ class TestInstructorSendEmail(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -1616,7 +1616,7 @@ class TestInstructorSendEmail(ModuleStoreTestCase, LoginEnrollmentTestCase):
""" """
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
test_subject = u'\u1234 test subject' test_subject = u'\u1234 test subject'
test_message = u'\u6824 test message' test_message = u'\u6824 test message'
...@@ -1738,7 +1738,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -1738,7 +1738,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase):
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
self.student = UserFactory() self.student = UserFactory()
...@@ -1871,7 +1871,7 @@ class TestInstructorAPIAnalyticsProxy(ModuleStoreTestCase, LoginEnrollmentTestCa ...@@ -1871,7 +1871,7 @@ class TestInstructorAPIAnalyticsProxy(ModuleStoreTestCase, LoginEnrollmentTestCa
def setUp(self): def setUp(self):
self.course = CourseFactory.create() self.course = CourseFactory.create()
self.instructor = InstructorFactory(course=self.course.id) self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
@patch.object(instructor.views.api.requests, 'get') @patch.object(instructor.views.api.requests, 'get')
...@@ -2041,7 +2041,7 @@ class TestDueDateExtensions(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -2041,7 +2041,7 @@ class TestDueDateExtensions(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.user1 = user1 self.user1 = user1
self.user2 = user2 self.user2 = user2
self.instructor = InstructorFactory(course=course.id) self.instructor = InstructorFactory(course_key=course.id)
self.client.login(username=self.instructor.username, password='test') self.client.login(username=self.instructor.username, password='test')
def test_change_due_date(self): def test_change_due_date(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment