Esempio n. 1
0
    def test_login_10_wrong(self):
        player = self._get_player()
        for i in range(14):
            timestamp = datetime.now() + timedelta(days=-i)
            if i == 5:
                continue
            Activity.objects.create(timestamp=timestamp, user_from=player, action='seen', public=False)

        self.assertEqual(consecutive_days_seen(player, datetime.now()), 5)
Esempio n. 2
0
 def test_login_with_multiple_seens(self):
     """
     Multiple seens every day for more than 14 days in a row.
     """
     player = self._get_player()
     for i in range(100):
         timestamp = datetime.now() - timedelta(hours=i*16)
         Activity.objects.create(timestamp=timestamp, user_from=player, action='seen', public=False)
     self.assertGreaterEqual(consecutive_days_seen(player, datetime.now()), 14)
Esempio n. 3
0
    def test_login_10_less(self):
        """
        Multiple seens every day for less than 14 days in a row.
        """

        player = self._get_player()
        for i in range(20):
            timestamp = datetime.now() - timedelta(hours=i*7)
            Activity.objects.create(timestamp=timestamp, user_from=player, action='seen', public=False)
        self.assertLess(consecutive_days_seen(player, datetime.now()), 14)
Esempio n. 4
0
    def test_login_10(self):
        """
        One seen every day for 14 days in a row.
        """
        player = self._get_player()
        for i in range(14):
            timestamp = datetime.now() + timedelta(days=-i)
            Activity.objects.create(timestamp=timestamp, user_from=player, action='seen', public=False)

        self.assertEqual(consecutive_days_seen(player, datetime.now()), 14)
Esempio n. 5
0
    def test_login_10_wrong(self):
        player = self._get_player()
        for i in range(14):
            timestamp = datetime.now() + timedelta(days=-i)
            if i == 5:
                continue
            Activity.objects.create(timestamp=timestamp,
                                    user_from=player,
                                    action='seen',
                                    public=False)

        self.assertEqual(consecutive_days_seen(player, datetime.now()), 5)
Esempio n. 6
0
    def test_login_10_less(self):
        """
        Multiple seens every day for less than 14 days in a row.
        """

        player = self._get_player()
        for i in range(20):
            timestamp = datetime.now() - timedelta(hours=i * 7)
            Activity.objects.create(timestamp=timestamp,
                                    user_from=player,
                                    action='seen',
                                    public=False)
        self.assertLess(consecutive_days_seen(player, datetime.now()), 14)
Esempio n. 7
0
    def test_login_10(self):
        """
        One seen every day for 14 days in a row.
        """
        player = self._get_player()
        for i in range(14):
            timestamp = datetime.now() + timedelta(days=-i)
            Activity.objects.create(timestamp=timestamp,
                                    user_from=player,
                                    action='seen',
                                    public=False)

        self.assertEqual(consecutive_days_seen(player, datetime.now()), 14)
Esempio n. 8
0
 def test_login_with_multiple_seens(self):
     """
     Multiple seens every day for more than 14 days in a row.
     """
     player = self._get_player()
     for i in range(100):
         timestamp = datetime.now() - timedelta(hours=i * 16)
         Activity.objects.create(timestamp=timestamp,
                                 user_from=player,
                                 action='seen',
                                 public=False)
     self.assertGreaterEqual(consecutive_days_seen(player, datetime.now()),
                             14)