This commit adds all of cms. These keys are now objects with a limited interface, and the particular internal representation is managed by the data storage layer (the modulestore). For the LMS, there should be no outward-facing changes to the system. The keys are, for now, a change to internal representation only. For Studio, the new serialized form of the keys is used in urls, to allow for further migration in the future. Co-Author: Andy Armstrong <andya@edx.org> Co-Author: Christina Roberts <christina@edx.org> Co-Author: David Baumgold <db@edx.org> Co-Author: Diana Huang <dkh@edx.org> Co-Author: Don Mitchell <dmitchell@edx.org> Co-Author: Julia Hansbrough <julia@edx.org> Co-Author: Nimisha Asthagiri <nasthagiri@edx.org> Co-Author: Sarina Canelake <sarina@edx.org> [LMS-2370]
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""
|
|
Tests access.py
|
|
"""
|
|
from django.test import TestCase
|
|
from django.contrib.auth.models import User
|
|
|
|
from student.roles import CourseInstructorRole, CourseStaffRole
|
|
from student.tests.factories import AdminFactory
|
|
from student.auth import add_users
|
|
from contentstore.views.access import get_user_role
|
|
from xmodule.modulestore.locations import SlashSeparatedCourseKey
|
|
|
|
|
|
class RolesTest(TestCase):
|
|
"""
|
|
Tests for lti user role serialization.
|
|
"""
|
|
def setUp(self):
|
|
""" Test case setup """
|
|
self.global_admin = AdminFactory()
|
|
self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo')
|
|
self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo')
|
|
self.course_key = SlashSeparatedCourseKey('mitX', '101', 'test')
|
|
|
|
def test_get_user_role_instructor(self):
|
|
"""
|
|
Verifies if user is instructor.
|
|
"""
|
|
add_users(self.global_admin, CourseInstructorRole(self.course_key), self.instructor)
|
|
self.assertEqual(
|
|
'instructor',
|
|
get_user_role(self.instructor, self.course_key)
|
|
)
|
|
add_users(self.global_admin, CourseStaffRole(self.course_key), self.staff)
|
|
self.assertEqual(
|
|
'instructor',
|
|
get_user_role(self.instructor, self.course_key)
|
|
)
|
|
|
|
def test_get_user_role_staff(self):
|
|
"""
|
|
Verifies if user is staff.
|
|
"""
|
|
add_users(self.global_admin, CourseStaffRole(self.course_key), self.staff)
|
|
self.assertEqual(
|
|
'staff',
|
|
get_user_role(self.staff, self.course_key)
|
|
)
|