test_ManagerConfig.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 #
5 # \file test_ManagerConfig.py
6 # \brief test for RTC manager configuration
7 # \date $Date: $
8 # \author Shinji Kurihara
9 #
10 # Copyright (C) 2003
11 # Task-intelligence Research Group,
12 # Intelligent Systems Research Institute,
13 # National Institute of
14 # Advanced Industrial Science and Technology (AIST), Japan
15 # All rights reserved.
16 #
17 
18 import sys
19 sys.path.insert(1,"../")
20 
21 import unittest
22 
23 import OpenRTM_aist
24 
25 from ManagerConfig import *
26 
27 configsample_spec = ["implementation_id", "ConfigSample",
28  "type_name", "ConfigSample",
29  "description", "Configuration example component",
30  "version", "1.0",
31  "vendor", "Shinji Kurihara, AIST",
32  "category", "example",
33  "activity_type", "DataFlowComponent",
34  "max_instance", "10",
35  "language", "C++",
36  "lang_type", "compile",
37  # Configuration variables
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",
45  ""]
46 
47 class TestManagerConfig(unittest.TestCase) :
48 
49  def setUp(self):
50  argv = (sys.argv[0], "-f", "./rtc.conf")
51  self.mgrConf = ManagerConfig(argv)
52 
53 
54  def tearDown(self):
55  OpenRTM_aist.Manager.instance().shutdownManager()
56  return
57 
58  def test_configure(self):
59  prop = OpenRTM_aist.Properties(defaults_str=configsample_spec)
60  self.mgrConf.configure(prop)
61  self.assertEqual(prop.getProperty("type_name"),"ConfigSample","Result failed.")
62 
63 
64  def test_parseArgs(self):
65  argv = (sys.argv[0], "-f", "./rtc.conf")
66  self.mgrConf.parseArgs(argv)
67 
68  # Failed Pattern
69  # argv = (sys.argv[0], "-c", "./rtc.conf")
70  # self.mgrConf.parseArgs(3,argv)
71 
72 
74  self.assertEqual(self.mgrConf.findConfigFile(),True,"Result failed.")
75 
76 
78  prop = OpenRTM_aist.Properties(defaults_str=configsample_spec)
79  # Failed Pattern
80  # self.assertEqual(prop.getProperty("manager.os.name"),"Linux","Result failed.")
81 
82  prop = self.mgrConf.setSystemInformation(prop)
83  self.assertEqual(prop.getProperty("manager.os.name"),"Linux","Result failed.")
84  #self.assertEqual(prop.getProperty("manager.os.name"),"Windows","Result failed.")
85 
86 
87  def test_fileExist(self):
88  self.assertEqual(self.mgrConf.fileExist("rtc.conf"),True,"Result failed.")
89  self.assertEqual(self.mgrConf.fileExist("./rtc.conf"),True,"Result failed.")
90 
91  # Failed Pattern
92  # self.assertEqual(self.mgrConf.fileExist("../rtc.conf"),True,"Result failed.")
93 
94 
95 ############### test #################
96 if __name__ == '__main__':
97  unittest.main()
98 
99 
The Properties class represents a persistent set of properties.
Definition: Properties.py:83


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34