test_say.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
00016 
00017 
00018 import sys
00019 import unittest
00020 
00021 import rospy
00022 import rostest
00023 
00024 from simple_script_server import *
00025 sss = simple_script_server()
00026 
00027 class SayTest(unittest.TestCase):
00028         def __init__(self, *args):
00029                 super(SayTest, self).__init__(*args)
00030                 rospy.init_node('test_say_test')
00031                 self.cb_executed = False
00032 
00033         def test_say(self):
00034                 as_name = "/sound/say"
00035                 self.as_server = actionlib.SimpleActionServer(as_name, SayAction, execute_cb=self.say_cb, auto_start=False)
00036                 self.as_server.start()
00037                 self.cb_executed = False
00038                 handle = sss.say("sound", ["hello"])
00039                 if not self.cb_executed:
00040                         self.fail('Service Server not called. script server error_code: ' + str(handle.get_error_code()))
00041 
00042         def say_cb(self, goal):
00043                 self.cb_executed = True
00044                 result = SayResult()
00045                 self.as_server.set_succeeded(result)
00046 
00047 if __name__ == '__main__':
00048         try:
00049                 rostest.run('rostest', 'test_say_test', SayTest, sys.argv)
00050         except KeyboardInterrupt, e:
00051                 pass
00052         print "exiting"
00053 


cob_script_server
Author(s): Florian Weisshardt
autogenerated on Sun Jun 9 2019 20:20:12