00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 import roslib; roslib.load_manifest('test_rospy')
00037
00038 import os
00039 import sys
00040 import struct
00041 import unittest
00042 import time
00043
00044
00045 class TestRospyApi(unittest.TestCase):
00046
00047 def test_msg(self):
00048
00049
00050
00051 import rospy
00052
00053 m = rospy.Message()
00054 from cStringIO import StringIO
00055 buff = StringIO()
00056 m.serialize(buff)
00057 self.assertEquals(0, buff.tell())
00058 m.deserialize('')
00059
00060 def test_anymsg(self):
00061
00062
00063
00064
00065 from cStringIO import StringIO
00066 import rospy
00067
00068 m = rospy.AnyMsg()
00069 try:
00070 m.serialize(StringIO())
00071 self.fail("AnyMsg should not allow serialization")
00072 except:
00073 pass
00074
00075 teststr = 'foostr-%s'%time.time()
00076 m.deserialize(teststr)
00077 self.assertEquals(teststr, m._buff)
00078
00079
00080 try:
00081 m = rospy.AnyMsg('foo')
00082 self.fail("AnyMsg ctor should not allow args")
00083 except: pass
00084
00085 def test_rospy_api(self):
00086 import rospy
00087
00088
00089
00090
00091 try:
00092 rospy.add_shutdown_hook
00093 self.fail("add_shutdown_hookshould not longer be top-level API")
00094 except AttributeError: pass
00095
00096 rospy.DEBUG
00097 rospy.INFO
00098 rospy.WARN
00099 rospy.ERROR
00100 rospy.FATAL
00101
00102 rospy.get_caller_id
00103 rospy.get_name
00104 rospy.get_master
00105 rospy.get_namespace
00106 rospy.get_published_topics
00107 rospy.get_node_uri
00108 rospy.get_ros_root
00109 rospy.get_time
00110 rospy.get_rostime
00111 rospy.init_node
00112 rospy.is_shutdown
00113 rospy.logdebug
00114 rospy.logerr
00115 rospy.logfatal
00116 rospy.loginfo
00117 rospy.logout
00118 rospy.logwarn
00119 rospy.myargv
00120 rospy.on_shutdown
00121 rospy.parse_rosrpc_uri
00122 rospy.resolve_name
00123 rospy.remap_name
00124 rospy.signal_shutdown
00125 rospy.sleep
00126 rospy.spin
00127 rospy.wait_for_message
00128 rospy.wait_for_service
00129
00130 rospy.delete_param
00131 rospy.get_param
00132 rospy.get_param_names
00133 rospy.has_param
00134 rospy.set_param
00135 rospy.search_param
00136
00137 rospy.AnyMsg
00138 rospy.Duration
00139 rospy.Header
00140 rospy.MasterProxy
00141 rospy.Message
00142 rospy.Publisher
00143 rospy.Rate
00144 rospy.ROSException
00145 rospy.ROSInternalException
00146 rospy.ROSSerializationException
00147 rospy.ServiceDefinition
00148 rospy.ServiceException
00149 rospy.Service
00150 rospy.ServiceProxy
00151 rospy.SubscribeListener
00152 rospy.Subscriber
00153 rospy.Time
00154 rospy.TransportException
00155 rospy.TransportTerminated
00156 rospy.TransportInitError
00157
00158 if __name__ == '__main__':
00159 import rostest
00160 rostest.unitrun('test_rospy', sys.argv[0], TestRospyApi)