buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_documentation.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
#Name        : test_documentation.py
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#===============================================================================
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    19
""" test documentation """
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import tempfile
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import unittest
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import sys
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
from helium.documentation import APIDeltaWriter
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
_logger = logging.getLogger('test.documentation')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
logging.basicConfig(level=logging.INFO)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
class DocumentationTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
    """ Unit tests for documentation module """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
    def test_APIDeltaWriter(self):
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    34
        """test API Delta writer"""
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
        (fileDes, tempFileName) = tempfile.mkstemp()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
        old_db = os.path.join(os.environ['TEST_DATA'], 'data', 'docs', 'sample_old_db.xml') 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
        new_db = os.path.join(os.environ['TEST_DATA'], 'data', 'docs', 'sample_new_db.xml') 
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    38
        writer = APIDeltaWriter(open(old_db), open(new_db))
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        saveout = sys.stdout
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        sys.stdout = sys.stderr
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        writer.write(tempFileName)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        os.close(fileDes)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
        sys.stdout = saveout
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        tempFile = open(tempFileName, 'r')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        content = tempFile.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        tempFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        os.unlink(tempFileName)
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    48
        assert len(content) == 13