'Test that grades are persisted to the database properly,
and that loading saved grades returns the same data.'

def test_save_and_load(self):

    input_grade = SubsectionGrade(self.sequence)
    input_grade.init_from_structure(self.request.user, self.course_structure, self.subsection_grade_factory._submissions_scores, self.subsection_grade_factory._csm_scores)
    self.assertEqual(PersistentSubsectionGrade.objects.count(), 0)
    input_grade.create_model(self.request.user)
    self.assertEqual(PersistentSubsectionGrade.objects.count(), 1)
    loaded_grade = SubsectionGrade(self.sequence)
    saved_model = PersistentSubsectionGrade.read_grade(user_id=self.request.user.id, usage_key=self.sequence.location)
    loaded_grade.init_from_model(self.request.user, saved_model, self.course_structure, self.subsection_grade_factory._submissions_scores, self.subsection_grade_factory._csm_scores)
    self.assertEqual(input_grade.url_name, loaded_grade.url_name)
    loaded_grade.all_total.first_attempted = None
    self.assertEqual(input_grade.all_total, loaded_grade.all_total)
