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 ############### test #################
92 if __name__ == '__main__':
93  unittest.main()
def test_getPortDataType(self)
Definition: test_OutPort.py:86
def echo(self, value=None)
Definition: test_OutPort.py:43
name
Definition: setup.py:543
def echo(self, value=None)
Definition: test_OutPort.py:36


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Jun 6 2019 19:11:34