16 from json
import dumps, loads
19 PKG =
'rosbridge_library'
31 msg = {
"op":
"publish"}
32 self.assertRaises(MissingArgumentException, pub.publish, msg)
34 msg = {
"op":
"publish",
"msg": {}}
35 self.assertRaises(MissingArgumentException, pub.publish, msg)
41 msg = {
"op":
"publish",
"topic": 3}
42 self.assertRaises(InvalidArgumentException, pub.publish, msg)
47 topic =
"/test_publish_works"
48 msg = {
"data":
"test publish works"}
50 received = {
"msg":
None}
55 rospy.Subscriber(topic, String, cb)
57 pub_msg =
loads(
dumps({
"op":
"publish",
"topic": topic,
"msg": msg}))
61 self.assertEqual(received[
"msg"].data, msg[
"data"])
64 if __name__ ==
'__main__':
65 rosunit.unitrun(PKG, NAME, TestPublish)