예제 #1
0
    def test_status_can_be_cleared(self):
        bot = Bot('user@server', 'pass')
        bot.logs['first'] = Log('/tmp/jabber_test/first.log')
        bot.logs['secnd'] = Log('/tmp/jabber_test/secnd.log')
        bot.status = lambda: ('', 'Ok')
        bot.client = fudge.Fake('client').is_a_stub()
        
        filename1 = '/tmp/jabber_test/first.log'
        log1 = Log('first')

        self.set_date('2011-09-21 01:00:03')

        open(filename1, 'w').write('2011-09-21 01:00:01,854 - first - INFO - Line 01\n')

        # Status should be 'Ok'
        bot.cycle()
        self.assertEquals(bot.status_msg, '2011-09-21 01:00:03 Ok')
        self.assertEquals(bot.status_show, '')

        # Error will change status
        self.set_date('2011-09-21 01:00:05')
        open(filename1, 'a').write('2011-09-21 01:00:04,854 - first - ERROR - Error 01\n')
        bot.cycle()
        self.assertEquals(bot.status_msg, '2011-09-21 01:00:04 first: Error 01')
        self.assertEquals(bot.status_show, 'dnd')

        bot.clear()
        bot.cycle()
        self.assertEquals(bot.status_msg, '2011-09-21 01:00:03 Ok')
        self.assertEquals(bot.status_show, '')
예제 #2
0
    def test_status_can_be_cleared(self):
        bot = Bot('user@server', 'pass')
        bot.logs['first'] = Log('/tmp/jabber_test/first.log')
        bot.logs['secnd'] = Log('/tmp/jabber_test/secnd.log')
        bot.status = lambda: ('', 'Ok')
        bot.client = fudge.Fake('client').is_a_stub()

        filename1 = '/tmp/jabber_test/first.log'
        log1 = Log('first')

        self.set_date('2011-09-21 01:00:03')

        open(filename1,
             'w').write('2011-09-21 01:00:01,854 - first - INFO - Line 01\n')

        # Status should be 'Ok'
        bot.cycle()
        self.assertEquals(bot.status_msg, '2011-09-21 01:00:03 Ok')
        self.assertEquals(bot.status_show, '')

        # Error will change status
        self.set_date('2011-09-21 01:00:05')
        open(filename1,
             'a').write('2011-09-21 01:00:04,854 - first - ERROR - Error 01\n')
        bot.cycle()
        self.assertEquals(bot.status_msg,
                          '2011-09-21 01:00:04 first: Error 01')
        self.assertEquals(bot.status_show, 'dnd')

        bot.clear()
        bot.cycle()
        self.assertEquals(bot.status_msg, '2011-09-21 01:00:03 Ok')
        self.assertEquals(bot.status_show, '')