test_SdoServiceAdmin.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 
4 
15 
16 import sys
17 sys.path.insert(1, "../")
18 
19 import unittest
20 from SdoServiceAdmin import *
21 import OpenRTM_aist
22 import SDOPackage,SDOPackage__POA
23 from omniORB import CORBA, PortableServer
24 from omniORB import any
25 
26 
28  def __init__(self):
29  self._orb = CORBA.ORB_init()
30  self._poa = self._orb.resolve_initial_references("RootPOA")
31  OpenRTM_aist.RTObject_impl.__init__(self, orb=self._orb, poa=self._poa)
32  pass
33 
34 
35 class SDOServiceMock(SDOPackage__POA.SDOService):
36  def __init__(self):
37  pass
38 
39 class MockSdoServiceConsumer(OpenRTM_aist.SdoServiceConsumerBase):
40  """
41  """
42 
43  def __init__(self):
44  OpenRTM_aist.SdoServiceConsumerBase.__init__(self)
45  return
46 
47  def reinit(self, profile):
48  pass
49 
50  def getProfile(self):
51  any_val = any.to_any("3.14159")
52  nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
53  sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
54  return sprof
55 
56 
57 class TestListener(unittest.TestCase):
58  def setUp(self):
59  return
60 
61 
62  def tearDown(self):
63  OpenRTM_aist.Manager.instance().shutdownManager()
64  return
65 
66 
68  sdoadmin = SdoServiceAdmin(MockRTC())
69  self.assertEqual(sdoadmin.addSdoServiceConsumerFactory(),False)
70  return
71 
72 
74  sdoadmin = SdoServiceAdmin(MockRTC())
75  self.assertEqual(sdoadmin.removeSdoServiceConsumerFactory(),False)
76  return
77 
78 
80  any_val = any.to_any("3.14159")
81  nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
82  sprof = SDOPackage.ServiceProfile("ID 0","INTERFACE_TYPE",[nv],SDOServiceMock())
83  sdoadmin = SdoServiceAdmin(MockRTC())
84  self.assertEqual(sdoadmin.addSdoServiceConsumer(sprof),False)
85  return
86 
87 
89  any_val = any.to_any("3.14159")
90  nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
91  sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
92  sdoadmin = SdoServiceAdmin(MockRTC())
93  self.assertEqual(sdoadmin.addSdoServiceConsumer(sprof),False)
94  sdoadmin._consumers.append(MockSdoServiceConsumer())
95  self.assertEqual(sdoadmin.removeSdoServiceConsumer("test id"),True)
96  self.assertEqual(sdoadmin.addSdoServiceConsumer(sprof),False)
97  sdoadmin._consumers.append(MockSdoServiceConsumer())
98  self.assertEqual(sdoadmin.removeSdoServiceConsumer("test id2"),False)
99  return
100 
101 
103  sdoadmin = SdoServiceAdmin(MockRTC())
104  any_val = any.to_any("3.14159")
105  nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
106  sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
107  self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),True)
108  sdoadmin._allConsumerAllowed = False
109  self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),False)
110  sdoadmin._consumerTypes = ["type0","type1","type2","INTERFACE_TYPE"]
111  self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),True)
112  sdoadmin._consumerTypes = ["type0","type1","type2"]
113  self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),False)
114  return
115 
116 
118  factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
119  factory.addFactory("test_factory",OpenRTM_aist.SdoServiceConsumerBase,OpenRTM_aist.Delete)
120  sdoadmin = SdoServiceAdmin(MockRTC())
121  any_val = any.to_any("3.14159")
122  nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
123  sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
124  self.assertEqual(sdoadmin.isExistingConsumerType(sprof),False)
125  factory.addFactory("INTERFACE_TYPE",OpenRTM_aist.SdoServiceConsumerBase,OpenRTM_aist.Delete)
126  self.assertEqual(sdoadmin.isExistingConsumerType(sprof),True)
127  return
128 
129 
130  def test_getUUID(self):
131  sdoadmin = SdoServiceAdmin(MockRTC())
132  self.assertNotEqual(sdoadmin.getUUID(),"")
133  self.assertNotEqual(sdoadmin.getUUID(),None)
134  return
135 
136 
137 
138 if __name__ == '__main__':
139  unittest.main()


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Feb 28 2022 23:01:07