當前位置: 首頁>>代碼示例>>Python>>正文


Python models.AccessLog類代碼示例

本文整理匯總了Python中auvsi_suas.models.AccessLog的典型用法代碼示例。如果您正苦於以下問題:Python AccessLog類的具體用法?Python AccessLog怎麽用?Python AccessLog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AccessLog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_basic_access

    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)
開發者ID:APTRG,項目名稱:interop,代碼行數:9,代碼來源:access_log_test.py

示例2: test_no_data

    def test_no_data(self):
        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))
開發者ID:CnuUasLab,項目名稱:interop,代碼行數:9,代碼來源:access_log_test.py

示例3: test_multi_user

    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)
開發者ID:APTRG,項目名稱:interop,代碼行數:12,代碼來源:access_log_test.py

示例4: test_open_end

    def test_open_end(self):
        """Logs (2003, inf)"""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(self.year2003, None),
        ])

        self.assertSequenceEqual([self.year2003_logs], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:7,代碼來源:access_log_test.py

示例5: test_open_start

    def test_open_start(self):
        """Logs (-inf, 2001)"""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(None, self.year2001),
        ])

        self.assertSequenceEqual([self.year2000_logs], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:7,代碼來源:access_log_test.py

示例6: test_non_intersecting_period

    def test_non_intersecting_period(self):
        """No logs matched."""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(self.year2001, self.year2002),
        ])

        self.assertSequenceEqual([[]], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:7,代碼來源:access_log_test.py

示例7: test_full_range

    def test_full_range(self):
        """All logs from (-inf, inf)."""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(None, None)
        ])

        self.assertSequenceEqual([self.logs], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:7,代碼來源:access_log_test.py

示例8: test_single_period

    def test_single_period(self):
        """Single set of logs accessible."""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(self.year2000, self.year2001)
        ])

        self.assertSequenceEqual([self.year2000_logs], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:7,代碼來源:access_log_test.py

示例9: test_last_for_user_before_time

    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)
開發者ID:APTRG,項目名稱:interop,代碼行數:8,代碼來源:access_log_test.py

示例10: test_one_intersecting_period

    def test_one_intersecting_period(self):
        """Only one period matches logs."""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(self.year2001, self.year2002),
            TimePeriod(self.year2003, self.year2004),
        ])

        self.assertSequenceEqual(
            [[], self.year2003_logs], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:9,代碼來源:access_log_test.py

示例11: test_both_periods

    def test_both_periods(self):
        """Both sets of logs, accesses individually."""
        results = AccessLog.by_time_period(self.user1, [
            TimePeriod(self.year2000, self.year2001),
            TimePeriod(self.year2003, self.year2004),
        ])

        self.assertSequenceEqual(
            [self.year2000_logs, self.year2003_logs], self.to_lists(results))
開發者ID:APTRG,項目名稱:interop,代碼行數:9,代碼來源:access_log_test.py

示例12: test_ignore_start_end

    def test_ignore_start_end(self):
        """When start and end are None, only times between logs are compared."""
        delta = datetime.timedelta(seconds=1)

        logs = self.create_logs(self.user1, delta=delta)
        period = TimePeriod(None, None)

        rates = AccessLog.rates(self.user1, [period])

        self.assertSequenceEqual((1, 1), rates)
開發者ID:APTRG,項目名稱:interop,代碼行數:10,代碼來源:access_log_test.py

示例13: test_constant_rate

    def test_constant_rate(self):
        """Rates computed correctly."""
        delta = datetime.timedelta(seconds=1)

        logs = self.create_logs(self.user1, delta=delta)
        period = self.consistent_period(logs, delta)

        rates = AccessLog.rates(self.user1, [period])

        self.assertSequenceEqual((1, 1), rates)
開發者ID:APTRG,項目名稱:interop,代碼行數:10,代碼來源:access_log_test.py

示例14: test_user_active

    def test_user_active(self):
        delta = datetime.timedelta(seconds=1)

        self.create_logs(self.user1, start=self.year2000, num=10, delta=delta)

        latest_time = self.year2000 + 10 * delta

        # Active for user with recent logs
        self.assertTrue(AccessLog.user_active(self.user1, base=latest_time))

        # Not active for user with no logs
        self.assertFalse(AccessLog.user_active(self.user2, base=latest_time))

        # Not active for user with no recent logs
        self.assertFalse(AccessLog.user_active(self.user1, base=self.year2001))

        # Active now
        self.create_logs(self.user1, num=10, delta=delta)
        self.assertTrue(AccessLog.user_active(self.user1))
開發者ID:APTRG,項目名稱:interop,代碼行數:19,代碼來源:access_log_test.py

示例15: test_provided_logs

    def test_provided_logs(self):
        """Rates computed with provided logs."""
        delta = datetime.timedelta(seconds=1)

        used_logs = self.create_logs(self.user1, delta=delta)
        unused_logs = self.create_logs(self.user1, delta=delta)
        period = self.consistent_period(used_logs, delta)

        rates = AccessLog.rates(self.user1, [period],
                                time_period_logs=[used_logs])

        self.assertSequenceEqual((1, 1), rates)
開發者ID:CnuUasLab,項目名稱:interop,代碼行數:12,代碼來源:access_log_test.py


注:本文中的auvsi_suas.models.AccessLog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。