Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import sys
00019 sys.path.insert(1,"../")
00020
00021 import OpenRTM_aist
00022 import unittest
00023
00024 from GlobalFactory import *
00025
00026 class Test:
00027 def __init__(self):
00028 pass
00029
00030 def test(self):
00031 return True
00032
00033 class TestGlobalFactory(unittest.TestCase):
00034
00035 def setUp(self):
00036 self.factory = GlobalFactory.instance()
00037 self.factory.addFactory("test",Test,OpenRTM_aist.Delete)
00038 return
00039
00040 def tearDown(self):
00041 self.factory.removeFactory("test")
00042 return
00043
00044 def test_isinstance(self):
00045 self.assertEqual(self.factory,GlobalFactory.instance())
00046
00047 def test_hasFactory(self):
00048
00049 self.assertEqual(self.factory.hasFactory("test"),True)
00050
00051 self.assertEqual(self.factory.hasFactory("testtest"),False)
00052
00053 self.assertEqual(self.factory.hasFactory(""),False)
00054 return
00055
00056 def test_getIdentifiers(self):
00057
00058 self.assertEqual(self.factory.getIdentifiers(),["test"])
00059 GlobalFactory.instance().addFactory("test2",Test,OpenRTM_aist.Delete)
00060 self.assertEqual(self.factory.getIdentifiers(),["test","test2"])
00061
00062 self.factory.removeFactory("test")
00063 self.factory.removeFactory("test2")
00064 self.assertEqual(self.factory.getIdentifiers(),[])
00065 return
00066
00067 def test_addFactory(self):
00068
00069 self.assertEqual(GlobalFactory.instance().addFactory("test",None,OpenRTM_aist.Delete),
00070 GlobalFactory.INVALID_ARG)
00071
00072
00073 self.assertEqual(GlobalFactory.instance().addFactory("test",Test,OpenRTM_aist.Delete),
00074 GlobalFactory.ALREADY_EXISTS)
00075
00076
00077 self.assertEqual(GlobalFactory.instance().addFactory("test1",Test,OpenRTM_aist.Delete),
00078 GlobalFactory.FACTORY_OK)
00079 self.factory.removeFactory("test1")
00080
00081
00082 return
00083
00084 def test_removeFactory(self):
00085
00086 self.assertEqual(self.factory.removeFactory("testtest"),
00087 GlobalFactory.NOT_FOUND)
00088
00089
00090 self.assertEqual(self.factory.removeFactory("test"),
00091 GlobalFactory.FACTORY_OK)
00092
00093
00094 self.assertEqual(self.factory.getIdentifiers(),[])
00095 return
00096
00097 def test_createObject(self):
00098
00099 self.assertEqual(self.factory.createObject("testtest"),
00100 None)
00101
00102 self.assertEqual(self.factory.createObject("test").test(),True)
00103 return
00104
00105 def test_deleteObject(self):
00106
00107 self.factory.deleteObject(self.factory.createObject("test"),"testtest")
00108
00109 self.factory.deleteObject(self.factory.createObject("test"))
00110 return
00111
00112
00113 if __name__ == '__main__':
00114 unittest.main()