'Tests particular user\'s can access content via has_access in preview mode.'

@patch('courseware.access.in_preview_mode', Mock(return_value=True))
def test_has_access_with_preview_mode(self):

    self.assertTrue(bool(access.has_access(self.global_staff, 'staff', self.course, course_key=self.course.id)))
    self.assertTrue(bool(access.has_access(self.course_staff, 'staff', self.course, course_key=self.course.id)))
    self.assertTrue(bool(access.has_access(self.course_instructor, 'staff', self.course, course_key=self.course.id)))
    self.assertFalse(bool(access.has_access(self.student, 'staff', self.course, course_key=self.course.id)))
    self.assertFalse(bool(access.has_access(self.student, 'load', self.course, course_key=self.course.id)))
    with patch('courseware.access.is_masquerading_as_student') as mock_masquerade:
        mock_masquerade.return_value = True
        self.assertFalse(bool(access.has_access(self.global_staff, 'staff', self.course, course_key=self.course.id)))
        self.assertFalse(bool(access.has_access(self.student, 'staff', self.course, course_key=self.course.id)))
