Esempio n. 1
0
    def test_find_by_language(self):
        random_language = LanguageRule().random
        list_random_user_words = [
            UserWordRule(word=self.faker.word(),
                         language=random_language).user_word
            for _ in range(random.randint(2, 5))
        ]
        list_retrieved = UserWord.find_by_language(random_language)

        assert all([word in list_retrieved for word in list_random_user_words])
def set_default_exercise_based_prob():
    zeeguu.app.test_request_context().push()
    zeeguu.db.session.commit()
    users = User.find_all()
    languages = Language.all()

    for user in users:
        for language in languages:
            user_words_by_language = UserWord.find_by_language(language)
            for word in user_words_by_language:
                if ExerciseBasedProbability.exists(user, word):
                    prob = ExerciseBasedProbability.find(user, word)
                    bookmarks_by_user_and_word = Bookmark.find_all_by_user_and_word(user, word)
                    total_prob = 0
                    for bookmark in bookmarks_by_user_and_word:
                        prob.calculate_known_bookmark_probability(bookmark)
                        total_prob += float(prob.probability)
                    if bookmarks_by_user_and_word:
                        prob.probability = total_prob / len(bookmarks_by_user_and_word)
                    zeeguu.db.session.commit()
    print "job1"
def set_default_exercise_based_prob():
    zeeguu.app.test_request_context().push()
    zeeguu.db.session.commit()
    users = User.find_all()
    languages = Language.all()

    for user in users:
        for language in languages:
            user_words_by_language = UserWord.find_by_language(language)
            for word in user_words_by_language:
                if ExerciseBasedProbability.exists(user, word):
                    prob = ExerciseBasedProbability.find(user, word)
                    bookmarks_by_user_and_word = Bookmark.find_all_by_user_and_word(
                        user, word)
                    total_prob = 0
                    for bookmark in bookmarks_by_user_and_word:
                        prob.calculate_known_bookmark_probability(bookmark)
                        total_prob += float(prob.probability)
                    if bookmarks_by_user_and_word:
                        prob.probability = total_prob / len(
                            bookmarks_by_user_and_word)
                    zeeguu.db.session.commit()
    print 'job1'