test_say.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import sys
19 import unittest
20 
21 import rospy
22 import rostest
23 
24 import actionlib
25 from cob_sound.msg import SayAction, SayResult
26 from simple_script_server import *
28 
29 class SayTest(unittest.TestCase):
30  def __init__(self, *args):
31  super(SayTest, self).__init__(*args)
32  rospy.init_node('test_say_test')
33  self.cb_executed = False
34 
35  def test_say(self):
36  as_name = "/sound/say"
37  self.as_server = actionlib.SimpleActionServer(as_name, SayAction, execute_cb=self.say_cb, auto_start=False)
38  self.as_server.start()
39  self.cb_executed = False
40  handle = sss.say("sound", ["hello"])
41  if not self.cb_executed:
42  self.fail('Service Server not called. script server error_code: ' + str(handle.get_error_code()))
43 
44  def say_cb(self, goal):
45  self.cb_executed = True
46  result = SayResult()
47  self.as_server.set_succeeded(result)
48 
49 if __name__ == '__main__':
50  try:
51  rostest.run('rostest', 'test_say_test', SayTest, sys.argv)
52  except KeyboardInterrupt as e:
53  pass
54  print("exiting")
55 
def __init__(self, args)
Definition: test_say.py:30
def test_say(self)
Definition: test_say.py:35
def say_cb(self, goal)
Definition: test_say.py:44


cob_script_server
Author(s): Florian Weisshardt
autogenerated on Wed Apr 7 2021 03:03:06