37 import roslib.packages
42 from roslib.msgs
import MsgSpec
43 from roslib.srvs
import SrvSpec
49 msg_a = MsgSpec(types, names, constants, text)
55 msg_b = MsgSpec(types, names, constants, text)
57 text = msg_a.text +
'\n---\n' + msg_b.text
58 spec = SrvSpec(msg_a, msg_b, text)
59 self.assertEquals(msg_a, spec.request)
60 self.assertEquals(msg_b, spec.response)
61 self.assertEquals(text, spec.text)
62 self.assertEquals(
'', spec.full_name)
63 self.assertEquals(
'', spec.short_name)
64 self.assertEquals(
'',spec.package)
67 self.assert_(repr(spec))
68 self.assert_(str(spec))
71 self.assertNotEquals(spec,
'spec')
72 self.assert_(spec !=
'spec')
74 spec2 = SrvSpec(msg_a, msg_b, text)
75 self.assertEquals(spec, spec2)
76 self.failIf(spec != spec2)
79 spec2.full_name =
'something' 80 self.assertNotEquals(spec, spec2)
82 self.assertEquals(spec, spec2)
84 spec2.short_name =
'something' 85 self.assertNotEquals(spec, spec2)
87 self.assertEquals(spec, spec2)
89 spec2.package =
'something' 90 self.assertNotEquals(spec, spec2)
92 self.assertEquals(spec, spec2)
95 from roslib.srvs
import srv_file
97 d = roslib.packages.get_pkg_dir(
'test_rosmaster')
98 filename = os.path.join(d,
'srv',
'AddTwoInts.srv')
99 with open(filename,
'r') as f: 102 self.assertEquals(filename, srv_file('test_rosmaster',
'AddTwoInts'))
105 from roslib.srvs
import load_from_file, set_verbose
107 d = roslib.packages.get_pkg_dir(
'test_rosmaster')
108 filename = os.path.join(d,
'srv',
'AddTwoInts.srv')
109 with open(filename,
'r') as f: 112 name, spec = load_from_file(filename) 113 self.assertEquals('AddTwoInts', name)
114 self.assertEquals([
'int64',
'int64'], spec.request.types)
115 self.assertEquals([
'a',
'b'], spec.request.names)
116 self.assertEquals(text, spec.text)
118 name2, spec2 = load_from_file(filename, package_context=
'foo')
119 self.assertEquals(
'foo/AddTwoInts', name2)
120 name2, spec2 = load_from_file(filename, package_context=
'foo/')
121 self.assertEquals(
'foo/AddTwoInts', name2)
122 name2, spec2 = load_from_file(filename, package_context=
'foo//')
123 self.assertEquals(
'foo/AddTwoInts', name2)
127 name3, spec3 = load_from_file(filename)
128 self.assertEquals(name, name3)
129 self.assertEquals(spec, spec3)
def test_load_from_file(self)