test_rospy_api.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Software License Agreement (BSD License)
00003 #
00004 # Copyright (c) 2008, Willow Garage, Inc.
00005 # All rights reserved.
00006 #
00007 # Redistribution and use in source and binary forms, with or without
00008 # modification, are permitted provided that the following conditions
00009 # are met:
00010 #
00011 #  * Redistributions of source code must retain the above copyright
00012 #    notice, this list of conditions and the following disclaimer.
00013 #  * Redistributions in binary form must reproduce the above
00014 #    copyright notice, this list of conditions and the following
00015 #    disclaimer in the documentation and/or other materials provided
00016 #    with the distribution.
00017 #  * Neither the name of Willow Garage, Inc. nor the names of its
00018 #    contributors may be used to endorse or promote products derived
00019 #    from this software without specific prior written permission.
00020 #
00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 # POSSIBILITY OF SUCH DAMAGE.
00033 
00034 import os
00035 import sys
00036 import struct
00037 import unittest
00038 import time
00039 
00040 # test rospy API verifies that the rospy module exports the required symbols
00041 class TestRospyApi(unittest.TestCase):
00042 
00043     def test_msg(self):
00044         # rospy.Message really only exists at the client level, as the internal
00045         # implementation is built around the roslib reference, so we put the test here
00046 
00047         import rospy
00048         #trip wires against Message API
00049         m = rospy.Message()
00050         from cStringIO import StringIO
00051         buff = StringIO()
00052         m.serialize(buff)
00053         self.assertEquals(0, buff.tell())
00054         m.deserialize('')
00055         
00056     def test_anymsg(self):
00057         # rospy.AnyMsg really only exists at the client level as nothing within
00058         # rospy uses its functionality.
00059         
00060 
00061         from cStringIO import StringIO
00062         import rospy
00063         #trip wires against AnyMsg API
00064         m = rospy.AnyMsg()
00065         try:
00066             m.serialize(StringIO())
00067             self.fail("AnyMsg should not allow serialization")
00068         except:
00069             pass
00070 
00071         teststr = 'foostr-%s'%time.time()
00072         m.deserialize(teststr)
00073         self.assertEquals(teststr, m._buff)
00074 
00075         #test AnyMsg ctor error checking
00076         try:
00077             m = rospy.AnyMsg('foo')
00078             self.fail("AnyMsg ctor should not allow args")
00079         except: pass
00080 
00081     def test_rospy_api(self):
00082         import rospy
00083 
00084         # just a laundry list of API methods to make sure that they still exist
00085         
00086         # removed
00087         try:
00088             rospy.add_shutdown_hook
00089             self.fail("add_shutdown_hookshould not longer be top-level API")
00090         except AttributeError: pass
00091 
00092         rospy.DEBUG
00093         rospy.INFO
00094         rospy.WARN
00095         rospy.ERROR
00096         rospy.FATAL
00097         
00098         rospy.get_caller_id
00099         rospy.get_name        
00100         rospy.get_master
00101         rospy.get_namespace
00102         rospy.get_published_topics
00103         rospy.get_node_uri
00104         rospy.get_ros_root
00105         rospy.get_time
00106         rospy.get_rostime
00107         rospy.init_node
00108         rospy.is_shutdown
00109         rospy.logdebug
00110         rospy.logerr
00111         rospy.logfatal
00112         rospy.loginfo        
00113         rospy.logout #deprecated
00114         rospy.logwarn
00115         rospy.myargv
00116         rospy.on_shutdown
00117         rospy.parse_rosrpc_uri
00118         rospy.resolve_name
00119         rospy.remap_name
00120         rospy.signal_shutdown
00121         rospy.sleep
00122         rospy.spin
00123         rospy.wait_for_message
00124         rospy.wait_for_service
00125 
00126         rospy.delete_param
00127         rospy.get_param
00128         rospy.get_param_names
00129         rospy.has_param
00130         rospy.set_param
00131         rospy.search_param        
00132 
00133         rospy.AnyMsg
00134         rospy.Duration
00135         rospy.Header
00136         rospy.MasterProxy
00137         rospy.Message
00138         rospy.Publisher
00139         rospy.Rate
00140         rospy.ROSException
00141         rospy.ROSInternalException
00142         rospy.ROSSerializationException
00143         rospy.ServiceException
00144         rospy.Service
00145         rospy.ServiceProxy
00146         rospy.SubscribeListener
00147         rospy.Subscriber        
00148         rospy.Time
00149         rospy.TransportException
00150         rospy.TransportTerminated
00151         rospy.TransportInitError


test_rospy
Author(s): Ken Conley/kwc@willowgarage.com
autogenerated on Sat Dec 28 2013 17:36:20