def test_compute_is_prereq_met(self): """ Test if prereq has been met and force recompute """ student = UserFactory(is_staff=False) gating_api.add_prerequisite(self.course.id, self.seq1.location) gating_api.set_required_content(self.course.id, self.seq2.location, self.seq1.location, 100, 0) # complete the prerequisite to unlock the gated content # this call triggers reevaluation of prerequisites fulfilled by the gating block. with patch.object(gating_api, 'get_subsection_grade_percentage') as mock_grade: mock_grade.return_value = 75 # don't force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met( self.seq2.location, student.id, False) self.assertFalse(prereq_met) self.assertIsNone(prereq_meta_info['url']) self.assertIsNone(prereq_meta_info['display_name']) # force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met( self.seq2.location, student.id, True) self.assertFalse(prereq_met) self.assertIsNotNone(prereq_meta_info['url']) self.assertIsNotNone(prereq_meta_info['display_name']) # change to passing grade mock_grade.return_value = 100 # don't force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met( self.seq2.location, student.id, False) self.assertFalse(prereq_met) self.assertIsNone(prereq_meta_info['url']) self.assertIsNone(prereq_meta_info['display_name']) # force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met( self.seq2.location, student.id, True) self.assertTrue(prereq_met) self.assertIsNotNone(prereq_meta_info['url']) self.assertIsNotNone(prereq_meta_info['display_name'])
def test_compute_is_prereq_met(self): """ Test if prereq has been met and force recompute """ student = UserFactory(is_staff=False) gating_api.add_prerequisite(self.course.id, self.seq1.location) gating_api.set_required_content(self.course.id, self.seq2.location, self.seq1.location, 100, 0) # complete the prerequisite to unlock the gated content # this call triggers reevaluation of prerequisites fulfilled by the gating block. with patch.object(gating_api, 'get_subsection_grade_percentage') as mock_grade: mock_grade.return_value = 75 # don't force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met(self.seq2.location, student.id, False) self.assertFalse(prereq_met) self.assertIsNone(prereq_meta_info['url']) self.assertIsNone(prereq_meta_info['display_name']) # force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met(self.seq2.location, student.id, True) self.assertFalse(prereq_met) self.assertIsNotNone(prereq_meta_info['url']) self.assertIsNotNone(prereq_meta_info['display_name']) # change to passing grade mock_grade.return_value = 100 # don't force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met(self.seq2.location, student.id, False) self.assertFalse(prereq_met) self.assertIsNone(prereq_meta_info['url']) self.assertIsNone(prereq_meta_info['display_name']) # force recompute prereq_met, prereq_meta_info = gating_api.compute_is_prereq_met(self.seq2.location, student.id, True) self.assertTrue(prereq_met) self.assertIsNotNone(prereq_meta_info['url']) self.assertIsNotNone(prereq_meta_info['display_name'])