Beispiel #1
0
 def test_get_best_tci_users(self):
     """
        Test for query that retrieves top users (based on common taste).
     """
     do_create_comparators()
     recom_helper = RecomHelper()
     result = recom_helper.get_best_tci_users(self.u1)
     self.assertEquals(len(result), 3)
Beispiel #2
0
 def test_get_best_tci_users(self):
     """
        Test for query that retrieves top users (based on common taste).
     """
     do_create_comparators()
     recom_helper = RecomHelper()
     result = recom_helper.get_best_tci_users(self.u1)
     print "result -->", result
     self.assertEquals(len(result), 4)
Beispiel #3
0
#!/usr/bin/env python
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'film20.settings'
from film20.recommendations.bot_helper import do_create_comparators 
from film20.core.rating_helper import *
from film20.core.models import *
 
do_create_comparators()

from film20.tagging.models import *

#Tag.objects.update_all_weights()

#from film20.recommendations.bot_helper import create_comparators_for_user
#user = User.objects.get(username='******')
#all_users = User.objects.all()
#create_comparators_for_user(user, all_users)
Beispiel #4
0
    def test_planet_tag(self):
        # --- Initialize ---
        self.initialize()
        helper_without_tags = PlanetTagHelper()
        helper_with_tags = PlanetTagHelper(tag='comedy')
        recom_helper = RecomHelper()
        user_activity_helper = UserActivityHelper()

        # --- setup followers ---
        self.u1.followers.follow(self.u2)
        self.u1.followers.follow(self.u3)
        self.u1.followers.follow(self.u4)

        # similar users
        from film20.recommendations.bot_helper import do_create_comparators
        self.films_for_comparator()
        do_create_comparators()

        friends_list = recom_helper.get_following_ids_as_list(self.u1)
        friends_without_activities = helper_without_tags.planet_tag_friends(friends_list)
        self.assertEquals(len(friends_without_activities), 0)
        
        similar_users_list = user_activity_helper.get_similar_users_list(request)
        similar_users_without_tags = helper_without_tags.planet_tag_similar_users(similar_users_list)
        self.assertEquals(len(similar_users_without_tags), 0)

        notes_without_tags = helper_without_tags.planet_tag_notes()
        self.assertEquals(len(notes_without_tags), 0)

        all_planet_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_planet_activities), 0)

        # --- setup User activities ---
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()
        
        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 1)
        
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film1)
        post.save()
        
        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 2)
                
        obj = Object.objects.get(id=self.film2.id)
        shortreview = ShortReview()
        shortreview.user = self.u1
        shortreview.review_text = "sialala bumcyk cyk"
        shortreview.status = Object.PUBLIC_STATUS
        shortreview.type = Object.TYPE_SHORT_REVIEW
        shortreview.object = obj
        shortreview.kind = ShortReview.REVIEW
        shortreview.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 3)
        
        # Activities with 'comedy' tag
        all_activities_with_tags = helper_with_tags.planet_tag_all()
        self.assertEquals(len(all_activities_with_tags), 1)

        # --- setup followers activities ---
        post = Post()
        post.title = "#1 Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u2
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 4)

        post = Post()
        post.title = "#2 Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u3
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film1)
        post.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 5)

        obj = Object.objects.get(id=self.film2.id)
        shortreview = ShortReview()
        shortreview.user = self.u4
        shortreview.review_text = "sialala bumcyk cyk"
        shortreview.status = Object.PUBLIC_STATUS
        shortreview.type = Object.TYPE_SHORT_REVIEW
        shortreview.object = obj
        shortreview.kind = ShortReview.REVIEW
        shortreview.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 6)

        activities_with_tags = helper_with_tags.planet_tag_all()
        self.assertEquals(len(activities_with_tags), 2)

        all_friends_activities = helper_without_tags.planet_tag_friends(friends_list)
        self.assertEquals(len(all_friends_activities), 3)
        friends_activities_with_tag = helper_with_tags.planet_tag_friends(friends_list)
        self.assertEquals(len(friends_activities_with_tag), 1)

        # --- Check notes ---
        all_planet_notes = helper_without_tags.planet_tag_notes()
        self.assertEquals(len(all_planet_notes), 4)

        # Post notes with 'comedy' tag
        notes_activities_with_tag = helper_with_tags.planet_tag_notes()
        self.assertEquals(len(notes_activities_with_tag), 2)

        similar_users_activities = helper_without_tags.planet_tag_similar_users(similar_users_list)
        self.assertEquals(len(similar_users_activities), 2)

        users_with_tags = helper_with_tags.planet_tag_similar_users(similar_users_list)
        self.assertEquals(len(users_with_tags), 1)
        
        activities = UserActivity.objects.all() 
