587
|
1 |
#============================================================================
|
|
2 |
#Name : test_ccm.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 ccm python toolkit.
|
|
21 |
|
|
22 |
"""
|
|
23 |
|
628
|
24 |
# pylint: disable=E1101
|
587
|
25 |
|
|
26 |
import logging
|
|
27 |
import os
|
|
28 |
import sys
|
|
29 |
import mocker
|
|
30 |
import ccm
|
|
31 |
|
|
32 |
|
|
33 |
_logger = logging.getLogger('test.ccm')
|
|
34 |
|
|
35 |
|
|
36 |
class CcmTest(mocker.MockerTestCase):
|
|
37 |
""" Tests the ccm module using mocker to prevent accessing a real Synergy database. """
|
|
38 |
|
|
39 |
def test_running_sessions(self):
|
|
40 |
""" Running sessions can be checked. """
|
628
|
41 |
obj = self.mocker.replace(ccm.execute)
|
587
|
42 |
if sys.platform == "win32":
|
|
43 |
obj('c:\\apps\\ccm65\\bin\\ccm.exe status')
|
|
44 |
else:
|
|
45 |
site_id = 'fa_nmp'
|
|
46 |
if 'SITE_ID' in os.environ:
|
|
47 |
site_id = os.environ['SITE_ID']
|
|
48 |
obj('/nokia/' + site_id + '/apps/cmsynergy/6.5/bin/ccm status')
|
|
49 |
self.mocker.result(("""Sessions for user pmackay:
|
|
50 |
|
|
51 |
Command Interface @ 1CAL01176:1553:10.241.72.23
|
|
52 |
Database: /nokia/vc_nmp/groups/gscm/dbs/vc1s60p1
|
|
53 |
|
|
54 |
Current project could not be identified.
|
|
55 |
""", 0))
|
|
56 |
|
|
57 |
self.mocker.replay()
|
|
58 |
|
|
59 |
sessions = ccm.running_sessions()
|
|
60 |
print sessions
|
|
61 |
|
|
62 |
# def test_open_session(self):
|
|
63 |
# """ ccm session can be opened. """
|
|
64 |
# gscm_obj = self.mocker.replace(nokia.gscm._execute)
|
|
65 |
# gscm_obj('perl f:\\helium\\svn\\trunk\\helium\\tools/common/bin/get_gscm_info.pl get_router_address /nokia/vc_nmp/groups/gscm/dbs/vc1s60p1')
|
|
66 |
# self.mocker.result(("vccmsr65:55414:172.18.95.98:172.18.95.61:172.18.95.95:172.18.95.96:172.18.95.97", 0))
|
|
67 |
#
|
|
68 |
# obj = self.mocker.replace(ccm._execute)
|
|
69 |
# obj('c:\\apps\\ccm65\\bin\\ccm.exe start -m -q -nogui -n username -pw foobar -h vccmsweh.americas.company.com -d /nokia/vc_nmp/groups/gscm/dbs/vc1s60p1')
|
|
70 |
# self.mocker.result(("1CAL01176:1333:10.186.216.77:10.241.72.68", 0))
|
|
71 |
#
|
|
72 |
# self.mocker.replay()
|
|
73 |
# session = nokia.nokiaccm.open_session(password='foobar', engine='vccmsweh.americas.company.com', dbpath='/nokia/vc_nmp/groups/gscm/dbs/vc1s60p1', database='/nokia/vc_nmp/groups/gscm/dbs/vc1s60p1')
|
|
74 |
|
|
75 |
|
|
76 |
#def test_timeout_launcher(self):
|
|
77 |
#sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools/common/python/scripts'))
|
|
78 |
#import timeout_launcher
|
|
79 |
#backup = sys.argv
|
|
80 |
#sys.argv = ['--', 'echo 1']
|
|
81 |
#timeout_launcher.main()
|
|
82 |
#sys.argv = backup
|
|
83 |
|