trigger.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 PKG="cob_script_server"
00004 import roslib; roslib.load_manifest(PKG)
00005 
00006 import sys
00007 import unittest
00008 
00009 from simple_script_server import *
00010 sss = simple_script_server()
00011 
00012 ## This test checks the correct call to commands from the cob_script_server. This does not cover the execution of the commands (this shoud be checked in the package where the calls refer to).
00013 class TestTrigger(unittest.TestCase):
00014         def __init__(self, *args):
00015                 super(TestTrigger, self).__init__(*args)
00016                 rospy.init_node('test_trigger')
00017                 self.cb_executed = False
00018                 self.component_name = "arm"  # testing for component arm
00019 
00020         def test_init(self):
00021                 rospy.Service("/" + self.component_name + "_controller/init", Trigger, self.cb)
00022                 self.cb_executed = False
00023                 handle = sss.init(self.component_name)
00024                 if not self.cb_executed:
00025                         self.fail('Service Server not called. script server error_code: ' + str(handle.get_error_code()))
00026 
00027         def test_stop(self):
00028                 rospy.Service("/" + self.component_name + "_controller/stop", Trigger, self.cb)
00029                 self.cb_executed = False
00030                 handle = sss.stop(self.component_name)
00031                 if not self.cb_executed:
00032                         self.fail('Service Server not called. script server error_code: ' + str(handle.get_error_code()))
00033 
00034         def test_recover(self):
00035                 rospy.Service("/" + self.component_name + "_controller/recover", Trigger, self.cb)
00036                 self.cb_executed = False
00037                 handle = sss.recover(self.component_name)
00038                 if not self.cb_executed:
00039                         self.fail('Service Server not called. script server error_code: ' + str(handle.get_error_code()))
00040 
00041         def cb(self,req):
00042                 self.cb_executed = True
00043                 res = TriggerResponse()
00044                 res.success.data = True
00045                 return res
00046 
00047 if __name__ == '__main__':
00048         import rostest
00049         rostest.rosrun(PKG, 'trigger', TestTrigger)


cob_script_server
Author(s): Florian Weisshardt
autogenerated on Thu Aug 27 2015 12:42:55