587
|
1 |
#============================================================================
|
|
2 |
#Name : test_integration_ant.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 integration.ant module """
|
|
20 |
|
|
21 |
import tempfile
|
|
22 |
import os
|
|
23 |
import logging
|
|
24 |
import unittest
|
|
25 |
import integration.ant
|
|
26 |
|
|
27 |
_logger = logging.getLogger('test.integration.ant')
|
|
28 |
logging.basicConfig(level=logging.INFO)
|
|
29 |
|
|
30 |
class IntegrationAntTest(unittest.TestCase):
|
|
31 |
"""Verifying integration ant module"""
|
|
32 |
def test_check_build_duplicates_task(self):
|
|
33 |
"""Verifying check_build_duplicates_task method """
|
|
34 |
(fileDes, outputFilename) = tempfile.mkstemp()
|
|
35 |
os.close(fileDes)
|
|
36 |
integration.ant.check_build_duplicates_task(None, _emulateTask(), _emulateAttributes(outputFilename), _emulateElements())
|
|
37 |
outputFile = open(outputFilename, 'r')
|
|
38 |
contents = outputFile.readlines()
|
|
39 |
outputFile.close()
|
|
40 |
os.unlink(outputFilename)
|
|
41 |
assert len(contents) == 15
|
|
42 |
def test_check_build_duplicates_task_invalid(self):
|
|
43 |
"""Verifying check_build_duplicates_task (invalid args) method"""
|
|
44 |
self.assertRaises(Exception, integration.ant.check_build_duplicates_task, None, None, None, None)
|
|
45 |
|
|
46 |
class _emulateTask():
|
|
47 |
"""Emulate task"""
|
|
48 |
def log(self, message):
|
|
49 |
"""Emulate log method"""
|
|
50 |
pass
|
|
51 |
|
|
52 |
class _emulateAttributes():
|
|
53 |
"""Emulate attributes"""
|
|
54 |
def __init__(self, outputFilename):
|
|
55 |
self.outputFilename = outputFilename
|
|
56 |
def get(self, attribute):
|
|
57 |
"""Emulate get method"""
|
|
58 |
return self.outputFilename
|
|
59 |
|
|
60 |
class _emulateElements():
|
|
61 |
"""Emulate elements"""
|
|
62 |
def get(self, fileset):
|
|
63 |
"""Emulate get method"""
|
|
64 |
return _emulateFileset()
|
|
65 |
|
|
66 |
class _emulateFileset():
|
|
67 |
"""Emulate fileset"""
|
|
68 |
def get(self, eid):
|
|
69 |
"""Emulate get method"""
|
|
70 |
return _emulateDirScanner()
|
|
71 |
def size(self):
|
|
72 |
"""Emulate size method"""
|
|
73 |
return 1
|
|
74 |
|
|
75 |
class _emulateDirScanner():
|
|
76 |
"""Emulate dirscanner"""
|
|
77 |
def scan(self):
|
|
78 |
"""Emulate scan method"""
|
|
79 |
pass
|
|
80 |
def getIncludedFiles(self):
|
|
81 |
"""Emulate getIncludedFiles method """
|
|
82 |
if os.sep == '\\':
|
|
83 |
return ['test_build_compile.log']
|
|
84 |
elif os.sep == '/':
|
|
85 |
return ['test_build_compile_linux.log']
|
|
86 |
def getDirectoryScanner(self, project):
|
|
87 |
"""Emulate getDirectoryScanner method """
|
|
88 |
return self
|
|
89 |
def getBasedir(self):
|
|
90 |
"""Emulate getBasedir method """
|
|
91 |
return os.path.join(os.environ['TEST_DATA'], 'data', 'compile', 'logs')
|