buildframework/helium/tools/common/python/lib/cpythontest/test_logger.py
changeset 179 d8ac696cc51f
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
       
     1 #============================================================================ 
       
     2 #Name        : test_logger.py 
       
     3 #Part of     : Helium 
       
     4 
       
     5 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     6 #All rights reserved.
       
     7 #This component and the accompanying materials are made available
       
     8 #under the terms of the License "Eclipse Public License v1.0"
       
     9 #which accompanies this distribution, and is available
       
    10 #at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 #
       
    12 #Initial Contributors:
       
    13 #Nokia Corporation - initial contribution.
       
    14 #
       
    15 #Contributors:
       
    16 #
       
    17 #Description:
       
    18 #===============================================================================
       
    19 
       
    20 import logging
       
    21 import os
       
    22 import unittest
       
    23 
       
    24 import helium.logger
       
    25 import helium.outputer
       
    26 
       
    27 
       
    28 # Uncomment this line to enable logging in this module, or configure logging elsewhere
       
    29 #logging.basicConfig(level=logging.DEBUG)
       
    30 logger = logging.getLogger('test.helium.logger')
       
    31 
       
    32 
       
    33 class TestHeliumLogger(unittest.TestCase):
       
    34             
       
    35     def test_mc_logger_xml_generation(self):
       
    36         """ Test simple XML logging generation. """
       
    37         mclogger = helium.logger.Logger()
       
    38         mclogger.SetInterface("http://fawww.europe.company.com/isis/isis_interface/")
       
    39         mclogger.SetTitle("Validate Overlay")
       
    40         mclogger.SetSubTitle("Validating: ")
       
    41         mclogger.OpenMainContent("test")
       
    42         mclogger.PrintRaw("<a href=\"google.com\">test</a>")
       
    43         mclogger.Print("test")
       
    44         mclogger.Print(u"\u00A9")
       
    45         mclogger.error("test")
       
    46         mclogger.CloseMainContent()
       
    47         mclogger.OpenMainContent("test2")
       
    48         mclogger.OpenEvent("test2")
       
    49         mclogger.Print("test2")
       
    50         mclogger.error("test2")
       
    51         mclogger.CloseEvent()
       
    52         mclogger.CloseMainContent()
       
    53         mclogger.WriteToFile('log.xml')
       
    54         
       
    55         logger.info(mclogger)
       
    56         
       
    57         os.unlink('log.xml')
       
    58         
       
    59         #out = helium.outputer.XML2XHTML("log.xml")
       
    60         #out.generate()
       
    61         #out.WriteToFile("log.html")
       
    62 
       
    63     def test_helium_logger_unicode_handling(self):
       
    64         """ Test simple XML logging generation with unicode handling. """
       
    65         mclogger = helium.logger.Logger()
       
    66         mclogger.SetInterface("http://fawww.europe.company.com/isis/isis_interface/")
       
    67         mclogger.SetTitle("Validate Overlay")
       
    68         mclogger.SetSubTitle("Validating: ")
       
    69         mclogger.OpenMainContent("test")
       
    70         mclogger.Print(u"Test unicode handling: \u00A9")
       
    71         mclogger.CloseMainContent()
       
    72         mclogger.WriteToFile('log.xml')
       
    73         
       
    74         logger.info(mclogger)
       
    75         
       
    76         os.unlink('log.xml')
       
    77 
       
    78     def test_helium_logger_outputer(self):
       
    79         """ Test simple XML logging generation with unicode handling and XHTML generation. """
       
    80         mclogger = helium.logger.Logger()
       
    81         mclogger.SetInterface("http://fawww.europe.company.com/isis/isis_interface/")
       
    82         mclogger.SetTitle("Validate Overlay")
       
    83         mclogger.SetSubTitle("Validating: ")
       
    84         mclogger.OpenMainContent("test")
       
    85         mclogger.Print(u"Test unicode handling: \u00A9")
       
    86         mclogger.CloseMainContent()
       
    87         mclogger.WriteToFile('log.xml')
       
    88         
       
    89         logger.info(mclogger)
       
    90         
       
    91         out = helium.outputer.XML2XHTML('log.xml')
       
    92         out.generate()
       
    93         out.WriteToFile('log.html')
       
    94         
       
    95         os.unlink('log.xml')
       
    96         os.unlink('log.html')
       
    97 
       
    98 
       
    99 if __name__ == '__main__':
       
   100     unittest.main()