def test__has_access_error_desc(self, action, expected_student, expected_staff, expected_instructor): descriptor = Mock() for (user, expected_response) in ( (self.student, expected_student), (self.course_staff, expected_staff), (self.course_instructor, expected_instructor) ): self.assertEquals( bool(access._has_access_error_desc(user, action, descriptor, self.course.id)), expected_response ) with self.assertRaises(ValueError): access._has_access_error_desc(self.course_instructor, 'not_load_or_staff', descriptor, self.course.id)
def test__has_access_error_desc(self): descriptor = Mock() self.assertFalse(access._has_access_error_desc(self.student, 'load', descriptor, self.course.course_key)) self.assertTrue(access._has_access_error_desc(self.course_staff, 'load', descriptor, self.course.course_key)) self.assertTrue(access._has_access_error_desc(self.course_instructor, 'load', descriptor, self.course.course_key)) self.assertFalse(access._has_access_error_desc(self.student, 'staff', descriptor, self.course.course_key)) self.assertTrue(access._has_access_error_desc(self.course_staff, 'staff', descriptor, self.course.course_key)) self.assertTrue(access._has_access_error_desc(self.course_instructor, 'staff', descriptor, self.course.course_key)) self.assertFalse(access._has_access_error_desc(self.student, 'instructor', descriptor, self.course.course_key)) self.assertFalse(access._has_access_error_desc(self.course_staff, 'instructor', descriptor, self.course.course_key)) self.assertTrue(access._has_access_error_desc(self.course_instructor, 'instructor', descriptor, self.course.course_key)) with self.assertRaises(ValueError): access._has_access_error_desc(self.course_instructor, 'not_load_or_staff', descriptor, self.course.course_key)