def test_build_parameter_search_url(self):
        """ Using grouped preferences of user, is Ravelry API url built? """

        user = User.query.filter(User.username == 'u1').first()
        grouped_prefs = group_user_prefs(user)
        search_url = build_parameter_search_url(grouped_prefs)
        self.assertIn("api.ravelry", search_url)
Beispiel #2
0
    def test_build_parameter_search_url(self):
        """ Using grouped preferences of user, is Ravelry API url built? """

        user = User.query.filter(User.username == 'u1').first()
        grouped_prefs = group_user_prefs(user)
        search_url = build_parameter_search_url(grouped_prefs)
        self.assertIn("api.ravelry", search_url)
    def test_build_short_pattern_list_from_parameters(self):
        """ from GroupedPreferences, can a list of 5 patterns be returned? """

        user = User.query.filter(User.username == 'u1').first()
        grouped_prefs = group_user_prefs(user)
        pattern_list = build_short_pattern_list_from_parameters(grouped_prefs)
        self.assertIsInstance(pattern_list, list)
        first_pattern = pattern_list[0]
        self.assertIsInstance(first_pattern, SearchResultPattern)
Beispiel #4
0
    def test_build_short_pattern_list_from_parameters(self):
        """ from GroupedPreferences, can a list of 5 patterns be returned? """

        user = User.query.filter(User.username == 'u1').first()
        grouped_prefs = group_user_prefs(user)
        pattern_list = build_short_pattern_list_from_parameters(grouped_prefs)
        self.assertIsInstance(pattern_list, list)
        first_pattern = pattern_list[0]
        self.assertIsInstance(first_pattern, SearchResultPattern)
Beispiel #5
0
def show_search_page():
    """Search page for users: personalized recs, and for basket yarns."""

    user = verify_login(session)
    if not user:
        return redirect("/")

    search_params = group_user_prefs(user)

    search_result_patterns = build_short_pattern_list_from_parameters(search_params)

    return render_template("search.html",
                           all_prefs=ALL_PREFERENCES,
                           pattern_recs=search_result_patterns)
Beispiel #6
0
def show_preference_search_results():
    """ Shows patterns based on user preferences
    :return: html page with patterns
    """

    user = verify_login(session)
    if not user:
        return redirect("/")

    search_params = group_user_prefs(user)

    search_result_patterns = build_pattern_list_from_parameters(search_params)
    headline = "Personalized recommendations for " + user.username

    return render_template("pattern_search_results.html",
                           patterns=search_result_patterns,
                           headline=headline)
Beispiel #7
0
def show_user_profile():
    """Show the user their info"""

    user = verify_login(session)
    if not user:
        return redirect("/")

    basket = Basket.query.filter(Basket.user_id == user.user_id).one()
    basket_yarns = BasketYarn.query.filter(BasketYarn.basket_id == basket.basket_id).all()

    # get GroupedPreferences object for user
    user_grouped_prefs = group_user_prefs(user)

    return render_template("profile.html",
                           user=user,
                           basket_yarns=basket_yarns,
                           user_prefs=user_grouped_prefs,
                           all_prefs=ALL_PREFERENCES)
    def test_group_user_prefs(self):
        """ From a User object can a GroupedPreferences object be returned? """

        user = User.query.filter(User.username == 'u1').first()
        grouped_prefs = group_user_prefs(user)
        self.assertIsInstance(grouped_prefs,GroupedPreferences)
Beispiel #9
0
    def test_group_user_prefs(self):
        """ From a User object can a GroupedPreferences object be returned? """

        user = User.query.filter(User.username == 'u1').first()
        grouped_prefs = group_user_prefs(user)
        self.assertIsInstance(grouped_prefs, GroupedPreferences)