| 179 |      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 | 
 | 
|  |     25 | from lxml import etree
 | 
|  |     26 | 
 | 
|  |     27 | import configuration
 | 
|  |     28 | import sis
 | 
|  |     29 | 
 | 
|  |     30 | _logger = logging.getLogger('test.sis')
 | 
|  |     31 | 
 | 
|  |     32 | 
 | 
|  |     33 | class ArchivePreBuilderTest(unittest.TestCase):
 | 
|  |     34 |     """ Tests for sis module. """
 | 
|  |     35 |     
 | 
|  |     36 |     def test_sis_v1(self):
 | 
|  |     37 |         """ V1 config format. """
 | 
|  |     38 |         data = {'name': 'foo',
 | 
|  |     39 |                 'path': 'bar'}
 | 
|  |     40 |         tree = self._setup_test_case(data)
 | 
|  |     41 |         assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
 | 
|  |     42 |         
 | 
|  |     43 |     def test_sis_v2(self):
 | 
|  |     44 |         """ V2 config format. """
 | 
|  |     45 |         data = {'input': 'foo.pkg'}
 | 
|  |     46 |         tree = self._setup_test_case(data)
 | 
|  |     47 |         assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
 | 
|  |     48 | 
 | 
|  |     49 |     def test_sis_v2_1(self):
 | 
|  |     50 |         """ V2 config format for sisx. """
 | 
|  |     51 |         data = {'input': 'foo.pkg', 'output': 'foo.sisx'}
 | 
|  |     52 |         tree = self._setup_test_case(data)
 | 
|  |     53 |         assert tree.xpath("/project/target[@name='stage1']/parallel/*/arg/@line")[0] == '-v foo.pkg foo.sis'
 | 
|  |     54 |         assert tree.xpath("/project/target[@name='stage2']/parallel/*/arg/@line")[0] == '-v foo.sis foo.sisx cert1 key1'
 | 
|  |     55 |         
 | 
|  |     56 |     def _setup_test_case(self, additional_data):
 | 
|  |     57 |         """ Setup test case based on varying inputs. """
 | 
|  |     58 |         data = {'makesis.tool': 'makesis',
 | 
|  |     59 |                 'signsis.tool': 'signsis',
 | 
|  |     60 |                 'key': 'key1',
 | 
|  |     61 |                 'cert': 'cert1',
 | 
|  |     62 |                 'build.sisfiles.dir': 'dir'}
 | 
|  |     63 |         data.update(additional_data)
 | 
|  |     64 |         config = configuration.ConfigurationSet([configuration.Configuration(data)])
 | 
|  |     65 |         sis_prebuilder = sis.SisPreBuilder(config)
 | 
|  |     66 |         sis_prebuilder.write('test.xml')
 | 
|  |     67 |         
 | 
|  |     68 |         tree = etree.parse('test.xml')
 | 
|  |     69 |         return tree
 | 
|  |     70 |     
 | 
|  |     71 | 
 | 
|  |     72 | 
 | 
|  |     73 | 
 | 
|  |     74 | 
 | 
|  |     75 | 
 |