def test_incrementExerciseEvaluationAttempts_calledWithExerciseEvaluation_attemptNumberCorrectlyUpdated(
         self):
     exercise_evaluation = self.__create_and_insert_exercise_evaluation_test_instance(
     )
     self.sut.increment_exercise_evaluation_attempts(exercise_evaluation)
     actual = ExerciseEvaluation.from_json(
         self.db.evaluations.find_one({'_id': exercise_evaluation.get_id()
                                       })).get_attempt()
     expected = 2
     self.assertEqual(actual, expected)
 def get_exercise_evaluation(self, user_id, exercise_id):
     query_result = self.db.evaluations.find_one(
         {
             'user_id': ObjectId(user_id),
             'exercise_id': ObjectId(exercise_id)
         }, self.ITEM_REQUIRED_FIELDS)
     if query_result is not None:
         exercise = ExerciseEvaluation.from_json(query_result)
         return exercise
     else:
         return None
 def test_updateExerciseEvaluationAsSolved_calledWithValidParams_exerciseEvaluationCorrectlyUpdated(
         self):
     exercise_evaluation = self.__create_and_insert_exercise_evaluation_test_instance(
     )
     self.sut.update_exercise_evaluation_as_solved(exercise_evaluation, 200)
     exercise_evaluation_returned_from_db = ExerciseEvaluation.from_json(
         self.db.evaluations.find_one({'_id':
                                       exercise_evaluation.get_id()}))
     actual_score = exercise_evaluation_returned_from_db.get_score()
     expected_score = 200
     actual_status = exercise_evaluation_returned_from_db.get_status()
     expected_status = ExerciseEvaluation.STATUS_SOLVED
     self.assertEqual(actual_score, expected_score)
     self.assertEqual(actual_status, expected_status)