587
|
1 |
#============================================================================
|
|
2 |
#Name : test_gscm.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 |
""" Test cases for gscm python wrapper.
|
|
21 |
|
|
22 |
"""
|
|
23 |
|
628
|
24 |
# pylint: disable=R0201
|
588
|
25 |
|
587
|
26 |
import logging
|
|
27 |
import unittest
|
|
28 |
import os
|
|
29 |
import nokia.gscm
|
|
30 |
|
|
31 |
# Uncomment this line to enable logging in this module, or configure logging elsewhere
|
|
32 |
#logging.basicConfig(level=logging.DEBUG)
|
|
33 |
_logger = logging.getLogger('test.gscm')
|
|
34 |
|
|
35 |
|
|
36 |
class TestGSCM(unittest.TestCase):
|
|
37 |
""" Test cases for gscm python wrapper. """
|
|
38 |
|
|
39 |
def setUp(self):
|
588
|
40 |
"""setUp automatically called before running the tests"""
|
587
|
41 |
if os.environ.has_key('CCM_DATABASE'):
|
|
42 |
self.ccmdatabase = os.environ['CCM_DATABASE']
|
|
43 |
else:
|
|
44 |
self.ccmdatabase = 'fa1f5132'
|
|
45 |
|
|
46 |
def test_get_db_path(self):
|
|
47 |
""" Test the get_db_path function. """
|
|
48 |
dbpath = nokia.gscm.get_db_path(self.ccmdatabase)
|
|
49 |
assert self.ccmdatabase in dbpath, "Wrong value returned!"
|
|
50 |
|
|
51 |
def test_get_db_path2(self):
|
|
52 |
""" Test the get_db_path function with unexistant database. """
|
|
53 |
try:
|
|
54 |
_logger.info("get_db_path('not_valid_db'): %s" % nokia.gscm.get_db_path('not_valid_db'))
|
|
55 |
assert False, "Should raise Exception when giving unexisting db.'"
|
|
56 |
except Exception, exc:
|
|
57 |
_logger.info(exc)
|
|
58 |
|
|
59 |
def test_get_engine_host(self):
|
|
60 |
""" Test the get_engine_host function. """
|
|
61 |
engine = nokia.gscm.get_engine_host(self.ccmdatabase)
|
|
62 |
assert engine != None, "Wrong value returned!"
|
|
63 |
|
|
64 |
def test_get_engine_host2(self):
|
|
65 |
""" Test the get_engine_host function with unexistant database. """
|
|
66 |
try:
|
|
67 |
_logger.info("get_engine_host('not_valid_db'): %s" % nokia.gscm.get_engine_host('not_valid_db'))
|
|
68 |
assert False, "Should raise Exception when giving unexisting db.'"
|
|
69 |
except Exception, exc:
|
|
70 |
_logger.info(exc)
|
|
71 |
|
|
72 |
def test_get_router_address(self):
|
|
73 |
""" Test the get_router_address function. """
|
|
74 |
_logger.info("get_router_address(self.ccmdatabase): %s" % nokia.gscm.get_router_address(self.ccmdatabase))
|
|
75 |
|
|
76 |
def test_get_router_address2(self):
|
|
77 |
""" Test the get_router_address function with unexistant database. """
|
|
78 |
try:
|
|
79 |
_logger.info("get_router_address('not_valid_db'): %s" % nokia.gscm.get_router_address('not_valid_db'))
|
|
80 |
assert False, "Should raise Exception when giving unexisting db.'"
|
|
81 |
except Exception, exc:
|
|
82 |
_logger.info(exc)
|