|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 #!/usr/bin/env python |
|
17 ## |
|
18 # @author Teemu Rytkonen |
|
19 |
|
20 import os |
|
21 |
|
22 import unittest |
|
23 from cone.action import configroot2flat |
|
24 from cone.public import api |
|
25 |
|
26 ROOT_PATH = os.path.abspath(os.path.dirname(__file__)) |
|
27 |
|
28 |
|
29 class TestConfigRootFlat(unittest.TestCase): |
|
30 def test_get_flat_configuration_with_empty_config(self): |
|
31 conf = api.Configuration('foo.confml') |
|
32 self.assertEquals(configroot2flat.get_flat_includes(conf), []) |
|
33 |
|
34 def test_get_flat_configuration_with_single_config_hierarchy(self): |
|
35 conf = api.Configuration('foo.confml') |
|
36 conf.include_configuration('test1/root.confml') |
|
37 conf.include_configuration('test2/root.confml') |
|
38 conf.include_configuration('test3/root.confml') |
|
39 self.assertEquals(configroot2flat.get_flat_includes(conf), ['test1/root.confml', |
|
40 'test2/root.confml', |
|
41 'test3/root.confml']) |
|
42 |
|
43 def test_get_flat_configuration_with_two_level_config_hierarchy(self): |
|
44 prj = api.Project(api.Storage.open(os.path.join(ROOT_PATH,'temp'), 'w')) |
|
45 rootconf1 = prj.create_configuration('product1_root.confml', True) |
|
46 rootconf2 = prj.create_configuration('product2_root.confml', True) |
|
47 prj.create_configuration('test/one/root.confml', True) |
|
48 fooconf = prj.create_configuration('test/foo.confml', True) |
|
49 rootconf1.create_configuration('layer1/root.confml') |
|
50 rootconf1.create_configuration('layer2/root.confml') |
|
51 rootconf1.create_configuration('layer3/root.confml') |
|
52 fooconf.include_configuration('/product1_root.confml') |
|
53 fooconf.include_configuration('/product2_root.confml') |
|
54 fooconf.include_configuration('/test/one/root.confml') |
|
55 rootconf1.create_configuration('layer5/root.confml') |
|
56 rootconf1.create_configuration('layer6/root.confml') |
|
57 prj.save() |
|
58 self.assertEquals(configroot2flat.get_flat_includes(fooconf), ['layer1/root.confml', |
|
59 'layer2/root.confml', |
|
60 'layer3/root.confml', |
|
61 'layer5/root.confml', |
|
62 'layer6/root.confml', |
|
63 'test/one/root.confml']) |
|
64 |