Beispiel #5
0
#!/usr/bin/env python
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'film20.settings'
from film20.recommendations.bot_helper import do_create_comparators
from film20.core.rating_helper import *
from film20.core.models import *

do_create_comparators()

from film20.tagging.models import *

#Tag.objects.update_all_weights()

#from film20.recommendations.bot_helper import create_comparators_for_user
#user = User.objects.get(username='******')
#all_users = User.objects.all()
#create_comparators_for_user(user, all_users)
Beispiel #6
0
    def test_planet_tag(self):
        # --- Initialize ---
        self.initialize()
        helper_without_tags = PlanetTagHelper()
        helper_with_tags = PlanetTagHelper(tag='comedy')
        recom_helper = RecomHelper()
        user_activity_helper = UserActivityHelper()

        # --- setup followers ---
        self.u1.followers.follow(self.u2)
        self.u1.followers.follow(self.u3)
        self.u1.followers.follow(self.u4)

        # similar users
        from film20.recommendations.bot_helper import do_create_comparators
        self.films_for_comparator()
        do_create_comparators()

        friends_list = recom_helper.get_following_ids_as_list(self.u1)
        friends_without_activities = helper_without_tags.planet_tag_friends(
            friends_list)
        self.assertEquals(len(friends_without_activities), 0)

        similar_users_list = user_activity_helper.get_similar_users_list(
            request)
        similar_users_without_tags = helper_without_tags.planet_tag_similar_users(
            similar_users_list)
        self.assertEquals(len(similar_users_without_tags), 0)

        notes_without_tags = helper_without_tags.planet_tag_notes()
        self.assertEquals(len(notes_without_tags), 0)

        all_planet_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_planet_activities), 0)

        # --- setup User activities ---
        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 1)

        post = Post()
        post.title = "Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u1
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film1)
        post.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 2)

        obj = Object.objects.get(id=self.film2.id)
        shortreview = ShortReview()
        shortreview.user = self.u1
        shortreview.review_text = "sialala bumcyk cyk"
        shortreview.status = Object.PUBLIC_STATUS
        shortreview.type = Object.TYPE_SHORT_REVIEW
        shortreview.object = obj
        shortreview.kind = ShortReview.REVIEW
        shortreview.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 3)

        # Activities with 'comedy' tag
        all_activities_with_tags = helper_with_tags.planet_tag_all()
        self.assertEquals(len(all_activities_with_tags), 1)

        # --- setup followers activities ---
        post = Post()
        post.title = "#1 Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u2
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film)
        post.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 4)

        post = Post()
        post.title = "#2 Lorem ipsum"
        post.permalink = "lorem-ipsum"
        post.body = "siala lala tralala"
        post.user = self.u3
        post.status = Object.PUBLIC_STATUS
        post.type = Object.TYPE_POST
        post.save()
        post.related_film.add(self.film1)
        post.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 5)

        obj = Object.objects.get(id=self.film2.id)
        shortreview = ShortReview()
        shortreview.user = self.u4
        shortreview.review_text = "sialala bumcyk cyk"
        shortreview.status = Object.PUBLIC_STATUS
        shortreview.type = Object.TYPE_SHORT_REVIEW
        shortreview.object = obj
        shortreview.kind = ShortReview.REVIEW
        shortreview.save()

        all_activities = helper_without_tags.planet_tag_all()
        self.assertEquals(len(all_activities), 6)

        activities_with_tags = helper_with_tags.planet_tag_all()
        self.assertEquals(len(activities_with_tags), 2)

        all_friends_activities = helper_without_tags.planet_tag_friends(
            friends_list)
        self.assertEquals(len(all_friends_activities), 3)
        friends_activities_with_tag = helper_with_tags.planet_tag_friends(
            friends_list)
        self.assertEquals(len(friends_activities_with_tag), 1)

        # --- Check notes ---
        all_planet_notes = helper_without_tags.planet_tag_notes()
        self.assertEquals(len(all_planet_notes), 4)

        # Post notes with 'comedy' tag
        notes_activities_with_tag = helper_with_tags.planet_tag_notes()
        self.assertEquals(len(notes_activities_with_tag), 2)

        similar_users_activities = helper_without_tags.planet_tag_similar_users(
            similar_users_list)
        self.assertEquals(len(similar_users_activities), 2)

        users_with_tags = helper_with_tags.planet_tag_similar_users(
            similar_users_list)
        self.assertEquals(len(users_with_tags), 1)

        activities = UserActivity.objects.all()
Beispiel #7
0
#!/usr/bin/env python
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'film20.settings'
from film20.recommendations.bot_helper import do_create_comparators 
from film20.core.rating_helper import *
from film20.core.models import *
 
do_create_comparators(True)