예제 #1
0
    def test_basic(self):
        """Test a basic run of the update leaderboard cron command."""
        # Chains through factories to create two seperate users.
        stats1 = (FacebookClickStatsFactory.create(
            clicks=2, banner_instance__total_clicks=2))
        stats2 = (FacebookClickStatsFactory.create(
            clicks=4, banner_instance__total_clicks=4))
        user1 = stats1.banner_instance.user
        user2 = stats2.banner_instance.user

        update_facebook_leaderboard()

        user1 = FacebookUser.objects.get(id=user1.id)
        user2 = FacebookUser.objects.get(id=user2.id)

        eq_(user1.leaderboard_position, 2)
        eq_(user2.leaderboard_position, 1)
        eq_(user1.total_clicks, 2)
        eq_(user2.total_clicks, 4)
예제 #2
0
 def _mkstats(self, user, year, month, clicks):
     now = datetime.now()
     hour = datetime(year, month, now.day, now.hour)
     return FacebookClickStatsFactory.create(banner_instance__user=user,
                                             hour=hour, clicks=clicks)
예제 #3
0
 def _mkstats(self, user, year, month, clicks):
     hour = datetime(year, month, 1, 0)
     return FacebookClickStatsFactory.create(banner_instance__user=user,
                                             hour=hour,
                                             clicks=clicks)
예제 #4
0
 def _mkstats(self, user, year, month, clicks):
     now = datetime.now()
     hour = datetime(year, month, now.day, now.hour)
     return FacebookClickStatsFactory.create(banner_instance__user=user,
                                             hour=hour,
                                             clicks=clicks)
예제 #5
0
 def _mkstats(self, user, year, month, clicks):
     hour = datetime(year, month, 1, 0)
     return FacebookClickStatsFactory.create(banner_instance__user=user,
                                             hour=hour, clicks=clicks)