|
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 sys, os, unittest |
|
18 import __init__ |
|
19 |
|
20 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
21 |
|
22 from cone.public import plugin, api |
|
23 from examplemlplugin.exampleml_reader import ExamplemlReader |
|
24 from examplemlplugin.exampleml_model import Output |
|
25 |
|
26 class TestExamplemlImpl(unittest.TestCase): |
|
27 |
|
28 def setUp(self): |
|
29 project_dir = os.path.join(ROOT_PATH, 'project') |
|
30 self.project = api.Project(api.Storage.open(project_dir)) |
|
31 self.config = self.project.get_configuration('root.confml') |
|
32 |
|
33 def get_impl(self, ref, index): |
|
34 impl_list = plugin.ImplFactory.get_impls_from_file(ref, self.config) |
|
35 return impl_list[index] |
|
36 |
|
37 def test_has_ref(self): |
|
38 impl = self.get_impl('Layer/implml/test.exampleml', 0) |
|
39 self.assertTrue(impl.has_ref(['TestFeature.Value1'])) |
|
40 self.assertFalse(impl.has_ref(['TestFeature.Foo'])) |
|
41 self.assertFalse(impl.has_ref(['Foo.Bar'])) |
|
42 |
|
43 def test_list_output_files(self): |
|
44 def oj( p2): # oj = output_join |
|
45 return os.path.normpath(os.path.join('output', p2)) |
|
46 |
|
47 impl = self.get_impl('Layer/implml/test.exampleml', 0) |
|
48 self.assertEquals(impl.list_output_files(), [oj('test.txt'), |
|
49 oj('some/dir/out1.txt'), |
|
50 oj('some/dir2/out2.txt')]) |
|
51 |
|
52 impl = self.get_impl('Layer/implml/multitest.implml', 0) |
|
53 self.assertEquals(impl[0].list_output_files(), [oj('multitest1_1.txt'), |
|
54 oj('multitest1_2.txt')]) |
|
55 |
|
56 impl = self.get_impl('Layer/implml/multitest.implml', 0) |
|
57 self.assertEquals(impl[1].list_output_files(), [oj('multitest2_1.txt'), |
|
58 oj('multitest2_2.txt')]) |