示例#1
0
    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))
示例#2
0
    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))
示例#3
0
    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))
示例#4
0
    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))
示例#5
0
    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))
示例#6
0
    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))
示例#7
0
    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))
示例#8
0
    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))
示例#9
0
    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))
示例#10
0
    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))
示例#11
0
    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))
示例#12
0
    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))
示例#13
0
    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))
示例#14
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))
示例#15
0
    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))
示例#16
0
    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))