12 # Contributors: |
12 # Contributors: |
13 # |
13 # |
14 # Description: |
14 # Description: |
15 # |
15 # |
16 |
16 |
17 import sys, os, unittest |
17 import os |
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 testautomation.base_testcase import BaseTestCase |
21 from testautomation.base_testcase import BaseTestCase |
23 from cone.public import exceptions, plugin, api, container |
22 from cone.public import plugin, api |
24 |
23 |
25 from examplemlplugin import exampleml_reader |
|
26 |
24 |
27 def abspath(path): |
25 def abspath(path): |
28 return os.path.normpath(os.path.join(ROOT_PATH, path)) |
26 return os.path.normpath(os.path.join(ROOT_PATH, path)) |
29 |
27 |
30 class TestExamplemlGeneration(BaseTestCase): |
28 class TestExamplemlGeneration(BaseTestCase): |
31 |
29 |
32 def test_generate_from_project(self): |
30 def test_generate_from_project(self): |
33 project_dir = abspath('project') |
31 project_dir = abspath('testdata/generation/project') |
34 config = 'root.confml' |
32 config = 'root.confml' |
35 output_dir = abspath('temp/output') |
33 output_dir = abspath('temp/generation/output') |
36 expected_dir = abspath('gen_expected') |
34 expected_dir = abspath('testdata/generation/expected') |
37 |
35 |
38 self.remove_if_exists(output_dir) |
36 self.remove_if_exists(output_dir) |
39 |
37 |
40 prj = api.Project(api.Storage.open(project_dir)) |
38 prj = api.Project(api.Storage.open(project_dir)) |
41 config = prj.get_configuration(config) |
39 config = prj.get_configuration(config) |
|
40 context = plugin.GenerationContext(configuration=config, |
|
41 output=output_dir) |
42 impls = plugin.get_impl_set(config) |
42 impls = plugin.get_impl_set(config) |
43 impls.output = output_dir |
43 impls.generate(context) |
44 impls.generate() |
|
45 |
44 |
46 self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn']) |
45 self.assert_dir_contents_equal(output_dir, expected_dir, ['.svn']) |
47 |
46 |