14 # Description: |
14 # Description: |
15 # |
15 # |
16 |
16 |
17 import unittest, os, shutil |
17 import unittest, os, shutil |
18 |
18 |
19 import __init__ |
|
20 from projectconvertplugin import convertproject |
19 from projectconvertplugin import convertproject |
21 from cone.public import exceptions,plugin,api |
20 from cone.public import plugin,api |
22 from cone.storage import filestorage |
21 from cone.storage import filestorage |
23 from cone.confml import implml |
|
24 from testautomation.base_testcase import BaseTestCase |
22 from testautomation.base_testcase import BaseTestCase |
25 |
23 |
26 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
24 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
27 temp_dir = os.path.join(ROOT_PATH, "temp") |
25 temp_dir = os.path.join(ROOT_PATH, "temp") |
28 testdata = os.path.join(ROOT_PATH,'project') |
26 testdata = os.path.join(ROOT_PATH,'project') |
41 self.assertEquals(1, len(impls)) |
39 self.assertEquals(1, len(impls)) |
42 impl = iter(impls).next() |
40 impl = iter(impls).next() |
43 self.assertTrue(isinstance(impl, convertproject.ConvertProjectImpl)) |
41 self.assertTrue(isinstance(impl, convertproject.ConvertProjectImpl)) |
44 |
42 |
45 def test_generate(self): |
43 def test_generate(self): |
|
44 os.environ['ncp_version'] = 'platforms' |
|
45 os.environ['variants'] = 'variants' |
46 output_dir = os.path.join(temp_dir, "new_project") |
46 output_dir = os.path.join(temp_dir, "new_project") |
47 if os.path.exists(output_dir): |
47 if os.path.exists(output_dir): |
48 shutil.rmtree(output_dir) |
48 shutil.rmtree(output_dir) |
49 expected_dir = os.path.join(ROOT_PATH, "expected/new_project") |
49 expected_dir = os.path.join(ROOT_PATH, "expected/new_project") |
50 oldPath = os.path.join(ROOT_PATH,'old_structure/epoc32/rom/config') |
50 oldPath = os.path.join(ROOT_PATH,'old_structure/epoc32/rom/config') |
51 |
51 |
52 fs = filestorage.FileStorage(oldPath) |
52 fs = filestorage.FileStorage(oldPath) |
53 p = api.Project(fs) |
53 p = api.Project(fs) |
54 config = p.get_configuration('convert.confml') |
54 config = p.get_configuration('convert.confml') |
|
55 context = plugin.GenerationContext(configuration=config, |
|
56 output=output_dir) |
55 impls = plugin.get_impl_set(config,'\.convertprojectml$') |
57 impls = plugin.get_impl_set(config,'\.convertprojectml$') |
56 impls.output = output_dir |
58 context.filtering_disabled = True |
57 impls.generate() |
59 impls.generate(context) |
58 |
60 |
59 self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn']) |
61 self.assert_dir_contents_equal(expected_dir, output_dir, ['.svn']) |
60 |
62 |
61 |
63 |
62 if __name__ == '__main__': |
64 if __name__ == '__main__': |
63 unittest.main() |
65 unittest.main() |