buildframework/helium/sf/python/pythoncore/lib/pythoncoretests/test_preparation.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
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_preparation.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
""" Testing preparation module """  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    21
# pylint: disable=R0201
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    22
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import tempfile
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
from shutil import rmtree
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import unittest
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import preparation
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
import ccm
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
import ccm.extra
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
_logger = logging.getLogger('test.preparation')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
logging.basicConfig(level=logging.INFO)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
_disable_is_relative = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
_disable_sub_projects = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    37
# pylint: disable=W0613
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
#these methods are all mocking/emulating the real methods in other files so need the interface to be
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
#the same and no code present hence pylint throws up warnings saying unused variables.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
def _get_role_for_status(status): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
    """ Emulate get_role_for_status method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
    pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
def _get_role_for_purpose(session, purpose): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    """ Emulate get_role_for_purpose method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
def _sessionPool(username, password, engine, dbpath, database, size, opener):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
    """ Emulate ccm.SessionPool method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    return _emulateSession()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
def _fastSnapshot(project, target_dir, threads): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    """ Emulate ccm.extra.FastSnapshot method for unit testing """
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    54
    #Snapshot Created
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
def _updateResultSimple(session): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    """ Emulate ccm.UpdateResultSimple method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
    pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    60
def _fastMaintainWorkArea(project, dir_, projectname, threads): 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
    """ Emulate ccm.extra.FastMaintainWorkArea method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
    pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
def _is_same_family(self, project): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
    """ Emulate project.is_same_family method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
    pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
def _checkoutException( self, session, version, purpose ): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    """ Emulate project.checkout method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
    raise ccm.CCMException('unit testing')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
def _checkoutNone( self, session, version, purpose ): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
    """ Emulate project.checkout method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
    return _checkout(True) 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
