13 # |
13 # |
14 # Description: |
14 # Description: |
15 # |
15 # |
16 |
16 |
17 import sys, os, unittest |
17 import sys, os, unittest |
18 import __init__ |
|
19 |
18 |
20 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
19 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
21 |
20 |
22 from cone.public import plugin, api |
21 from cone.public import plugin, api |
23 from examplemlplugin.exampleml_reader import ExamplemlReader |
22 from examplemlplugin.exampleml_reader import ExamplemlReader |
24 from examplemlplugin.exampleml_model import Output |
23 from examplemlplugin.exampleml_model import Output |
25 |
24 |
26 class TestExamplemlImpl(unittest.TestCase): |
25 class TestExamplemlImpl(unittest.TestCase): |
27 |
26 |
28 def setUp(self): |
27 def setUp(self): |
29 project_dir = os.path.join(ROOT_PATH, 'project') |
28 project_dir = os.path.join(ROOT_PATH, 'testdata/generation/project') |
30 self.project = api.Project(api.Storage.open(project_dir)) |
29 self.project = api.Project(api.Storage.open(project_dir)) |
31 self.config = self.project.get_configuration('root.confml') |
30 self.config = self.project.get_configuration('root.confml') |
32 |
31 |
33 def get_impl(self, ref, index): |
32 def get_impl(self, ref, index): |
34 impl_list = plugin.ImplFactory.get_impls_from_file(ref, self.config) |
33 impl_list = plugin.ImplFactory.get_impls_from_file(ref, self.config) |
40 self.assertFalse(impl.has_ref(['TestFeature.Foo'])) |
39 self.assertFalse(impl.has_ref(['TestFeature.Foo'])) |
41 self.assertFalse(impl.has_ref(['Foo.Bar'])) |
40 self.assertFalse(impl.has_ref(['Foo.Bar'])) |
42 |
41 |
43 def test_list_output_files(self): |
42 def test_list_output_files(self): |
44 def oj( p2): # oj = output_join |
43 def oj( p2): # oj = output_join |
45 return os.path.normpath(os.path.join('output', p2)) |
44 return os.path.normpath(p2) |
46 |
45 |
47 impl = self.get_impl('Layer/implml/test.exampleml', 0) |
46 impl = self.get_impl('Layer/implml/test.exampleml', 0) |
48 self.assertEquals(impl.list_output_files(), [oj('test.txt'), |
47 self.assertEquals(impl.list_output_files(), [oj('test.txt'), |
49 oj('some/dir/out1.txt'), |
48 oj('some/dir/out1.txt'), |
50 oj('some/dir2/out2.txt')]) |
49 oj('some/dir2/out2.txt')]) |