test_ManagerConfig.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- Python -*-
00003 
00004 #
00005 # \file test_ManagerConfig.py
00006 # \brief test for RTC manager configuration
00007 # \date $Date: $
00008 # \author Shinji Kurihara
00009 #
00010 # Copyright (C) 2003
00011 #     Task-intelligence Research Group,
00012 #     Intelligent Systems Research Institute,
00013 #     National Institute of
00014 #         Advanced Industrial Science and Technology (AIST), Japan
00015 #     All rights reserved.
00016 #
00017 
00018 import sys
00019 sys.path.insert(1,"../")
00020 
00021 import unittest
00022 
00023 import OpenRTM_aist
00024 
00025 from ManagerConfig import *
00026 
00027 configsample_spec = ["implementation_id", "ConfigSample",
00028            "type_name",         "ConfigSample",
00029            "description",       "Configuration example component",
00030            "version",           "1.0",
00031            "vendor",            "Shinji Kurihara, AIST",
00032            "category",          "example",
00033            "activity_type",     "DataFlowComponent",
00034            "max_instance",      "10",
00035            "language",          "C++",
00036            "lang_type",         "compile",
00037            # Configuration variables
00038            "conf.default.int_param0", "0",
00039            "conf.default.int_param1", "1",
00040            "conf.default.double_param0", "0.11",
00041            "conf.default.double_param1", "9.9",
00042            "conf.default.str_param0", "hoge",
00043            "conf.default.str_param1", "dara",
00044            "conf.default.vector_param0", "0.0,1.0,2.0,3.0,4.0",
00045            ""]
00046 
00047 class TestManagerConfig(unittest.TestCase) :
00048   
00049   def setUp(self):
00050     argv = (sys.argv[0], "-f", "./rtc.conf")
00051     self.mgrConf = ManagerConfig(argv)
00052 
00053 
00054   def tearDown(self):
00055     OpenRTM_aist.Manager.instance().shutdownManager()
00056     return
00057   
00058   def test_configure(self):
00059     prop = OpenRTM_aist.Properties(defaults_str=configsample_spec)
00060     self.mgrConf.configure(prop)
00061     self.assertEqual(prop.getProperty("type_name"),"ConfigSample","Result failed.")
00062 
00063     
00064   def test_parseArgs(self):
00065     argv = (sys.argv[0], "-f", "./rtc.conf")
00066     self.mgrConf.parseArgs(argv)
00067 
00068     # Failed Pattern
00069     # argv = (sys.argv[0], "-c", "./rtc.conf")
00070     # self.mgrConf.parseArgs(3,argv)
00071     
00072 
00073   def test_findConfigFile(self):
00074     self.assertEqual(self.mgrConf.findConfigFile(),True,"Result failed.")
00075 
00076 
00077   def test_setSystemInformation(self):
00078     prop = OpenRTM_aist.Properties(defaults_str=configsample_spec)
00079     # Failed Pattern
00080     # self.assertEqual(prop.getProperty("manager.os.name"),"Linux","Result failed.")
00081 
00082     prop = self.mgrConf.setSystemInformation(prop)
00083     self.assertEqual(prop.getProperty("manager.os.name"),"Linux","Result failed.")
00084     #self.assertEqual(prop.getProperty("manager.os.name"),"Windows","Result failed.")
00085 
00086 
00087   def test_fileExist(self):
00088     self.assertEqual(self.mgrConf.fileExist("rtc.conf"),True,"Result failed.")
00089     self.assertEqual(self.mgrConf.fileExist("./rtc.conf"),True,"Result failed.")
00090 
00091     # Failed Pattern
00092     # self.assertEqual(self.mgrConf.fileExist("../rtc.conf"),True,"Result failed.")
00093     
00094 
00095 ############### test #################
00096 if __name__ == '__main__':
00097         unittest.main()
00098 
00099 


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28