test_OutPort.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 #
5 # \file test_OutPort.py
6 # \brief test for OutPort class
7 # \date $Date: 2007/09/19$
8 # \author Shinji Kurihara
9 #
10 # Copyright (C) 2006
11 # Noriaki Ando
12 # Task-intelligence Research Group,
13 # Intelligent Systems Research Institute,
14 # National Institute of
15 # Advanced Industrial Science and Technology (AIST), Japan
16 # All rights reserved.
17 #
18 
19 import sys
20 sys.path.insert(1,"../")
21 
22 from omniORB import *
23 from omniORB import any
24 
25 import unittest
26 from OutPort import *
27 
28 import RTC, RTC__POA
29 
30 import OpenRTM_aist
31 
32 class OnRWTest:
33  def __init__(self):
34  pass
35 
36  def echo(self, value=None):
37  print("OnRW Called")
38 
40  def __init__(self):
41  pass
42 
43  def echo(self, value=None):
44  print("OnRWConvert Called")
45  return value
46 
48  def write(self, data):
49  self._data = data
50  return OpenRTM_aist.DataPortStatus.PORT_OK
51 
52  def read(self, data):
53  data[0] = self._data
54  return True
55 
56 
57 class TestOutPort(unittest.TestCase):
58  def setUp(self):
59  OpenRTM_aist.Manager.init(sys.argv)
60  self._op = OutPort("out", RTC.TimedLong(RTC.Time(0,0), 0))
61  return
62 
63  def tearDown(self):
64  OpenRTM_aist.Manager.instance().shutdownManager()
65  return
66 
67  def test_write(self):
68  self.assertEqual(self._op.write(RTC.TimedLong(RTC.Time(0,0), 123)), True)
70  self._op._connectors = [self._connector]
71  self.assertEqual(self._op.write(RTC.TimedLong(RTC.Time(0,0), 123)), True)
72  read_data = [RTC.TimedLong(RTC.Time(0,0), 0)]
73  self._connector.read(read_data)
74  self.assertEqual(read_data[0].data,123)
75  return
76 
77  def test_OnWrite(self):
78  self._connector = ConnectorMock()
79  self._op._connectors = [self._connector]
80  self._op.setOnWrite(OnRWTest().echo)
81  self._op.setOnWriteConvert(OnRWConvertTest().echo)
82  self.assertEqual(self._op.write(RTC.TimedLong(RTC.Time(0,0), 123)), True)
83  return
84 
85 
87  self.assertEqual(self._op.getPortDataType(),any.to_any(RTC.TimedLong(RTC.Time(0,0),0)).typecode().name())
88  return
89 
90 
91 
92 if __name__ == '__main__':
93  unittest.main()
test_OutPort.ConnectorMock
Definition: test_OutPort.py:47
test_OutPort.TestOutPort.setUp
def setUp(self)
Definition: test_OutPort.py:58
test_OutPort.ConnectorMock.read
def read(self, data)
Definition: test_OutPort.py:52
test_OutPort.OnRWTest.__init__
def __init__(self)
Definition: test_OutPort.py:33
test_OutPort.TestOutPort.test_getPortDataType
def test_getPortDataType(self)
Definition: test_OutPort.py:86
test_OutPort.TestOutPort.test_write
def test_write(self)
Definition: test_OutPort.py:67
test_OutPort.TestOutPort._op
_op
Definition: test_OutPort.py:60
test_OutPort.ConnectorMock._data
_data
Definition: test_OutPort.py:49
test_OutPort.TestOutPort._connector
_connector
Definition: test_OutPort.py:69
test_OutPort.OnRWConvertTest
Definition: test_OutPort.py:39
test_OutPort.ConnectorMock.write
def write(self, data)
Definition: test_OutPort.py:48
OutPort
setup.name
name
Definition: setup.py:543
test_OutPort.TestOutPort.tearDown
def tearDown(self)
Definition: test_OutPort.py:63
test_OutPort.OnRWConvertTest.echo
def echo(self, value=None)
Definition: test_OutPort.py:43
test_OutPort.TestOutPort.test_OnWrite
def test_OnWrite(self)
Definition: test_OutPort.py:77
test_OutPort.OnRWTest
Definition: test_OutPort.py:32
test_OutPort.TestOutPort
Definition: test_OutPort.py:57
test_OutPort.OnRWTest.echo
def echo(self, value=None)
Definition: test_OutPort.py:36
test_OutPort.OnRWConvertTest.__init__
def __init__(self)
Definition: test_OutPort.py:40


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