48 |
45 |
49 def test_create_configuration(self): |
46 def test_create_configuration(self): |
50 self.prj.create_configuration("test.confml") |
47 self.prj.create_configuration("test.confml") |
51 self.assertTrue(self.prj.test_confml) |
48 self.assertTrue(self.prj.test_confml) |
52 self.assertEquals(self.prj.test_confml.get_path(),"test.confml") |
49 self.assertEquals(self.prj.test_confml.get_path(),"test.confml") |
|
50 |
|
51 def test_create_configuration_already_existing(self): |
|
52 self.prj.create_configuration("test.confml") |
|
53 try: |
|
54 self.prj.create_configuration("test.confml") |
|
55 self.fail("Succeeded to create already existing configuration") |
|
56 except exceptions.AlreadyExists: |
|
57 pass |
|
58 try: |
|
59 self.prj.add_configuration(api.Configuration("test.confml")) |
|
60 self.fail("Succeeded to create already existing configuration") |
|
61 except exceptions.AlreadyExists: |
|
62 pass |
|
63 |
|
64 def test_create_configuration_already_existing_with_overwrite(self): |
|
65 self.prj.create_configuration("test.confml") |
|
66 self.prj.create_configuration("test.confml", True) |
|
67 self.prj.add_configuration(api.Configuration("test.confml"), True) |
|
68 |
53 |
69 |
54 def test_create_and_getconfiguration(self): |
70 def test_create_and_getconfiguration(self): |
55 self.prj.create_configuration("test.confml") |
71 self.prj.create_configuration("test.confml") |
56 self.assertEquals(self.prj.get_configuration("test.confml").get_path(), "test.confml") |
72 self.assertEquals(self.prj.get_configuration("test.confml").get_path(), "test.confml") |
57 |
73 |
99 self.prj.create_configuration("test1.confml") |
115 self.prj.create_configuration("test1.confml") |
100 self.prj.create_configuration("test2.confml") |
116 self.prj.create_configuration("test2.confml") |
101 self.prj.create_configuration("test3.confml") |
117 self.prj.create_configuration("test3.confml") |
102 self.prj.test2_confml.create_configuration("foo/root.confml") |
118 self.prj.test2_confml.create_configuration("foo/root.confml") |
103 conf = self.prj.test2_confml.create_configuration("fii/root.confml") |
119 conf = self.prj.test2_confml.create_configuration("fii/root.confml") |
104 #self.assertEquals(conf.get_full_path(),'') |
120 conf.add_configuration(api.Configuration("confml/data.confml")) |
|
121 self.assertEquals(conf.get_full_path(),'fii/root.confml') |
|
122 self.assertEquals(conf.get_configuration("confml/data.confml").get_path(),'confml/data.confml') |
|
123 self.assertEquals(conf.get_configuration("confml/data.confml").get_full_path(),'fii/confml/data.confml') |
105 self.assertTrue(self.prj.is_configuration("test3.confml")) |
124 self.assertTrue(self.prj.is_configuration("test3.confml")) |
106 # TODO: this is not working at the moment due to performance problem in |
125 # TODO: this is not working at the moment due to performance problem in |
107 # Project.list_all_configurations() |
126 # Project.list_all_configurations() |
108 # self.assertTrue(self.prj.is_configuration("fii/root.confml")) |
127 # self.assertTrue(self.prj.is_configuration("fii/root.confml")) |
109 |
128 |
110 self.assertEquals(self.prj.list_configurations(), ["test1.confml", |
129 self.assertEquals(self.prj.list_configurations(), ["test1.confml", |
111 "test2.confml", |
130 "test2.confml", |
112 "test3.confml"]) |
131 "test3.confml"]) |
113 |
132 self.assertEquals(self.prj.list_all_configurations(), ['test1.confml', |
|
133 'test2.confml', |
|
134 'foo/root.confml', |
|
135 'fii/root.confml', |
|
136 'fii/confml/data.confml', |
|
137 'test3.confml']) |
114 self.assertEquals(self.prj.test2_confml.list_configurations(), ["foo/root.confml", |
138 self.assertEquals(self.prj.test2_confml.list_configurations(), ["foo/root.confml", |
115 "fii/root.confml",]) |
139 "fii/root.confml",]) |
|
140 self.assertEquals(self.prj.test2_confml.list_all_configurations(), ["foo/root.confml", |
|
141 "fii/root.confml", |
|
142 "fii/confml/data.confml"]) |
116 |
143 |
117 def test_create_multi_and_add_subconfigurations_and_features(self): |
144 def test_create_multi_and_add_subconfigurations_and_features(self): |
118 self.prj.create_configuration("test1.confml") |
145 self.prj.create_configuration("test1.confml") |
119 self.prj.create_configuration("test2.confml") |
146 self.prj.create_configuration("test2.confml") |
120 self.prj.create_configuration("test3.confml") |
147 self.prj.create_configuration("test3.confml") |
131 'testfea2', |
158 'testfea2', |
132 'testfea3', |
159 'testfea3', |
133 'testfea3.testfea31', |
160 'testfea3.testfea31', |
134 'testfea4']) |
161 'testfea4']) |
135 |
162 |
136 |
|
137 class TestProjectConfigurationsStorage(unittest.TestCase): |
163 class TestProjectConfigurationsStorage(unittest.TestCase): |
138 def test_create_configuration_and_store_storage(self): |
164 def test_create_configuration_and_store_storage(self): |
139 prj = api.Project(api.Storage.open("temp/testproject.pk", "w")) |
165 prj = api.Project(api.Storage.open("temp/testproject.pk", "w")) |
140 prj.create_configuration("test.confml") |
166 prj.create_configuration("test.confml") |
141 prj.close() |
167 prj.close() |
240 prj.create_configuration("foo/foo.confml") |
266 prj.create_configuration("foo/foo.confml") |
241 prj.create_configuration("foo/confml/component.confml").close() |
267 prj.create_configuration("foo/confml/component.confml").close() |
242 prj.test_confml.include_configuration("foo/foo.confml") |
268 prj.test_confml.include_configuration("foo/foo.confml") |
243 prj.test_confml.include_configuration("s60/root.confml") |
269 prj.test_confml.include_configuration("s60/root.confml") |
244 prj.test_confml.foo__foo_confml.create_configuration("data.confml") |
270 prj.test_confml.foo__foo_confml.create_configuration("data.confml") |
|
271 prj.test_confml.foo__foo_confml.add_configuration(api.Configuration("confml/test.confml")) |
245 foofea = api.Feature("foofea") |
272 foofea = api.Feature("foofea") |
246 foofea.add_feature(api.Feature("foofea_setting1")) |
273 foofea.add_feature(api.Feature("foofea_setting1")) |
247 foofea.add_feature(api.Feature("foofea_setting2")) |
274 foofea.add_feature(api.Feature("foofea_setting2")) |
248 prj.test_confml.foo__foo_confml.add_feature(foofea) |
275 prj.test_confml.foo__foo_confml.add_feature(foofea) |
249 prj.save() |
276 prj.save() |
253 res.write("foo.conf") |
280 res.write("foo.conf") |
254 res.close() |
281 res.close() |
255 res = layer.content_folder().open_resource("foobar.txt","w") |
282 res = layer.content_folder().open_resource("foobar.txt","w") |
256 res.write("foo bar") |
283 res.write("foo bar") |
257 res.close() |
284 res.close() |
258 self.assertEquals(layer.list_confml(), ['confml/component.confml', 'confml/component1.confml']) |
285 self.assertEquals(layer.list_confml(), ['confml/component.confml', 'confml/component1.confml', 'confml/test.confml']) |
259 self.assertEquals(layer.list_content(), ['content/foobar.txt']) |
286 self.assertEquals(layer.list_content(), ['content/foobar.txt']) |
260 self.assertEquals(layer.list_all_resources(), ['confml/component.confml', 'confml/component1.confml', 'content/foobar.txt']) |
287 self.assertEquals(layer.list_all_resources(), ['confml/component.confml', 'confml/component1.confml', 'confml/test.confml', 'content/foobar.txt']) |
261 self.assertEquals(foo_config.list_resources(), ['foo/foo.confml','foo/data.confml', 'foo/confml/component.confml', 'foo/confml/component1.confml', 'foo/content/foobar.txt']) |
288 self.assertEquals(foo_config.list_resources(), ['foo/foo.confml', |
|
289 'foo/data.confml', |
|
290 'foo/confml/test.confml', |
|
291 'foo/confml/component.confml', |
|
292 'foo/confml/component1.confml', |
|
293 'foo/content/foobar.txt']) |
262 self.assertEquals(prj.test_confml.list_resources(), ['test.confml', |
294 self.assertEquals(prj.test_confml.list_resources(), ['test.confml', |
263 'foo/foo.confml', |
295 'foo/foo.confml', |
264 'foo/data.confml', |
296 'foo/data.confml', |
|
297 'foo/confml/test.confml', |
265 's60/root.confml', |
298 's60/root.confml', |
266 'foo/confml/component.confml', |
299 'foo/confml/component.confml', |
267 'foo/confml/component1.confml', |
300 'foo/confml/component1.confml', |
268 'foo/content/foobar.txt']) |
301 'foo/content/foobar.txt']) |
269 |
302 |