def _get_workarea_info_exception(self, path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
    """ Emulate session.get_workarea_info method for unit testing """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
    raise ccm.CCMException('unit testing')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
# pylint: enable-msg=W0613
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
class PreparationTest(unittest.TestCase):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
    """Verifying preparation module"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
    def setUp(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
        """SetUp: setup variables required, called before all the tests are run"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
        self._sessionPool_safe = ccm.SessionPool 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        self._getRoleForStatus_safe = ccm.get_role_for_status 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
        self._getRolesForPurpose_safe = ccm.get_role_for_purpose 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
        self._extraFastSnapshot_safe = ccm.extra.FastSnapshot 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
        self._updateResultSimple_safe = ccm.UpdateResultSimple 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
        self._extra_FastMaintainWorkArea_safe = ccm.extra.FastMaintainWorkArea 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        ccm.SessionPool = _sessionPool
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
        ccm.get_role_for_status = _get_role_for_status
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
        ccm.get_role_for_purpose = _get_role_for_purpose
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
        ccm.extra.FastSnapshot = _fastSnapshot
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
        ccm.UpdateResultSimple = _updateResultSimple
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
        ccm.extra.FastMaintainWorkArea = _fastMaintainWorkArea
588
c7c26511138f helium-10.0.0-bc45d50958fe
wbernard
parents: 587
diff changeset
    99
        #Setup a temporary project directory for unit testing
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
        self.dirname = os.path.join(tempfile.gettempdir(), 'pyUnitTestHeliumProject')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
        self.filename = os.path.join(self.dirname, 'project.version')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
        if os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
            rmtree(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
    def tearDown(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
        """Remove the temporary project directory after unit testing complete """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
        ccm.SessionPool = self._sessionPool_safe 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
        ccm.get_role_for_status = self._getRoleForStatus_safe 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
        ccm.get_role_for_purpose = self._getRolesForPurpose_safe 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
        ccm.extra.FastSnapshot = self._extraFastSnapshot_safe 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
        ccm.UpdateResultSimple = self._updateResultSimple_safe 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
        ccm.extra.FastMaintainWorkArea = self._extra_FastMaintainWorkArea_safe 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
        if os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
            rmtree(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
    def test_find_valid(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
        """Verifying find (valid args) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
        seq = range(2) 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
        assert preparation.find(dummyFunction, seq) is not None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
    def test_find_invalid(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
        """Verifying find (invalid args) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
        seq = range(2, 5) 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
        assert preparation.find(dummyFunction, seq) is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
    def test_prep_builder_sshot_check_valid_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
        """Verifying check (valid args - snapshot with database) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
        builder = preparation.PreparationBuilder([_config('snapshot')], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
        assert builder.check() is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
    def test_prep_builder_sshot_check_valid_2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
        """Verifying check (valid args - snapshot with host + dbpath) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
        confObj = _config('snapshot')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
        del confObj['database']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
        confObj['host'] = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
        confObj['dbpath'] = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
        assert builder.check() is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
    def test_prep_builder_sshot_check_expn_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
        """Verifying check (snapshot - exception 1) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
        confObj = _config('snapshot')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
        del confObj['database']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
        self.assertRaises(Exception, builder.check)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
    def test_prep_builder_sshot_check_expn_2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
        """Verifying check (snapshot - exception 2) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
        confObj = _config('snapshot')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
        del confObj['database']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
        confObj['host'] = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
        self.assertRaises(Exception, builder.check)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
    def test_prep_builder_sshot_check_expn_3(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
        """Verifying check (snapshot - exception 3) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
        builder = preparation.PreparationBuilder([_config('snapshot')], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
        safe = _project.exists
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
        _project.exists = lambda self: False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
        self.assertRaises(Exception, builder.check)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
        _project.exists = safe
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
    def test_prep_builder_sshot_gtcnt_valid_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
        """Verifying get_content (valid args - snapshot - 1) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        builder = preparation.PreparationBuilder([_config('snapshot')], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
        builder.get_content()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
        versionFile = open(self.filename, 'r')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
        content = versionFile.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
        assert len(content) >= 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
            
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
    def test_prep_builder_sshot_gtcnt_valid_2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
        """Verifying get_content (valid args - snapshot - 2) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
        confObj = _config('snapshot')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
        confObj['threads'] = 2 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
        builder.get_content()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
        versionFile = open(self.filename, 'r')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
        content = versionFile.readlines()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
        assert len(content) >= 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
    def test_prep_builder_sshot_gtcnt_expn_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
        """Verifying get_content (exception - snapshot - 1) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
        os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
        builder = preparation.PreparationBuilder([_config('snapshot')], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
        self.assertRaises(Exception, builder.get_content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
    def test_prep_builder_ckt_check_valid(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
        """Verifying check (valid args - checkout) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
        confObj['tasks'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
        confObj['folders'] =  'x'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
        confObj['subbaselines'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
        assert builder.check() is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   199
    def test_prep_builder_ckt_check_expn_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   200
        """Verifying check (exception - checkout - 1) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   201
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   202
        del confObj['release']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   203
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   204
        self.assertRaises(Exception, builder.check)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   205
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   206
    def test_prep_builder_ckt_check_expn_2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   207
        """Verifying check (exception - checkout - 2) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   208
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   209
        confObj['folders'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   210
        confObj['purpose'] = "PurposeThatDoesnotExist"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   211
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   212
        self.assertRaises(Exception, builder.check)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   213
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   214
    def test_prep_builder_ckt_gtcnt_valid_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   215
        """Verifying get_content (valid args - checkout - 1) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   216
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   217
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   218
        result = builder.get_content() 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   219
        assert result is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   220
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   221
    def test_prep_builder_ckt_gtcnt_valid_2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   222
        """Verifying get_content (valid args - checkout - 2) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   223
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   224
            os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   225
        versionFile = open(self.filename , 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   226
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   227
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   228
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   229
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   230
        confObj['use.reconfigure.template'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   231
        confObj['threads'] = 2 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   232
        global _disable_is_relative
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   233
        _disable_is_relative = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   234
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   235
        result = builder.get_content() 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   236
        _disable_is_relative = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   237
        assert result is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   238
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   239
    def test_prep_builder_ckt_gtcnt_valid_3(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   240
        """Verifying get_content (valid args - checkout - 3) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   241
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   242
            os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   243
        versionFile = open(self.filename , 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   244
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   245
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   246
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   247
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   248
        confObj['use.reconfigure.template'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   249
        confObj['fix.missing.baselines'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   250
        confObj['threads'] = 2 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   251
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   252
        global _disable_sub_projects 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   253
        _disable_sub_projects = True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   254
        result = builder.get_content() 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   255
        _disable_sub_projects = False
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   256
        assert result is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   257
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   258
    def test_prep_builder_ckt_gtcnt_valid_4(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   259
        """Verifying get_content (valid args - checkout - 4) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   260
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   261
            os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   262
        versionFile = open(self.filename , 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   263
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   264
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   265
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   266
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   267
        confObj['sync'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   268
        confObj['replace.subprojects'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   269
        confObj['update.failonerror'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   270
        confObj['fix.missing.baselines'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   271
        confObj['show.conflict.objects'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   272
        confObj['show.conflicts'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   273
        confObj['subbaselines'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   274
        confObj['tasks'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   275
        confObj['folders'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   276
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   277
        result = builder.get_content() 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   278
        assert result is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   279
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   280
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   281
    def test_prep_builder_ckt_gtcnt_expn_1(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   282
        """Verifying get_content (exception - checkout - 1) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   283
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   284
            os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   285
        versionFile = open(self.filename , 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   286
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   287
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   288
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   289
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   290
        confObj['use.reconfigure.template'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   291
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   292
        safe = _project.checkout 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   293
        _project.checkout = _checkoutException
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   294
        self.assertRaises(ccm.CCMException, builder.get_content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   295
        _project.checkout  = safe
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   296
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   297
    def test_prep_builder_ckt_gtcnt_expn_2(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   298
        """Verifying get_content (exception - checkout - 2) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   299
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   300
            os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   301
        versionFile = open(self.filename , 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   302
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   303
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   304
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   305
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   306
        confObj['use.reconfigure.template'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   307
        safe = _project.checkout 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   308
        _project.checkout = _checkoutNone
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   309
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   310
        self.assertRaises(Exception, builder.get_content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   311
        _project.checkout  = safe
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   312
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   313
    def test_prep_builder_ckt_gtcnt_expn_3(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   314
        """Verifying get_content (exception - checkout - 3) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   315
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   316
            os.makedirs(os.path.join(self.dirname, 'pyUnitTestHeliumProject'))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   317
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   318
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   319
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   320
        confObj['use.reconfigure.template'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   321
        safe = _emulateSession.get_workarea_info 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   322
        _emulateSession.get_workarea_info = _get_workarea_info_exception
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   323
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   324
        result = builder.get_content() 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   325
        _emulateSession.get_workarea_info  = safe
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   326
        assert result is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   327
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   328
    def test_prep_builder_ckt_gtcnt_expn_4(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   329
        """Verifying get_content (expcetion - checkout - 4) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   330
        if not os.path.exists(self.dirname): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   331
            os.makedirs(self.dirname)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   332
        versionFile = open(self.filename , 'w+')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   333
        versionFile.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   334
        confObj = _config('checkout')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   335
        confObj['purpose'] = "samplePurpose"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   336
        confObj['version'] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   337
        confObj['sync'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   338
        confObj['fix.missing.baselines'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   339
        confObj['show.conflict.objects'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   340
        confObj['show.conflicts'] = "true"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   341
        confObj['subbaselines'] = [ 'x', 'y' , 'z']
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   342
        safe = _subProject.is_same_family  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   343
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   344
        _subProject.is_same_family = _is_same_family
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   345
        self.assertRaises(Exception, builder.get_content)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   346
        _subProject.is_same_family = safe
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   347
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   348
    def test_prep_builder_update_gtcnt_valid(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   349
        """Verifying get_content (valid args - update) method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   350
        confObj = _config('update')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   351
        confObj['replace.subprojects'] = 'False'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   352
        confObj['update.failonerror'] = 'true'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   353
        builder = preparation.PreparationBuilder([confObj], None, None, None)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   354
        result = builder.get_content()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   355
        assert result is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   356
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   357
    def test_prep_action_execute(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   358
        """Verifying execute method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   359
        assert preparation.PreparationAction(None, None).execute() is None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   360
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   361
def dummyFunction(item):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   362
    """Emulating a callback method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   363
    if item in range(2):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   364
        return True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   365
    return None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   366
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   367
class _config():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   368
    """Emulating configuration class"""
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   369
    def __init__(self, type_):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   370
        self.database = 'test'
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   371
        self.type = type_
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   372
        self.name = 'test'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   373
        self.data = {'database': 'test'}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   374
        self.data['dir'] = tempfile.gettempdir()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   375
        self.data['release'] = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   376
        self.threads = 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   377
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   378
    def get_int(self, key, default_value):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   379
        """ Get a value as an int. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   380
        try:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   381
            value = self.__getitem__(key)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   382
            return int(value)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   383
        except KeyError:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   384
            return default_value
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   385
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   386
    def get_boolean(self, key, default_value):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   387
        """ Get a value as a boolean. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   388
        try:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   389
            value = self.__getitem__(key)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   390
            return value == "true" or value == "yes" or value == "1" 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   391
        except KeyError:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   392
            return default_value
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   393
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   394
    def has_key(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   395
        """ Check if key exists. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   396
        return self.data.has_key(key)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   397
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   398
    def __getitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   399
        """ Get an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   400
        return self.data[key]                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   401
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   402
    def __setitem__(self, key, value):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   403
        """ Set an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   404
        self.data[key] = value               
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   405
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   406
    def __delitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   407
        """ Remove an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   408
        del self.data[key]                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   409
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   410
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   411
class _emulateSession():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   412
    """Emulating session class"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   413
    def __init__(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   414
        self.size = 1
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   415
        self.role = 'developer'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   416
        self.data = {'samplePurpose': None }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   417
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   418
    def __getitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   419
        """ Get an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   420
        return self.data[key]                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   421
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   422
    def __setitem__(self, key, value):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   423
        """ Set an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   424
        self.data[key] = value               
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   425
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   426
    def __delitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   427
        """ Remove an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   428
        del self.data[key]                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   429
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   430
    def _get_role(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   431
        """Emulating session._get_role method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   432
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   433
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   434
    def has_key(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   435
        """ Check if key exists. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   436
        return self.data.has_key(key)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   437
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   438
# pylint: disable=W0613
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   439
#need disable msg to prevent pylint warning as this is emulating the real method.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   440
    def create(self, fpn):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   441
        """Emulating session.create method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   442
        return _project()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   443
# pylint: enable-msg=W0613
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   444
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   445
    def purposes(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   446
        """Emulating session.purposes method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   447
        return self
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   448
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   449
# pylint: disable=W0613
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   450
#need disable msg to prevent pylint warning as this is emulating the real method.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   451
    def get_workarea_info(self, path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   452
        """Emulating session.get_workarea_info method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   453
        return _getWorkAreaInfo()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   454
# pylint: enable-msg=W0613
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   455
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   456
class _getWorkAreaInfo():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   457
    """Emulating work area info """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   458
    def __init__(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   459
        self.data = {'project': _project()}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   460
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   461
    def __getitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   462
        """ Get an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   463
        return self.data[key]    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   464
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   465
class _project():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   466
    """Emulating project class"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   467
    def __init__(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   468
        self.name = 'pyUnitTestHeliumProject'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   469
        self.objectname = '1'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   470
        self.data = {'status':None} 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   471
        self.data['project'] =  _subProject()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   472
        if _disable_is_relative:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   473
            self.data['is_relative'] =  None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   474
        self.data['release'] =  None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   475
        self.release = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   476
        self.subprojects = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   477
        if not _disable_sub_projects:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   478
            self.subprojects.extend([ _subProject(), _subProject()])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   479
        self.session = _emulateSession()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   480
        self.tasks =  [ 'x' , 'y', 'z' ]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   481
        self.folders = [ 'x' , 'y', 'z' ]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   482
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   483
    def __getitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   484
        """ Get an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   485
        return self.data[key]    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   486
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   487
    def __setitem__(self, key, value):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   488
        """ Set an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   489
        self.data[key] = value               
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   490
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   491
    def keys(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   492
        """ Get the list of item keys. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   493
        return self.data.keys()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   494
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   495
    def exists(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   496
        """Emulating project.exists method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   497
        return True                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   498
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   499
    def snapshot(self, target_dir, status):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   500
        """Emulating project.snapshot method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   501
        print "Snapshot created"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   502
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   503
    def update(self, status, replace_subprojects, update_keepgoing, result): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   504
        """Emulating project.update method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   505
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   506
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   507
    def work_area(self, boolean1, boolean2, boolean3 = None, dir_=None, projectname=None ):
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   508
        """Emulating project.work_area method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   509
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   510
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   511
    def conflict(self, boolean, conflictsobjects):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   512
        """Emulating project.conflict method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   513
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   514
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   515
# pylint: disable=W0613
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   516
#need disable msg to prevent pylint warning as this is emulating the real method.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   517
    def checkout(self, session, version, purpose):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   518
        """Emulating project.checkout method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   519
        return  _checkout()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   520
# pylint: enable-msg=W0613
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   521
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   522
    def set_update_method(self, mode, boolean):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   523
        """Emulating project.set_update_method method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   524
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   525
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   526
    def set_baseline(self, project, boolean):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   527
        """Emulating project.set_baseline method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   528
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   529
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   530
    def remove_task(self, task):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   531
        """Emulating project.remove_task method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   532
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   533
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   534
    def remove_folder(self, folder):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   535
        """Emulating project.remove_folder method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   536
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   537
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   538
    def apply_update_properties(self, baseline): 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   539
        """Emulating project.apply_update_properties method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   540
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   541
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   542
    def create_attribute(self, is_relative, boolean1, boolean2):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   543
        """Emulating project.create_attribute method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   544
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   545
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   546
    def sync(self, boolean1, boolean2):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   547
        """Emulating project.sync method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   548
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   549
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   550
    def conflicts(self, boolean1, boolean2):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   551
        """Emulating project.conflicts method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   552
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   553
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   554
    def add_task(self, project):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   555
        """Emulating project.add_task method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   556
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   557
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   558
    def add_folder(self, project):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   559
        """Emulating project.add_folder method"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   560
        pass
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   561
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   562
class _checkout():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   563
    """Emulating checkout project """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   564
    def __init__(self, noProject=None):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   565
        if noProject:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   566
            self.project = None
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   567
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   568
            self.project = _project()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   569
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   570
class _subProject():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   571
    """Emulating sub project """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   572
    def __init__(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   573
        self.name = 'pyUnitTestHeliumProject'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   574
        self.objectname = '1'
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   575
        self.data = {'status':'test'} 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   576
        self.session = _emulateSession()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   577
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   578
    def __getitem__(self, key):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   579
        """ Get an item from the configuration via dictionary interface. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   580
        return self.data[key]    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   581
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   582
    def keys(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   583
        """ Get the list of item keys. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   584
        return self.data.keys()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   585
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   586
    def exists(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   587
        """Emulating sub project.exists """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   588
        return True                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   589
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
   590
# pylint: disable=W0613
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   591
#need disable msg to prevent pylint warning as this is emulating the real method.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   592
    def checkout(self, session, version, purpose, subprojects=None):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   593
        """Emulating sub project.checkout """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   594
        return  _checkout()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   595
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   596
    def is_same_family(self, project):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   597
        """Emulating sub project.is_same_family """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   598
        return True
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   599
# pylint: enable-msg=W0613
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   600
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   601
    def set_baseline(self, subbaseline, boolean1):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   602
        """Emulating sub project.set_baseline """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   603
        pass