buildframework/helium/sf/python/pythoncore/lib/pythoncorecpythontests/test_ccm.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
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_ccm.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 ccm python toolkit.
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
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    24
# pylint: disable=E1101
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import sys
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
import mocker
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
import ccm
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
_logger = logging.getLogger('test.ccm')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
class CcmTest(mocker.MockerTestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    """ Tests the ccm module using mocker to prevent accessing a real Synergy database. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
    def test_running_sessions(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        """ Running sessions can be checked. """
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    41
        obj = self.mocker.replace(ccm.execute)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        if sys.platform == "win32":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
            obj('c:\\apps\\ccm65\\bin\\ccm.exe status')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
            site_id = 'fa_nmp'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
            if 'SITE_ID' in os.environ:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
                site_id = os.environ['SITE_ID']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
            obj('/nokia/' + site_id + '/apps/cmsynergy/6.5/bin/ccm status')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        self.mocker.result(("""Sessions for user pmackay:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
Command Interface @ 1CAL01176:1553:10.241.72.23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
Database: /nokia/vc_nmp/groups/gscm/dbs/vc1s60p1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
Current project could not be identified.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
""", 0))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        self.mocker.replay()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
        sessions = ccm.running_sessions()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        print sessions
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
#    def test_open_session(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
#        """ ccm session can be opened. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
#        gscm_obj = self.mocker.replace(nokia.gscm._execute)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    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')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    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))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
#        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
#        obj = self.mocker.replace(ccm._execute)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    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')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
#        self.mocker.result(("1CAL01176:1333:10.186.216.77:10.241.72.68", 0))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
#        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
#        self.mocker.replay()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    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')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
    #def test_timeout_launcher(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
        #sys.path.append(os.path.join(os.environ['HELIUM_HOME'], 'tools/common/python/scripts'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
        #import timeout_launcher
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
        #backup = sys.argv
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
        #sys.argv = ['--', 'echo 1']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
        #timeout_launcher.main()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
        #sys.argv = backup
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83