buildframework/helium/sf/python/pythoncore/lib/pythoncoretests/test_gscm.py
author wbernard
Tue, 27 Apr 2010 08:33:08 +0300
changeset 587 85df38eb4012
child 588 c7c26511138f
permissions -rw-r--r--
helium_9.0-a7879c935424
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_gscm.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
#===============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
""" Test cases for gscm python wrapper.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import unittest
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import nokia.gscm
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
# Uncomment this line to enable logging in this module, or configure logging elsewhere
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
#logging.basicConfig(level=logging.DEBUG)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
_logger = logging.getLogger('test.gscm')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
class TestGSCM(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    """ Test cases for gscm python wrapper. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    def setUp(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
        if os.environ.has_key('CCM_DATABASE'):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
            self.ccmdatabase = os.environ['CCM_DATABASE']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
            self.ccmdatabase = 'fa1f5132'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    def test_get_db_path(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        """ Test the get_db_path function. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        dbpath = nokia.gscm.get_db_path(self.ccmdatabase)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        assert self.ccmdatabase in dbpath, "Wrong value returned!"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    def test_get_db_path2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        """ Test the get_db_path function with unexistant database. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        try:        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
            _logger.info("get_db_path('not_valid_db'): %s" % nokia.gscm.get_db_path('not_valid_db'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
            assert False, "Should raise Exception when giving unexisting db.'"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        except Exception, exc:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
            _logger.info(exc)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
    def test_get_engine_host(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        """ Test the get_engine_host function. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
        engine = nokia.gscm.get_engine_host(self.ccmdatabase)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
        assert engine != None, "Wrong value returned!"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
    def test_get_engine_host2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
        """ Test the get_engine_host function with unexistant database. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        try:        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
            _logger.info("get_engine_host('not_valid_db'): %s" % nokia.gscm.get_engine_host('not_valid_db'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
            assert False, "Should raise Exception when giving unexisting db.'"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
        except Exception, exc:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
            _logger.info(exc)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    def test_get_router_address(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
        """ Test the get_router_address function. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
        _logger.info("get_router_address(self.ccmdatabase): %s" % nokia.gscm.get_router_address(self.ccmdatabase))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
    def test_get_router_address2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
        """ Test the get_router_address function with unexistant database. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        try:        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
            _logger.info("get_router_address('not_valid_db'): %s" % nokia.gscm.get_router_address('not_valid_db'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
            assert False, "Should raise Exception when giving unexisting db.'"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
        except Exception, exc:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
            _logger.info(exc)