Ejemplo n.º 1
0
    def test_check_if_learned_based_on_exercise_outcomes(self):
        random_bookmarks = [
            BookmarkRule(self.user).bookmark for _ in range(0, 4)
        ]

        # Empty exercise_log should lead to a False return
        assert not random_bookmarks[
            0].check_if_learned_based_on_exercise_outcomes()

        # An exercise with Outcome equal to TOO EASY results in True, and time of last exercise
        random_exercise = ExerciseRule().exercise
        random_exercise.outcome = OutcomeRule().too_easy
        random_bookmarks[1].add_new_exercise(random_exercise)
        result_bool, result_time = random_bookmarks[
            1].check_if_learned_based_on_exercise_outcomes(
                add_to_result_time=True)
        assert result_bool and result_time == random_exercise.time

        # Same test as above, but without a second return value
        assert random_bookmarks[1].check_if_learned_based_on_exercise_outcomes(
        )

        # A bookmark with 5 correct exercises in a row returns true and the time of the last exercise
        for i in range(0, 5):
            correct_exercise = ExerciseRule().exercise
            correct_exercise.outcome = OutcomeRule().correct
            random_bookmarks[2].add_new_exercise(correct_exercise)

        result_bool, result_time = random_bookmarks[
            2].check_if_learned_based_on_exercise_outcomes()
        assert result_bool and result_time == random_bookmarks[2].exercise_log[
            -1].time

        random_bookmarks[2].update_learned_status(self.db.session)

        # A bookmark with no TOO EASY outcome or less than 5 correct exercises in a row returns False, None
        wrong_exercise = ExerciseRule().exercise
        wrong_exercise.outcome = OutcomeRule().wrong
        random_bookmarks[3].add_new_exercise(wrong_exercise)
        result_bool, result_None = random_bookmarks[
            3].check_if_learned_based_on_exercise_outcomes(
                add_to_result_time=True)
        assert not result_bool and result_None is None

        # Same as before, but without a second return value
        assert not random_bookmarks[
            3].check_if_learned_based_on_exercise_outcomes()
Ejemplo n.º 2
0
    def test_fit_for_study(self):
        random_bookmarks = [
            BookmarkRule(self.user).bookmark for _ in range(0, 2)
        ]
        random_exercise = ExerciseRule().exercise
        random_exercise.outcome = OutcomeRule().correct

        random_bookmarks[0].starred = True
        random_bookmarks[1].starred = True
        random_bookmarks[1].add_new_exercise(random_exercise)

        for b in random_bookmarks:
            assert b.fit_for_study
Ejemplo n.º 3
0
    def test_has_been_learned(self):
        random_bookmarks = [
            BookmarkRule(self.user).bookmark for _ in range(0, 2)
        ]

        random_exercise = ExerciseRule().exercise
        random_exercise.outcome = OutcomeRule().too_easy
        random_bookmarks[0].add_new_exercise(random_exercise)
        result_bool, result_time = random_bookmarks[0].has_been_learned(
            also_return_time=True)
        assert result_bool and result_time == random_bookmarks[0].exercise_log[
            -1].time

        result_bool, result_None = random_bookmarks[1].has_been_learned(
            also_return_time=True)
        assert not result_bool and result_None is None