587
|
1 |
#============================================================================
|
|
2 |
#Name : test_sis.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
""" Test sis module. """
|
|
21 |
|
|
22 |
import logging
|
|
23 |
import unittest
|
|
24 |
import tempfile
|
|
25 |
import os
|
628
|
26 |
import amara
|
587
|
27 |
import configuration
|
|
28 |
import sis
|
|
29 |
|
|
30 |
_logger = logging.getLogger('test.sis')
|
|
31 |
|
|
32 |
class ArchivePreBuilderTest(unittest.TestCase):
|
|
33 |
""" Tests for sis module. """
|
|
34 |
|
|
35 |
def test_sis_v1(self):
|
|
36 |
""" V1 config format. """
|
|
37 |
data = {'name': 'foo',
|
|
38 |
'path': 'bar'}
|
|
39 |
tree = self._setup_test_case(data)
|
628
|
40 |
assert tree.xml_xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
|
587
|
41 |
|
|
42 |
def test_sis_v2(self):
|
|
43 |
""" V2 config format. """
|
|
44 |
data = {'input': 'foo.pkg'}
|
|
45 |
tree = self._setup_test_case(data)
|
628
|
46 |
assert tree.xml_xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
|
587
|
47 |
|
|
48 |
def test_sis_v2_1(self):
|
|
49 |
""" V2 config format for sisx. """
|
|
50 |
data = {'input': 'foo.pkg', 'output': 'foo.sisx'}
|
|
51 |
tree = self._setup_test_case(data)
|
628
|
52 |
assert tree.xml_xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
|
|
53 |
assert tree.xml_xpath("/project/target[@name='stage2']/parallel/*/arg/@line")[0] == '-v foo.sis foo.sisx cert1 key1'
|
587
|
54 |
|
|
55 |
def _setup_test_case(self, additional_data):
|
|
56 |
""" Setup test case based on varying inputs. """
|
|
57 |
data = {'makesis.tool': 'makesis',
|
|
58 |
'signsis.tool': 'signsis',
|
|
59 |
'key': 'key1',
|
|
60 |
'cert': 'cert1',
|
|
61 |
'build.sisfiles.dir': 'dir'}
|
|
62 |
data.update(additional_data)
|
|
63 |
config = configuration.ConfigurationSet([configuration.Configuration(data)])
|
|
64 |
sis_prebuilder = sis.SisPreBuilder(config)
|
|
65 |
tmpfile = os.path.join(tempfile.mkdtemp(), 'test.xml')
|
|
66 |
sis_prebuilder.write(tmpfile)
|
628
|
67 |
tree = amara.parse(open(tmpfile))
|
587
|
68 |
return tree
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|