'Tests to ensure that a persistent subsection grade is
created, saved, then fetched on re-request.'

def test_create_internals(self):

    with patch('lms.djangoapps.grades.new.subsection_grade.PersistentSubsectionGrade.create_grade', wraps=PersistentSubsectionGrade.create_grade) as mock_create_grade:
        with patch('lms.djangoapps.grades.new.subsection_grade_factory.SubsectionGradeFactory._get_bulk_cached_grade', wraps=self.subsection_grade_factory._get_bulk_cached_grade) as mock_get_bulk_cached_grade:
            with self.assertNumQueries(14):
                grade_a = self.subsection_grade_factory.create(self.sequence)
            self.assertTrue(mock_get_bulk_cached_grade.called)
            self.assertTrue(mock_create_grade.called)
            mock_get_bulk_cached_grade.reset_mock()
            mock_create_grade.reset_mock()
            with self.assertNumQueries(0):
                grade_b = self.subsection_grade_factory.create(self.sequence)
            self.assertTrue(mock_get_bulk_cached_grade.called)
            self.assertFalse(mock_create_grade.called)
    self.assertEqual(grade_a.url_name, grade_b.url_name)
    grade_b.all_total.first_attempted = None
    self.assertEqual(grade_a.all_total, grade_b.all_total)
