|
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 |
|
17 import unittest, os, re, subprocess |
|
18 |
|
19 # import __init__ |
|
20 from cone.public import api, plugin |
|
21 from cone.storage import filestorage |
|
22 from testautomation.base_testcase import BaseTestCase |
|
23 from commandplugin.commandml import Command, Condition |
|
24 from cone.public.api import Configuration |
|
25 |
|
26 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
27 testdata = os.path.join(ROOT_PATH,'project') |
|
28 |
|
29 class TestParseCommandMl(BaseTestCase): |
|
30 def _get_impl_and_set(self, ref): |
|
31 fs = filestorage.FileStorage(testdata) |
|
32 p = api.Project(fs) |
|
33 config = p.get_configuration('product.confml') |
|
34 impl_set = plugin.get_impl_set(config, re.escape(ref) + '$') |
|
35 self.assertEquals(len(impl_set), 1) |
|
36 return iter(impl_set).next(), impl_set |
|
37 |
|
38 def test_parse_file3(self): |
|
39 impl, impl_set = self._get_impl_and_set('file3.commandml') |
|
40 self.assertEquals(len(impl[0].reader.elements), 2) |
|
41 |
|
42 cond1 = impl.impls[0].reader.elements[0] |
|
43 cond2 = impl.impls[0].reader.elements[1] |
|
44 |
|
45 # Create temporary variables |
|
46 impl_set.create_temp_features(impl_set.generation_context.configuration) |
|
47 |
|
48 self.assertTrue(isinstance(cond1, Condition)) |
|
49 self.assertTrue(isinstance(cond2, Condition)) |
|
50 |
|
51 |
|
52 self.assertEquals(True, cond1._solve_condition(cond1.condition, impl_set.generation_context)) |
|
53 self.assertEquals(False, cond2._solve_condition(cond2.condition, impl_set.generation_context)) |
|
54 |
|
55 |
|
56 if __name__ == '__main__': |
|
57 unittest.main() |