19 sys.path.insert(1,
"../")
23 from Properties
import *
27 configsample_spec = [
"implementation_id",
"ConfigSample",
28 "type_name",
"ConfigSample",
29 "description",
"Configuration example component",
31 "vendor",
"Shinji Kurihara, AIST",
32 "category",
"example",
33 "activity_type",
"DataFlowComponent",
36 "lang_type",
"compile",
38 "conf.default.int_param0",
"0",
39 "conf.default.int_param1",
"1",
40 "conf.default.double_param0",
"0.11",
41 "conf.default.double_param1",
"9.9",
42 "conf.default.str_param0",
"hoge",
43 "conf.default.str_param1",
"dara",
44 "conf.default.vector_param0",
"0.0,1.0,2.0,3.0,4.0",
54 OpenRTM_aist.Manager.instance().shutdownManager()
58 self.assertEqual(self.
prop.getName(),
"",
"Result failed.")
62 self.assertEqual(self.
prop.getValue(),
"",
"Result failed.")
66 self.assertEqual(self.
prop.getDefaultValue(),
"",
"Result failed.")
74 self.assertEqual(self.
prop.getLeaf()[0].getName(),
"implementation_id",
"Result failed.")
75 self.assertEqual(self.
prop.getLeaf()[1].getName(),
"type_name",
"Result failed.")
76 self.assertEqual(self.
prop.getLeaf()[2].getName(),
"description",
"Result failed.")
77 self.assertEqual(self.
prop.getLeaf()[3].getName(),
"version",
"Result failed.")
78 self.assertEqual(self.
prop.getLeaf()[4].getName(),
"vendor",
"Result failed.")
79 self.assertEqual(self.
prop.getLeaf()[5].getName(),
"category",
"Result failed.")
80 self.assertEqual(self.
prop.getLeaf()[6].getName(),
"activity_type",
"Result failed.")
81 self.assertEqual(self.
prop.getLeaf()[7].getName(),
"max_instance",
"Result failed.")
82 self.assertEqual(self.
prop.getLeaf()[8].getName(),
"language",
"Result failed.")
83 self.assertEqual(self.
prop.getLeaf()[9].getName(),
"lang_type",
"Result failed.")
84 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[0].getName(),
"int_param0",
"Result failed.")
85 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[1].getName(),
"int_param1",
"Result failed.")
86 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[2].getName(),
"double_param0",
"Result failed.")
87 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[3].getName(),
"double_param1",
"Result failed.")
88 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[4].getName(),
"str_param0",
"Result failed.")
89 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[5].getName(),
"str_param1",
"Result failed.")
90 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[6].getName(),
"vector_param0",
"Result failed.")
97 self.assertEqual(self.
prop.getRoot(),
None,
"Result failed.")
98 self.assertEqual(self.
prop.getLeaf()[10].getRoot().getRoot(),
None,
"Result failed.")
99 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getRoot().getName(),
"conf",
"Result failed.")
100 self.assertEqual(self.
prop.getLeaf()[10].getLeaf()[0].getLeaf()[0].getRoot().getName(),
"default",
"Result failed.")
104 self.assertEqual(self.
prop.getProperty(
"implementation_id"),
"ConfigSample",
"Result failed.")
105 self.assertEqual(self.
prop.getProperty(
"type_name"),
"ConfigSample",
"Result failed.")
106 self.assertEqual(self.
prop.getProperty(
"description"),
"Configuration example component",
"Result failed.")
107 self.assertEqual(self.
prop.getProperty(
"version"),
"1.0",
"Result failed.")
108 self.assertEqual(self.
prop.getProperty(
"vendor"),
"Shinji Kurihara, AIST",
"Result failed.")
109 self.assertEqual(self.
prop.getProperty(
"category"),
"example",
"Result failed.")
110 self.assertEqual(self.
prop.getProperty(
"activity_type"),
"DataFlowComponent",
"Result failed.")
111 self.assertEqual(self.
prop.getProperty(
"max_instance"),
"10",
"Result failed.")
112 self.assertEqual(self.
prop.getProperty(
"language"),
"C++",
"Result failed.")
113 self.assertEqual(self.
prop.getProperty(
"lang_type"),
"compile",
"Result failed.")
114 self.assertEqual(self.
prop.getProperty(
"conf.default.int_param0"),
"0",
"Result failed.")
115 self.assertEqual(self.
prop.getProperty(
"conf.default.int_param1"),
"1",
"Result failed.")
116 self.assertEqual(self.
prop.getProperty(
"conf.default.double_param0"),
"0.11",
"Result failed.")
117 self.assertEqual(self.
prop.getProperty(
"conf.default.double_param1"),
"9.9",
"Result failed.")
118 self.assertEqual(self.
prop.getProperty(
"conf.default.str_param0"),
"hoge",
"Result failed.")
119 self.assertEqual(self.
prop.getProperty(
"conf.default.str_param1"),
"dara",
"Result failed.")
120 self.assertEqual(self.
prop.getProperty(
"conf.default.vector_param0"),
"0.0,1.0,2.0,3.0,4.0",
"Result failed.")
133 self.assertEqual(self.
prop.getDefault(
"implementation_id"),
"ConfigSample",
"Result failed.")
134 self.assertEqual(self.
prop.getDefault(
"type_name"),
"ConfigSample",
"Result failed.")
135 self.assertEqual(self.
prop.getDefault(
"description"),
"Configuration example component",
"Result failed.")
136 self.assertEqual(self.
prop.getDefault(
"version"),
"1.0",
"Result failed.")
137 self.assertEqual(self.
prop.getDefault(
"vendor"),
"Shinji Kurihara, AIST",
"Result failed.")
138 self.assertEqual(self.
prop.getDefault(
"category"),
"example",
"Result failed.")
139 self.assertEqual(self.
prop.getDefault(
"activity_type"),
"DataFlowComponent",
"Result failed.")
140 self.assertEqual(self.
prop.getDefault(
"max_instance"),
"10",
"Result failed.")
141 self.assertEqual(self.
prop.getDefault(
"language"),
"C++",
"Result failed.")
142 self.assertEqual(self.
prop.getDefault(
"lang_type"),
"compile",
"Result failed.")
143 self.assertEqual(self.
prop.getDefault(
"conf.default.int_param0"),
"0",
"Result failed.")
144 self.assertEqual(self.
prop.getDefault(
"conf.default.int_param1"),
"1",
"Result failed.")
145 self.assertEqual(self.
prop.getDefault(
"conf.default.double_param0"),
"0.11",
"Result failed.")
146 self.assertEqual(self.
prop.getDefault(
"conf.default.double_param1"),
"9.9",
"Result failed.")
147 self.assertEqual(self.
prop.getDefault(
"conf.default.str_param0"),
"hoge",
"Result failed.")
148 self.assertEqual(self.
prop.getDefault(
"conf.default.str_param1"),
"dara",
"Result failed.")
149 self.assertEqual(self.
prop.getDefault(
"conf.default.vector_param0"),
"0.0,1.0,2.0,3.0,4.0",
"Result failed.")
153 self.
prop.setProperty(
"implementation_id",
"ConfigSample_test")
154 self.
prop.setProperty(
"type_name",
"ConfigSample_test")
155 self.
prop.setProperty(
"description",
"Configuration example component test")
156 self.
prop.setProperty(
"version",
"2.0")
157 self.
prop.setProperty(
"vendor",
"Shinji Kurihara")
158 self.
prop.setProperty(
"category",
"example_test")
159 self.
prop.setProperty(
"activity_type",
"DataFlowComponent")
160 self.
prop.setProperty(
"max_instance",
"1")
161 self.
prop.setProperty(
"language",
"C++")
162 self.
prop.setProperty(
"lang_type",
"compile")
163 self.
prop.setProperty(
"conf.default.int_param0",
"111")
164 self.
prop.setProperty(
"conf.default.int_param1",
"222")
165 self.
prop.setProperty(
"conf.default.double_param0",
"2.22")
166 self.
prop.setProperty(
"conf.default.double_param1",
"9.99")
167 self.
prop.setProperty(
"conf.default.str_param0",
"hogehoge")
168 self.
prop.setProperty(
"conf.default.str_param1",
"daradara")
169 self.
prop.setProperty(
"conf.default.vector_param0",
"0.0,1.1,2.2,3.3,4.4")
171 self.assertEqual(self.
prop.getProperty(
"implementation_id"),
"ConfigSample_test",
"Result failed.")
172 self.assertEqual(self.
prop.getProperty(
"type_name"),
"ConfigSample_test",
"Result failed.")
173 self.assertEqual(self.
prop.getProperty(
"description"),
"Configuration example component test",
"Result failed.")
174 self.assertEqual(self.
prop.getProperty(
"version"),
"2.0",
"Result failed.")
175 self.assertEqual(self.
prop.getProperty(
"vendor"),
"Shinji Kurihara",
"Result failed.")
176 self.assertEqual(self.
prop.getProperty(
"category"),
"example_test",
"Result failed.")
177 self.assertEqual(self.
prop.getProperty(
"activity_type"),
"DataFlowComponent",
"Result failed.")
178 self.assertEqual(self.
prop.getProperty(
"max_instance"),
"1",
"Result failed.")
179 self.assertEqual(self.
prop.getProperty(
"language"),
"C++",
"Result failed.")
180 self.assertEqual(self.
prop.getProperty(
"lang_type"),
"compile",
"Result failed.")
181 self.assertEqual(self.
prop.getProperty(
"conf.default.int_param0"),
"111",
"Result failed.")
182 self.assertEqual(self.
prop.getProperty(
"conf.default.int_param1"),
"222",
"Result failed.")
183 self.assertEqual(self.
prop.getProperty(
"conf.default.double_param0"),
"2.22",
"Result failed.")
184 self.assertEqual(self.
prop.getProperty(
"conf.default.double_param1"),
"9.99",
"Result failed.")
185 self.assertEqual(self.
prop.getProperty(
"conf.default.str_param0"),
"hogehoge",
"Result failed.")
186 self.assertEqual(self.
prop.getProperty(
"conf.default.str_param1"),
"daradara",
"Result failed.")
187 self.assertEqual(self.
prop.getProperty(
"conf.default.vector_param0"),
"0.0,1.1,2.2,3.3,4.4",
"Result failed.")
191 self.
prop.setDefault(
"implementation_id",
"ConfigSample")
192 self.
prop.setDefault(
"type_name",
"ConfigSample")
193 self.
prop.setDefault(
"description",
"Configuration example component")
194 self.
prop.setDefault(
"version",
"1.0")
195 self.
prop.setDefault(
"vendor",
"Shinji Kurihara")
196 self.
prop.setDefault(
"category",
"example")
197 self.
prop.setDefault(
"activity_type",
"DataFlowComponent")
198 self.
prop.setDefault(
"max_instance",
"10")
199 self.
prop.setDefault(
"language",
"C++")
200 self.
prop.setDefault(
"lang_type",
"compile")
201 self.
prop.setDefault(
"conf.default.int_param0",
"0")
202 self.
prop.setDefault(
"conf.default.int_param1",
"1")
203 self.
prop.setDefault(
"conf.default.double_param0",
"0.11")
204 self.
prop.setDefault(
"conf.default.double_param1",
"9.9")
205 self.
prop.setDefault(
"conf.default.str_param0",
"hoge")
206 self.
prop.setDefault(
"conf.default.str_param1",
"dara")
207 self.
prop.setDefault(
"conf.default.vector_param0",
"0.0,1.0,2.0,3.0,4.0")
209 self.assertEqual(self.
prop.getDefault(
"implementation_id"),
"ConfigSample",
"Result failed.")
210 self.assertEqual(self.
prop.getDefault(
"type_name"),
"ConfigSample",
"Result failed.")
211 self.assertEqual(self.
prop.getDefault(
"description"),
"Configuration example component",
"Result failed.")
212 self.assertEqual(self.
prop.getDefault(
"version"),
"1.0",
"Result failed.")
213 self.assertEqual(self.
prop.getDefault(
"vendor"),
"Shinji Kurihara",
"Result failed.")
214 self.assertEqual(self.
prop.getDefault(
"category"),
"example",
"Result failed.")
215 self.assertEqual(self.
prop.getDefault(
"activity_type"),
"DataFlowComponent",
"Result failed.")
216 self.assertEqual(self.
prop.getDefault(
"max_instance"),
"10",
"Result failed.")
217 self.assertEqual(self.
prop.getDefault(
"language"),
"C++",
"Result failed.")
218 self.assertEqual(self.
prop.getDefault(
"lang_type"),
"compile",
"Result failed.")
219 self.assertEqual(self.
prop.getDefault(
"conf.default.int_param0"),
"0",
"Result failed.")
220 self.assertEqual(self.
prop.getDefault(
"conf.default.int_param1"),
"1",
"Result failed.")
221 self.assertEqual(self.
prop.getDefault(
"conf.default.double_param0"),
"0.11",
"Result failed.")
222 self.assertEqual(self.
prop.getDefault(
"conf.default.double_param1"),
"9.9",
"Result failed.")
223 self.assertEqual(self.
prop.getDefault(
"conf.default.str_param0"),
"hoge",
"Result failed.")
224 self.assertEqual(self.
prop.getDefault(
"conf.default.str_param1"),
"dara",
"Result failed.")
225 self.assertEqual(self.
prop.getDefault(
"conf.default.vector_param0"),
"0.0,1.0,2.0,3.0,4.0",
"Result failed.")
229 self.
prop.setDefaults(configsample_spec)
231 self.assertEqual(self.
prop.getDefault(
"implementation_id"),
"ConfigSample",
"Result failed.")
232 self.assertEqual(self.
prop.getDefault(
"type_name"),
"ConfigSample",
"Result failed.")
233 self.assertEqual(self.
prop.getDefault(
"description"),
"Configuration example component",
"Result failed.")
234 self.assertEqual(self.
prop.getDefault(
"version"),
"1.0",
"Result failed.")
235 self.assertEqual(self.
prop.getDefault(
"vendor"),
"Shinji Kurihara, AIST",
"Result failed.")
236 self.assertEqual(self.
prop.getDefault(
"category"),
"example",
"Result failed.")
237 self.assertEqual(self.
prop.getDefault(
"activity_type"),
"DataFlowComponent",
"Result failed.")
238 self.assertEqual(self.
prop.getDefault(
"max_instance"),
"10",
"Result failed.")
239 self.assertEqual(self.
prop.getDefault(
"language"),
"C++",
"Result failed.")
240 self.assertEqual(self.
prop.getDefault(
"lang_type"),
"compile",
"Result failed.")
241 self.assertEqual(self.
prop.getDefault(
"conf.default.int_param0"),
"0",
"Result failed.")
242 self.assertEqual(self.
prop.getDefault(
"conf.default.int_param1"),
"1",
"Result failed.")
243 self.assertEqual(self.
prop.getDefault(
"conf.default.double_param0"),
"0.11",
"Result failed.")
244 self.assertEqual(self.
prop.getDefault(
"conf.default.double_param1"),
"9.9",
"Result failed.")
245 self.assertEqual(self.
prop.getDefault(
"conf.default.str_param0"),
"hoge",
"Result failed.")
246 self.assertEqual(self.
prop.getDefault(
"conf.default.str_param1"),
"dara",
"Result failed.")
247 self.assertEqual(self.
prop.getDefault(
"conf.default.vector_param0"),
"0.0,1.0,2.0,3.0,4.0",
"Result failed.")
256 fp = file(
"configsample.conf",
"r") 258 self.assertEqual(self.prop.getProperty("conf.mode0.int_param0"),
"12345",
"Result failed.")
259 self.assertEqual(self.prop.getProperty(
"conf.mode0.int_param1"),
"98765",
"Result failed.")
260 self.assertEqual(self.prop.getProperty(
"conf.mode0.double_param0"),
"3.141592653589793238462643383279")
261 self.assertEqual(self.prop.getProperty(
"conf.mode0.double_param1"),
"2.718281828459045235360287471352",
"Result failed.")
262 self.assertEqual(self.prop.getProperty(
"conf.mode0.str_param0"),
"bar",
"Result failed.")
263 self.assertEqual(self.prop.getProperty(
"conf.mode0.str_param1"),
"foo",
"Result failed.")
264 self.assertEqual(self.prop.getProperty(
"conf.mode0.vector_param0"),
"0.0,0.1,0.2,0.3,0.4",
"Result failed.")
268 fp = file(
"test_save.data",
"w")
269 self.
prop.save(fp,
"test Properties")
273 fp = file(
"test_store.data",
"w")
274 self.
prop.store(fp,
"test Properties")
278 keys = self.
prop.propertyNames()
279 self.assertEqual(keys[0],
"implementation_id",
"Result failed.")
280 self.assertEqual(keys[1],
"type_name",
"Result failed.")
281 self.assertEqual(keys[2],
"description",
"Result failed.")
282 self.assertEqual(keys[3],
"version",
"Result failed.")
283 self.assertEqual(keys[4],
"vendor",
"Result failed.")
284 self.assertEqual(keys[5],
"category",
"Result failed.")
285 self.assertEqual(keys[6],
"activity_type",
"Result failed.")
286 self.assertEqual(keys[7],
"max_instance",
"Result failed.")
287 self.assertEqual(keys[8],
"language",
"Result failed.")
288 self.assertEqual(keys[9],
"lang_type",
"Result failed.")
289 self.assertEqual(keys[10],
"conf.default.int_param0",
"Result failed.")
290 self.assertEqual(keys[11],
"conf.default.int_param1",
"Result failed.")
291 self.assertEqual(keys[12],
"conf.default.double_param0",
"Result failed.")
292 self.assertEqual(keys[13],
"conf.default.double_param1",
"Result failed.")
293 self.assertEqual(keys[14],
"conf.default.str_param0",
"Result failed.")
294 self.assertEqual(keys[15],
"conf.default.str_param1",
"Result failed.")
295 self.assertEqual(keys[16],
"conf.default.vector_param0",
"Result failed.")
299 self.assertEqual(self.
prop.size(),17,
"Result failed.")
303 self.assertEqual(self.
prop.findNode(
"implementation_id").getDefaultValue(),
"ConfigSample",
"Result failed.")
306 self.assertEqual(self.
prop.getNode(
"implementation_id").getDefaultValue(),
"ConfigSample",
"Result failed.")
307 self.assertEqual(self.
prop.getNode(
"type_name").getDefaultValue(),
"ConfigSample",
"Result failed.")
308 self.assertEqual(self.
prop.getNode(
"description").getDefaultValue(),
"Configuration example component",
"Result failed.")
309 self.assertEqual(self.
prop.getNode(
"version").getDefaultValue(),
"1.0",
"Result failed.")
310 self.assertEqual(self.
prop.getNode(
"vendor").getDefaultValue(),
"Shinji Kurihara, AIST",
"Result failed.")
311 self.assertEqual(self.
prop.getNode(
"category").getDefaultValue(),
"example",
"Result failed.")
312 self.assertEqual(self.
prop.getNode(
"activity_type").getDefaultValue(),
"DataFlowComponent",
"Result failed.")
313 self.assertEqual(self.
prop.getNode(
"max_instance").getDefaultValue(),
"10",
"Result failed.")
314 self.assertEqual(self.
prop.getNode(
"language").getDefaultValue(),
"C++",
"Result failed.")
315 self.assertEqual(self.
prop.getNode(
"lang_type").getDefaultValue(),
"compile",
"Result failed.")
316 self.assertEqual(self.
prop.getNode(
"conf.default.int_param0").getDefaultValue(),
"0",
"Result failed.")
317 self.assertEqual(self.
prop.getNode(
"conf.default.int_param1").getDefaultValue(),
"1",
"Result failed.")
318 self.assertEqual(self.
prop.getNode(
"conf.default.double_param0").getDefaultValue(),
"0.11",
"Result failed.")
319 self.assertEqual(self.
prop.getNode(
"conf.default.double_param1").getDefaultValue(),
"9.9",
"Result failed.")
320 self.assertEqual(self.
prop.getNode(
"conf.default.str_param0").getDefaultValue(),
"hoge",
"Result failed.")
321 self.assertEqual(self.
prop.getNode(
"conf.default.str_param1").getDefaultValue(),
"dara",
"Result failed.")
322 self.assertEqual(self.
prop.getNode(
"conf.default.vector_param0").getDefaultValue(),
"0.0,1.0,2.0,3.0,4.0",
"Result failed.")
326 self.assertEqual(self.
prop.createNode(
"conf.default.int_param.0"),
True,
"Result failed.")
327 self.assertEqual(self.
prop.createNode(
"conf.add.int_param1"),
True,
"Result failed.")
328 self.assertEqual(len(self.
prop.getNode(
"conf.default").leaf), 8,
"Result failed.")
329 self.assertEqual(len(self.
prop.getNode(
"conf.add").leaf), 1,
"Result failed.")
333 node = self.
prop.getNode(
"conf.default")
334 node.removeNode(
"int_param0")
335 self.assertEqual( len(self.
prop.getNode(
"conf.default").leaf),6,
"Result failed.")
337 node = self.
prop.getNode(
"conf")
338 node.removeNode(
"default")
339 self.assertEqual( len(self.
prop.getNode(
"conf").leaf),0,
"Result failed.")
343 node = self.
prop.getNode(
"conf")
344 self.assertEqual(len(node.hasKey(
"default").leaf),7,
"Result failed.")
346 self.assertEqual(self.
prop.hasKey(
"default"),
None,
"Result failed.")
351 self.assertEqual(self.
prop.getProperty(
"implementation_id"),
"",
"Result failed.")
360 self.
prop.splitKeyValue(
"key:value",key,val)
361 self.assertEqual(key[0],
"key")
362 self.assertEqual(val[0],
"value")
367 self.
prop.
split(
"test.split,hoge",
".",val)
369 self.assertEqual(val, [
"test",
"split,hoge"])
373 self.
prop.mergeProperties(self.
prop)
374 self.assertEqual(self.
prop.getProperty(
"implementation_id"),
"ConfigSample",
"Result failed.")
383 if __name__ ==
'__main__':
def test_setProperty(self)
def split(input, delimiter)
Split string by delimiter.
def test_getDefault(self)
def test_propertyNames(self)
def test_mergeProperties(self)
def test_getDefaultValue(self)
def test_createNode(self)
def test_removeNode(self)
def clear(seq)
Erase all the elements of the CORBA sequence.
def test_getProperty(self)
def test_splitKeyValue(self)
def test_setDefaults(self)
def test_setDefault(self)