コード例 #1
0
    def test_shouldIndex2(self):
        """ Check if time elapsed since first msg (10:00) v.s. max_interval """

        queued = ['0.tmp'] * 3

        # 2000-1-1 10:30 localtime
        now = datetime.datetime(2000,1,1,10,30,0)
                                                                                    # 30 min elapsed
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logpath, queued)) # 0 - do not index

        now = datetime.datetime(2000,1,1,16,0,0)                                    # 360 min elapsed
        self.assertEqual(2, qmsg_processor._shouldIndex(now, self.logpath, queued)) # 2 - max_interval has reached

        now = datetime.datetime(2000,1,1,9,0,0)                                     # -60 min elapsed
        self.assertEqual(-2, qmsg_processor._shouldIndex(now, self.logpath, queued))# -2 = fail to evaluete time elapsed
コード例 #2
0
    def test_shouldIndex0(self):
        """ no msg queued """

        # 2000-1-1 10:30 localtime
        now = datetime.datetime(2000, 1, 1, 10, 30, 0)

        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logdir, []))
コード例 #3
0
    def test_shouldIndex01(self):
        """ msg queued(3) < numDoc(5) """

        queued = ["0.tmp"] * 3

        # 2000-1-1 10:30 localtime
        now = datetime.datetime(2000, 1, 1, 10, 30, 0)
        # lastIssued is None
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logdir, queued))  # 0 - do not index

        messagelog.mlog.lastIssued = datetime.datetime(2000, 1, 1, 10, 29, 0)  # 1 min elapsed
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logdir, queued))  # 0 - do not index

        messagelog.mlog.lastIssued = datetime.datetime(2000, 1, 1, 10, 27, 0)  # 3 min elapsed
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logdir, queued))  # 0 - do not index

        messagelog.mlog.lastIssued = datetime.datetime(2000, 1, 1, 9, 30, 0)  # -60 min elapsed
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logdir, queued))  # 0 - do not index
コード例 #4
0
    def test_shouldIndex1(self):
        """ msg queued(5) >= numDoc(5) """

        queued = ['0.tmp'] * 5

        # 2000-1-1 10:30 localtime
        now = datetime.datetime(2000,1,1,10,30,0)
                                                                                    # lastIssued is None
        self.assertEqual(1, qmsg_processor._shouldIndex(now, self.logpath, queued)) # 1 - numDoc has met

        messagelog.mlog.lastIssued = datetime.datetime(2000,1,1,10,29,0)            # 1 min elapsed
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logpath, queued)) # 0 - do not index

        messagelog.mlog.lastIssued = datetime.datetime(2000,1,1,10,27,0)            # 3 min elapsed
        self.assertEqual(1, qmsg_processor._shouldIndex(now, self.logpath, queued)) # 1 - numDoc has met

        messagelog.mlog.lastIssued = datetime.datetime(2000,1,1,10,31,0)            # -1 min elapsed (new activity)
        self.assertEqual(0, qmsg_processor._shouldIndex(now, self.logpath, queued)) # 0 - do not index

        messagelog.mlog.lastIssued = datetime.datetime(2000,1,1,11,30,0)            # -60 min elapsed
        self.assertEqual(-1, qmsg_processor._shouldIndex(now, self.logpath, queued))# -1 - fail to evaluate time elapsed