buildframework/helium/tools/common/python/lib/cpythontest/test_ccm.py
changeset 179 d8ac696cc51f
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
       
     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 
       
    24 # pylint: disable-msg=E1101
       
    25 
       
    26 import logging
       
    27 import os
       
    28 import subprocess
       
    29 import sys
       
    30 import unittest
       
    31 
       
    32 import mocker
       
    33 
       
    34 import ccm
       
    35 import nokia.nokiaccm
       
    36 
       
    37 
       
    38 _logger = logging.getLogger('test.ccm')
       
    39 
       
    40 
       
    41 class CcmTest(mocker.MockerTestCase):
       
    42     """ Tests the ccm module using mocker to prevent accessing a real Synergy database. """
       
    43 
       
    44     def test_running_sessions(self):
       
    45         """ Running sessions can be checked. """
       
    46         obj = self.mocker.replace(ccm._execute)
       
    47         if sys.platform == "win32":
       
    48             obj('c:\\apps\\ccm65\\bin\\ccm.exe status')
       
    49         else:
       
    50             obj('/nokia/fa_nmp/apps/cmsynergy/6.5/bin/ccm status')
       
    51         self.mocker.result(("""Sessions for user pmackay:
       
    52 
       
    53 Command Interface @ 1CAL01176:1553:10.241.72.23
       
    54 Database: /nokia/vc_nmp/groups/gscm/dbs/vc1s60p1
       
    55 
       
    56 Current project could not be identified.
       
    57 """, 0))
       
    58 
       
    59         self.mocker.replay()
       
    60 
       
    61         sessions = ccm.running_sessions()
       
    62         print sessions
       
    63 
       
    64 #    def test_open_session(self):
       
    65 #        """ ccm session can be opened. """
       
    66 #        gscm_obj = self.mocker.replace(nokia.gscm._execute)
       
    67 #        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')
       
    68 #        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))
       
    69 #        
       
    70 #        obj = self.mocker.replace(ccm._execute)
       
    71 #        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')
       
    72 #        self.mocker.result(("1CAL01176:1333:10.186.216.77:10.241.72.68", 0))
       
    73 #        
       
    74 #        self.mocker.replay()
       
    75 #        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')
       
    76         
       
    77         
       
    78     def test_timeout_launcher(self):
       
    79         sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools/common/python/scripts'))
       
    80         import timeout_launcher
       
    81         #backup = sys.argv
       
    82         #sys.argv = ['--', 'echo 1']
       
    83         #timeout_launcher.main()
       
    84         #sys.argv = backup
       
    85