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