Пример #1
0
    def test_rating_useractivity(self):
        from film20.useractivity.models import UserActivity
        from film20.core.models import UserRatingTimeRange
        from film20 import notification
        from film20.tagging.models import Tag, TaggedItem
        
        notification.models.test_queue = []

        film = Film.objects.get(permalink='pulp-fiction')
        film.save_tags('hamburger')

        film2 = Film.objects.get(permalink='the-godfather')

        Rating.objects.filter(user=self.user, film=film).delete()

        film.rate(self.user, 10)
        film2.rate(self.user, 8)
        
        self.assertFalse(UserActivity.objects.filter(user=self.user))

        UserRatingTimeRange.process_rating_timerange(0)

        activities = list(UserActivity.objects.filter(user=self.user))
        self.assertTrue(len(activities), 1)

        self.assertEquals(activities[0].activity_type, UserActivity.TYPE_RATING)
        self.assertEquals(activities[0].content, "1") # one extra film rated

        self.assertTrue(notification.models.test_queue)

        self.assertTrue(TaggedItem.objects.get_by_model(UserActivity, 'hamburger'))

        self.assertTrue('hamburger' in [str(t) for t in Tag.objects.get_for_object(activities[0])])
Пример #2
0
    def test_rating_activity(self):
        """
           Test creating rating activity     
        """

        self.initialize()

        ratings = Rating.objects.filter(user=self.u1)

        userratingtime = UserRatingTimeRange()

        userratingtime.save_activity(ratings, 3, self.u1)

        ua = UserActivity.objects.get(activity_type=UserActivity.TYPE_RATING, user=self.u1)

        self.failUnlessEqual(ua is None, False)
        self.failUnlessEqual(ua.user, self.u1)
        self.failUnlessEqual(ua.content, u'2')
Пример #3
0
 def handle(self, *args, **opts):
     UserRatingTimeRange.process_rating_timerange()
Пример #4
0
 def handle(self, *args, **opts):
     UserRatingTimeRange.process_rating_timerange()