'Test that preview mode is only accessible by staff users.'

def test_has_staff_access_to_preview_mode(self):

    course_key = self.course.id
    CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
    for user in [self.global_staff, self.course_staff, self.course_instructor]:
        self.assertTrue(access.has_staff_access_to_preview_mode(user, course_key))
    self.assertFalse(access.has_staff_access_to_preview_mode(self.student, course_key))
    with patch('courseware.access.is_masquerading_as_student') as mock_masquerade:
        mock_masquerade.return_value = True
        for user in [self.global_staff, self.course_staff, self.course_instructor, self.student]:
            self.assertTrue(access.has_staff_access_to_preview_mode(user, course_key))
