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 
test_PortAdmin.TestPortAdmin.CCCtest_deletePortByName
def CCCtest_deletePortByName(self)
Definition: test_PortAdmin.py:125
test_PortAdmin.TestPortAdmin._orb
_orb
Definition: test_PortAdmin.py:53
test_PortAdmin.TestPortAdmin.CCCtest_getPortRef
def CCCtest_getPortRef(self)
Definition: test_PortAdmin.py:89
test_PortAdmin.TestPortAdmin._pb1
_pb1
Definition: test_PortAdmin.py:59
test_PortAdmin.PortBase.__init__
def __init__(self)
Definition: test_PortAdmin.py:31
test_PortAdmin.TestPortAdmin
Definition: test_PortAdmin.py:51
test_PortAdmin.TestPortAdmin._poa
_poa
Definition: test_PortAdmin.py:54
test_PortAdmin.TestPortAdmin.CCCtest_deletePort
def CCCtest_deletePort(self)
Definition: test_PortAdmin.py:115
test_PortAdmin.TestPortAdmin.CCCtest_getPort
def CCCtest_getPort(self)
Definition: test_PortAdmin.py:104
test_PortAdmin.PortBase.deactivateInterfaces
def deactivateInterfaces(self)
Definition: test_PortAdmin.py:47
test_PortAdmin.TestPortAdmin.tearDown
def tearDown(self)
Definition: test_PortAdmin.py:69
test_PortAdmin.TestPortAdmin.CCCtest_finalizePorts
def CCCtest_finalizePorts(self)
Definition: test_PortAdmin.py:142
test_PortAdmin.TestPortAdmin.CCCtest_activatePorts
def CCCtest_activatePorts(self)
Definition: test_PortAdmin.py:136
test_PortAdmin.PortBase.activateInterfaces
def activateInterfaces(self)
Definition: test_PortAdmin.py:43
test_PortAdmin.TestPortAdmin._pa
_pa
Definition: test_PortAdmin.py:57
test_PortAdmin.TestPortAdmin._pb2
_pb2
Definition: test_PortAdmin.py:60
test_PortAdmin.PortBase.publishInterfaces
def publishInterfaces(self, prof)
Publish interface information.
Definition: test_PortAdmin.py:34
test_PortAdmin.TestPortAdmin.test_getPortProfileList
def test_getPortProfileList(self)
Definition: test_PortAdmin.py:84
test_PortAdmin.PortBase.subscribeInterfaces
def subscribeInterfaces(self, prof)
Publish interface information.
Definition: test_PortAdmin.py:37
OpenRTM_aist.PortBase.PortBase
Port base class.
Definition: PortBase.py:115
test_PortAdmin.PortBase
Definition: test_PortAdmin.py:30
test_PortAdmin.TestPortAdmin.test_getPortServiceList
def test_getPortServiceList(self)
Definition: test_PortAdmin.py:73
test_PortAdmin.PortBase.unsubscribeInterfaces
def unsubscribeInterfaces(self, prof)
Disconnect interface connection.
Definition: test_PortAdmin.py:40
test_PortAdmin.TestPortAdmin.setUp
def setUp(self)
Definition: test_PortAdmin.py:52
PortAdmin


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Mon Apr 21 2025 02:45:07