38 NAME =
'empty_service' 46 EMPTY_SERVICE =
'empty_service' 47 EMPTY_RETURN_SERVICE =
'empty_return_service' 48 EMPTY_REQ_SERVICE =
'empty_req_service' 49 EMPTY_RESP_SERVICE =
'empty_resp_service' 56 print(
"Returning empty")
57 return EmptySrvResponse()
60 "print returning empty list" 65 print(
"Returning fake_secret")
66 return EmptyReqSrvResponse(FAKE_SECRET)
69 if req.fake_secret == FAKE_SECRET:
70 print(
"Request validated, returning empty")
71 return EmptyRespSrvResponse()
73 print(
"Request did not validate, returning None")
77 s1 = rospy.Service(EMPTY_SERVICE, EmptySrv, handle_empty)
78 s2 = rospy.Service(EMPTY_REQ_SERVICE, EmptyReqSrv, handle_empty_req)
79 s3 = rospy.Service(EMPTY_RESP_SERVICE, EmptyRespSrv, handle_empty_resp)
80 s4 = rospy.Service(EMPTY_RETURN_SERVICE, EmptySrv, handle_return_empty)
85 def _test(self, name, srv, req):
86 rospy.wait_for_service(name, WAIT_TIMEOUT)
87 s = rospy.ServiceProxy(name, srv)
89 self.assert_(resp
is not None)
94 rospy.wait_for_service(EMPTY_REQ_SERVICE, WAIT_TIMEOUT)
95 s = rospy.ServiceProxy(EMPTY_REQ_SERVICE, EmptyReqSrv)
97 self.assertEquals(FAKE_SECRET, resp.fake_secret,
98 "fake_secret fields is not set as expected")
100 self.assertEquals(FAKE_SECRET, resp.fake_secret,
101 "fake_secret fields is not set as expected")
104 self.
_test(EMPTY_SERVICE, EmptySrv, EmptySrvRequest())
107 self.
_test(EMPTY_RETURN_SERVICE, EmptySrv, EmptySrvRequest())
109 resp = self.
_test(EMPTY_REQ_SERVICE, EmptyReqSrv,
110 EmptyReqSrvRequest())
111 self.assertEquals(FAKE_SECRET, resp.fake_secret,
112 "fake_secret fields is not set as expected")
114 self.
_test(EMPTY_RESP_SERVICE, EmptyRespSrv,
115 EmptyRespSrvRequest(FAKE_SECRET))
117 if __name__ ==
'__main__':
118 if '--service' in sys.argv:
121 rostest.run(PKG,
'rospy_empty_service', TestEmptyServiceClient, sys.argv)
def test_call_empty(self)
def test_return_empty(self)
def _test(self, name, srv, req)
def test_empty_resp(self)
def handle_return_empty(req)
def handle_empty_resp(req)
handle empty response
def handle_empty_req(req)
handle empty request