Source

alerta / test / test_mailaction.py

Full commit
# Log4Tailer: A multicolored python tailer for log4J logs
# Copyright (C) 2008 Jordi Carrillo Bosch

# This file is part of Log4Tailer Project.
#
# Log4Tailer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Log4Tailer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Log4Tailer.  If not, see <http://www.gnu.org/licenses/>.

import sys,unittest,mox,email
from exceptions import ImportError

sys.path.append('..')
from log4tailer.Actions.MailAction import MailAction

class TestMailAction(unittest.TestCase):

    def setUp(self):
        pass
    
    def testshouldBeFineImportingformatdate(self):
        mailaction = MailAction()
        self.assertTrue(mailaction.getNow())
    
    def testshoulGetNowDateFromTime(self):
        m = mox.Mox()
        mailaction = MailAction()
        m.StubOutWithMock(email.utils,'formatdate')
        email.utils.__delattr__('formatdate')
        m.ReplayAll()
        now = mailaction.getNow()
        if now:
            m.UnsetStubs()
            m.VerifyAll()
            pass
        else:
            self.fail()
    
    def tearDown(self):
        pass

if __name__=='__main__':
    unittest.main()