16 from json
import dumps, loads
22 rospy.init_node(
"test_advertise")
27 msg = {
"op":
"publish"}
28 self.assertRaises(MissingArgumentException, pub.publish, msg)
30 msg = {
"op":
"publish",
"msg": {}}
31 self.assertRaises(MissingArgumentException, pub.publish, msg)
37 msg = {
"op":
"publish",
"topic": 3}
38 self.assertRaises(InvalidArgumentException, pub.publish, msg)
43 topic =
"/test_publish_works" 44 msg = {
"data":
"test publish works"}
46 received = {
"msg":
None}
51 rospy.Subscriber(topic, String, cb)
53 pub_msg =
loads(
dumps({
"op":
"publish",
"topic": topic,
"msg": msg}))
57 self.assertEqual(received[
"msg"].data, msg[
"data"])
60 PKG =
'rosbridge_library' 62 if __name__ ==
'__main__':
63 rostest.unitrun(PKG, NAME, TestAdvertise)
def dumps(ob, sort_keys=False)
def test_publish_works(self)
def test_invalid_arguments(self)
def test_missing_arguments(self)