test_PortAdmin.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 #
5 # \file test_PortAdmin.py
6 # \brief test for RTC's Port administration class
7 # \date $Date: 2007/09/03 $
8 # \author Shinji Kurihara
9 #
10 # Copyright (C) 2006
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 import OpenRTM_aist
23 from PortAdmin import *
24 
25 import RTC, RTC__POA
26 import OpenRTM
27 
28 from omniORB import CORBA
29 
31  def __init__(self):
32  OpenRTM_aist.PortBase.__init__(self)
33 
34  def publishInterfaces(self, prof):
35  return RTC.RTC_OK
36 
37  def subscribeInterfaces(self, prof):
38  return RTC.RTC_OK
39 
40  def unsubscribeInterfaces(self, prof):
41  return RTC.RTC_OK
42 
43  def activateInterfaces(self):
44  print "activateInterfaces"
45 
46 
48  print "deactivateInterfaces"
49 
50 
51 class TestPortAdmin(unittest.TestCase):
52  def setUp(self):
53  self._orb = CORBA.ORB_init(sys.argv)
54  self._poa = self._orb.resolve_initial_references("RootPOA")
55  self._poa._get_the_POAManager().activate()
56 
57  self._pa = PortAdmin(self._orb, self._poa)
58 
59  self._pb1 = PortBase()
60  self._pb2 = PortBase()
61 
62  self._pb1.setName("port0")
63  self._pb2.setName("port1")
64 
65  self._pa.registerPort(self._pb1)
66  self._pa.registerPort(self._pb2)
67  return
68 
69  def tearDown(self):
70  OpenRTM_aist.Manager.instance().shutdownManager()
71 
72 
74  plist = self._pa.getPortServiceList()
75 
76  prof0 = plist[0].get_port_profile()
77  self.assertEqual(prof0.name, "port0")
78 
79  prof1 = plist[1].get_port_profile()
80  self.assertEqual(prof1.name, "port1")
81  return
82 
83 
85  pprof = self._pa.getPortProfileList()
86  return
87 
88 
89  def CCCtest_getPortRef(self):
90 
91  getP = self._pa.getPortRef("")
92  self.assertEqual(CORBA.is_nil(getP), True)
93 
94  getP = self._pa.getPortRef("port1")
95  self.assertEqual(CORBA.is_nil(getP), False)
96  self.assertEqual(getP.get_port_profile().name, "port1")
97 
98  getP = self._pa.getPortRef("port0")
99  self.assertEqual(CORBA.is_nil(getP), False)
100  self.assertEqual(getP.get_port_profile().name, "port0")
101  return
102 
103 
104  def CCCtest_getPort(self):
105  pb = self._pa.getPort("port0")
106  prof = pb.get_port_profile()
107  self.assertEqual(prof.name, "port0")
108 
109  pb = self._pa.getPort("port1")
110  prof = pb.get_port_profile()
111  self.assertEqual(prof.name, "port1")
112  return
113 
114 
116  self._pa.deletePort(self._pb1)
117  plist = self._pa.getPortServiceList()
118  self.assertEqual(len(plist), 1)
119 
120  prof = plist[0].get_port_profile()
121  self.assertEqual(prof.name, "port1")
122  return
123 
124 
126  plist = self._pa.getPortServiceList()
127  self.assertEqual(len(plist), 2)
128 
129  self._pa.deletePortByName("port1")
130 
131  plist = self._pa.getPortServiceList()
132  self.assertEqual(len(plist), 1)
133  return
134 
135 
137  self._pa.activatePorts()
138  self._pa.deactivatePorts()
139  return
140 
141 
143  plist = self._pa.getPortServiceList()
144  self.assertEqual(len(plist), 2)
145 
146  self._pa.finalizePorts()
147 
148  plist = self._pa.getPortServiceList()
149  self.assertEqual(len(plist), 0)
150  return
151 
152 
153 
154 
155 if __name__ == '__main__':
156  unittest.main()
157 
def subscribeInterfaces(self, prof)
def unsubscribeInterfaces(self, prof)
def publishInterfaces(self, prof)


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