Esempio n. 1
0
    def test_last_for_user_before_time(self):
        start = timezone.now()
        delta = datetime.timedelta(seconds=1)
        logs = self.create_logs(self.user1, num=10, start=start, delta=delta)

        before_time = start + delta * 3
        log = AccessLog.last_for_user(self.user1, before_time=before_time)
        self.assertEqual(logs[2], log)
Esempio n. 2
0
    def test_last_for_user_before_time(self):
        start = timezone.now()
        delta = datetime.timedelta(seconds=1)
        logs = self.create_logs(self.user1, num=10, start=start, delta=delta)

        before_time = start + delta * 3
        log = AccessLog.last_for_user(self.user1, before_time=before_time)
        self.assertEqual(logs[2], log)
Esempio n. 3
0
    def test_basic_access(self):
        start = timezone.now() - datetime.timedelta(seconds=10)
        logs = self.create_logs(self.user1, start=start)

        log = AccessLog.last_for_user(self.user1)
        self.assertEqual(logs[-1], log)

        results = AccessLog.by_user(self.user1)
        self.assertSequenceEqual(logs, results)
Esempio n. 4
0
    def test_basic_access(self):
        start = timezone.now() - datetime.timedelta(seconds=10)
        logs = self.create_logs(self.user1, start=start)

        log = AccessLog.last_for_user(self.user1)
        self.assertEqual(logs[-1], log)

        results = AccessLog.by_user(self.user1)
        self.assertSequenceEqual(logs, results)
Esempio n. 5
0
    def test_multi_user(self):
        # Intersperse logs from two users
        logs = []
        for _ in xrange(10):
            logs += self.create_logs(self.user1, num=1)
            self.create_logs(self.user2, num=1)

        log = AccessLog.last_for_user(self.user1)
        self.assertEqual(logs[-1], log)

        results = AccessLog.by_user(self.user1)
        self.assertSequenceEqual(logs, results)
Esempio n. 6
0
    def test_no_data(self):
        log = AccessLog.last_for_user(self.user1)
        self.assertEqual(None, log)

        logs = AccessLog.by_user(self.user1)
        self.assertEqual(len(logs), 0)

        logs = AccessLog.by_time_period(self.user1, [])
        self.assertEqual(len(logs), 0)

        log_rates = AccessLog.rates(self.user1, [])
        self.assertTupleEqual(log_rates, (None, None))
Esempio n. 7
0
    def test_multi_user(self):
        # Intersperse logs from two users
        logs = []
        for _ in xrange(10):
            logs += self.create_logs(self.user1, num=1)
            self.create_logs(self.user2, num=1)

        log = AccessLog.last_for_user(self.user1)
        self.assertEqual(logs[-1], log)

        results = AccessLog.by_user(self.user1)
        self.assertSequenceEqual(logs, results)
Esempio n. 8
0
    def test_no_data(self):
        log = AccessLog.last_for_user(self.user1)
        self.assertEqual(None, log)

        logs = AccessLog.by_user(self.user1)
        self.assertEqual(len(logs), 0)

        logs = AccessLog.by_time_period(self.user1, [])
        self.assertEqual(len(logs), 0)

        log_rates = AccessLog.rates(self.user1, [])
        self.assertTupleEqual(log_rates, (None, None))