Example #1
0
class TestLogSetUp(unittest.TestCase):
    def reader(self):
        with open('test_log', 'r') as f:
            log = f.read()
        return log

    def setUp(self):
        log = self.reader()
        self.pars = ParserLog(log)

    def test_count_success_send_1(self):
        self.assertNotEqual(self.pars.count_success_send(), 99)

    def test_count_success_send_2(self):
        self.assertEqual(self.pars.count_success_send(), 2)

    def test_count_success_send_3(self):
        log = ''
        pars = ParserLog(log)
        self.assertEqual(pars.count_success_send(), 0)

    def test_count_falled_send_1(self):
        self.assertEqual(self.pars.count_falled_send(), 1)

    def test_count_falled_send_2(self):
        self.assertNotEqual(self.pars.count_falled_send(), 15)

    def test_count_falled_send_3(self):
        log = ''
        pars = ParserLog(log)
        self.assertEqual(pars.count_falled_send(), 0)
Example #2
0
    def test_send_from_4(self):
        log = '''ul 10 10:09:53 srv24-s-st postfix/qmgr[3043]: 5FEB2DF0506: from=<*****@*****.**>, size=788, nrcpt=1 (queue active)
		Jul 10 10:09:53 srv24-s-st postfix/qmgr[3043]: 5FEB2DF0506: from=<*****@*****.**>, size=788, nrcpt=1 (queue active)
		Jul 10 10:09:52 srv24-s-st postfix/qmgr[3044]: 5FEB2DF0507: from=<*****@*****.**>, size=788, nrcpt=1 (queue active)
		Jul 10 10:09:22 srv24-s-st postfix/smtp[22635]: D69F5DF04F4: to=<*****@*****.**>,'''
        pars = ParserLog(log)
        self.assertEqual(pars.send_from(), {
            '<*****@*****.**>': 1,
            '<*****@*****.**>': 2,
        })
Example #3
0
 def test_count_falled_send_3(self):
     log = ''
     pars = ParserLog(log)
     self.assertEqual(pars.count_falled_send(), 0)
Example #4
0
 def test_send_from_1(self):
     log = '''Jul 10 10:09:53 srv24-s-st postfix/qmgr[3043]: 5FEB2DF0506: from=<*****@*****.**>, size=788, nrcpt=1 (queue active)'''
     pars = ParserLog(log)
     self.assertEqual(pars.send_from(), {'<*****@*****.**>': 1})
Example #5
0
 def setUp(self):
     log = self.reader()
     self.pars = ParserLog(log)
Example #6
0
 def test_send_from_3(self):
     log = '''postfix/qmgr[3043]: 5FEB2DF0506: from=<*****@*****.**>, '''
     pars = ParserLog(log)
     self.assertEqual(pars.send_from(), {})
Example #7
0
 def test_send_from_2(self):
     log = ''
     pars = ParserLog(log)
     self.assertEqual(pars.send_from(), {})