587
|
1 |
#============================================================================
|
|
2 |
#Name : test_log2xml.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 |
#===============================================================================
|
588
|
19 |
""" test log to XML """
|
|
20 |
|
628
|
21 |
# pylint: disable=R0201
|
587
|
22 |
|
|
23 |
import unittest
|
|
24 |
import logging
|
|
25 |
import os
|
|
26 |
import log2xml
|
|
27 |
from xml.dom import minidom
|
|
28 |
import tempfile
|
|
29 |
|
588
|
30 |
_logger = logging.getLogger('test.log2xml')
|
587
|
31 |
|
|
32 |
|
|
33 |
class Log2XMLTest(unittest.TestCase):
|
|
34 |
""" Acceptance tests for log2xml.py """
|
|
35 |
def test_log_conversion(self):
|
|
36 |
"""
|
|
37 |
Convert a log into xml.
|
|
38 |
"""
|
|
39 |
logfile = os.path.join(os.environ['TEST_DATA'], 'data', 'log2xml_test.log')
|
|
40 |
testfile = os.path.join(tempfile.gettempdir(), "log2xml_test.xml")
|
|
41 |
log2xml.convert(logfile, testfile)
|
|
42 |
minidom.parse(testfile)
|
|
43 |
|
|
44 |
def test_log_utf16_conversion(self):
|
|
45 |
"""
|
|
46 |
Convert a log into xml.
|
|
47 |
"""
|
|
48 |
logfile = os.path.join(os.environ['TEST_DATA'], 'data', 'log2xml_failure.log')
|
|
49 |
testfile = os.path.join(tempfile.gettempdir(), "log2xml_test2.xml")
|
|
50 |
log2xml.convert(logfile, testfile)
|
|
51 |
minidom.parse(testfile)
|
|
52 |
|
|
53 |
|
|
54 |
if __name__ == '__main__':
|
|
55 |
unittest.main() |