test_SdoOrganization.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- Python -*-
3 
4 #
5 # \file test_SdoOrganization.py
6 # \brief test for SDO Organization implementation class
7 # \date $Date: 2007/09/12 $
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 omniORB.any
19 from omniORB import CORBA
20 import threading
21 
22 import sys
23 sys.path.insert(1,"../")
24 sys.path.insert(1,"../RTM_IDL")
25 
26 import unittest
27 import OpenRTM_aist
28 import SDOPackage, SDOPackage__POA
29 
30 from SdoOrganization import *
31 
32 
34  def __init__(self, manager):
35  OpenRTM_aist.DataFlowComponentBase.__init__(self, manager)
36 
37  def onInitialize(self):
38  print "onInitialize"
39  return RTC.RTC_OK
40 
41  def onFinalize(self):
42  print "onFinalize"
43  return RTC.RTC_OK
44 
45  def onStartup(self, ec_id):
46  print "onStartup"
47  return RTC.RTC_OK
48 
49  def onShutdown(self, ec_id):
50  print "onSutdown"
51  return RTC.RTC_OK
52 
53  def onActivated(self, ec_id):
54  print "onActivated"
55  return RTC.RTC_OK
56 
57  def onDeactivated(self, ec_id):
58  print "onDeactivated"
59  return RTC.RTC_OK
60 
61  def onExecute(self, ec_id):
62  print "onExecute"
63  return RTC.RTC_OK
64 
65  def onAborting(self, ec_id):
66  print "onAborting"
67  return RTC.RTC_OK
68 
69  def onReset(self, ec_id):
70  print "onReset"
71  return RTC.RTC_OK
72 
73  def onStateUpdate(self, ec_id):
74  print "onStateUpdate"
75  return RTC.RTC_OK
76 
77  def onRateChanged(self, ec_id):
78  print "onRateChanged"
79  return RTC.RTC_OK
80 
81 
82 class TestOrganization_impl(unittest.TestCase):
83  def setUp(self):
84  rtc = TestComp(OpenRTM_aist.Manager.instance())
85  self.org = Organization_impl(rtc.getObjRef())
86 
87  def tearDown(self):
88  OpenRTM_aist.Manager.instance().shutdownManager()
89  return
90 
92  print self.org.get_organization_id()
93 
95  nv_list = [SDOPackage.NameValue("test", 100)]
96  self.org.add_organization_property(SDOPackage.OrganizationProperty(nv_list))
97  self.assertEqual(self.org.get_organization_property().properties[0].name, "test")
98  self.org.remove_organization_property("test")
99  ret_val = self.org.get_organization_property()
100  self.assertEqual(len(ret_val.properties), 0)
101 
102  self.assertRaises(SDOPackage.InvalidParameter, self.org.remove_organization_property, None )
103 
105  self.org.set_organization_property_value("test", 100)
106  self.assertRaises(SDOPackage.InvalidParameter, self.org.set_organization_property_value, None, None )
107 
108  val = omniORB.any.from_any(self.org.get_organization_property_value("test"))
109  self.assertEqual(val, 100)
110  # Failure pattern
111  # because get_organization_property_value() returns value of CORBA.Any type.
112  # self.assertEqual(self.org.get_organization_property_value("test"), 100)
113  self.assertRaises(SDOPackage.InvalidParameter, self.org.get_organization_property_value, "aaa" )
114  self.assertRaises(SDOPackage.InvalidParameter, self.org.get_organization_property_value, None )
115 
116  self.assertRaises(SDOPackage.InvalidParameter, self.org.set_organization_property_value, None, "aaa" )
117 
118 
119  def test_get_owner(self):
120  rtc = TestComp(OpenRTM_aist.Manager.instance())
121  self.org.set_owner(rtc.getObjRef())
122  self.assertNotEqual(self.org.get_owner(),None)
123  self.assertRaises(SDOPackage.InvalidParameter, self.org.set_owner, None )
124 
126  def __init__(self):
127  self._orb = CORBA.ORB_init()
128  self._poa = self._orb.resolve_initial_references("RootPOA")
129  OpenRTM_aist.RTObject_impl.__init__(self, orb=self._orb, poa=self._poa)
130 
131 
132  def test_get_members(self):
133  # Failure pattern
134  #self.org.set_members([])
135  self.assertEqual(self.org.get_members(),[])
136  member = self.sdo_test()
137  member.setInstanceName("test0")
138  self.org.set_members([member])
139  member = self.sdo_test()
140  member.setInstanceName("test1")
141  self.org.add_members([member])
142  self.assertEqual(len(self.org.get_members()),2)
143  self.org.remove_member("test1")
144  self.assertEqual(len(self.org.get_members()),1)
145 
146  self.assertRaises(SDOPackage.InvalidParameter, self.org.set_members, None )
147  self.assertRaises(SDOPackage.InvalidParameter, self.org.add_members, None )
148  self.assertRaises(SDOPackage.InvalidParameter, self.org.remove_member, None )
149 
150 
152  self.org.set_dependency(SDOPackage.OWN)
153  self.assertEqual(self.org.get_dependency(), SDOPackage.OWN)
154 
155  self.assertRaises(SDOPackage.InvalidParameter, self.org.set_dependency, None )
156 
157 
158 
159 if __name__ == '__main__':
160  unittest.main()


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