configurationengine/source/cone/action/tests/unittest_configroot2flat.py
changeset 4 0951727b8815
parent 3 e7e0ae78773e
equal deleted inserted replaced
3:e7e0ae78773e 4:0951727b8815
    15 #
    15 #
    16 #!/usr/bin/env python
    16 #!/usr/bin/env python
    17 ## 
    17 ## 
    18 # @author Teemu Rytkonen
    18 # @author Teemu Rytkonen
    19 
    19 
    20 import os
    20 import os, shutil
    21 
    21 
    22 import unittest
    22 import unittest
    23 from cone.action import configroot2flat
    23 from cone.action import configroot2flat
    24 from cone.public import api
    24 from cone.public import api
    25 
    25 
    59                                                                        'layer2/root.confml',
    59                                                                        'layer2/root.confml',
    60                                                                        'layer3/root.confml',
    60                                                                        'layer3/root.confml',
    61                                                                        'layer5/root.confml',
    61                                                                        'layer5/root.confml',
    62                                                                        'layer6/root.confml',
    62                                                                        'layer6/root.confml',
    63                                                                        'test/one/root.confml'])
    63                                                                        'test/one/root.confml'])
    64                 
    64     
       
    65     def test_get_flat_configuration_with_nonexistent_files(self):
       
    66         TEMP_DIR = os.path.join(ROOT_PATH,'temp2')
       
    67         if os.path.exists(TEMP_DIR):
       
    68             shutil.rmtree(TEMP_DIR)
       
    69         
       
    70         # Create a configuration with some non-existent layers
       
    71         prj = api.Project(api.Storage.open(TEMP_DIR, 'w'))
       
    72         prj.create_configuration('test/one/root.confml', True)
       
    73         
       
    74         rootconf1 = prj.create_configuration('product1_root.confml', True)
       
    75         rootconf1.create_configuration('layer1/root.confml')
       
    76         rootconf1.include_configuration('nonexistent1/root.confml')
       
    77         
       
    78         rootconf2 = prj.create_configuration('product2_root.confml', True)
       
    79         rootconf2.create_configuration('layer3/root.confml')
       
    80         rootconf2.include_configuration('nonexistent2/root.confml')
       
    81         
       
    82         fooconf = prj.create_configuration('test/foo.confml', True)
       
    83         fooconf.include_configuration('/product1_root.confml')
       
    84         fooconf.include_configuration('/product2_root.confml')
       
    85         rootconf1.include_configuration('/nonexistent_product_root.confml')
       
    86         fooconf.include_configuration('/test/one/root.confml')
       
    87         fooconf.include_configuration('nonexistent3/root.confml')
       
    88         prj.save()
       
    89         prj.close()
       
    90         
       
    91         action = configroot2flat.ConeConfigroot2FlatAction(
       
    92             project=TEMP_DIR,
       
    93             configs=['test/foo.confml'])
       
    94         action.run()
       
    95         
       
    96         prj = api.Project(api.Storage.open(TEMP_DIR, 'r'))
       
    97         fooconf = prj.get_configuration('foo.confml')
       
    98         self.assertEquals(fooconf.list_configurations(),
       
    99             ['layer1/root.confml',
       
   100              'nonexistent1/root.confml',
       
   101              'layer3/root.confml',
       
   102              'nonexistent2/root.confml',
       
   103              'test/one/root.confml',
       
   104              'nonexistent3/root.confml'])
       
   105