test_find_node.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 """ Testing the find_node function """
00004 
00005 import unittest
00006 import rospy
00007 import rostest
00008 import rocon_python_comms
00009 
00010 
00011 class TestFindNode(unittest.TestCase):
00012     def test_find_node_unique(self):
00013         node_name = rospy.get_param('unique_node_name', 'unique_node')
00014         try:
00015             found_nodes = rocon_python_comms.find_node(node_name, unique=True)
00016             rospy.loginfo('Found node(s): ' + str(found_nodes))
00017         except rocon_python_comms.NotFoundException as e:
00018             rospy.logerr("Node: '" + node_name + "' not found or too many found: " + str(e))
00019             assert True
00020 
00021     def test_find_node_non_unique(self):
00022         node_name = rospy.get_param('non_unique_node_name', 'non_unique_node')
00023         try:
00024             found_nodes = rocon_python_comms.find_node(node_name, unique=False)
00025             rospy.loginfo('Found node(s): ' + str(found_nodes))
00026             if len(found_nodes) < 2:
00027                 rospy.loginfo('Not enough nodes found (min = 2): ' + str(found_nodes))
00028                 assert True
00029         except rocon_python_comms.NotFoundException as e:
00030             rospy.logerr("Node: '" + node_name + "' not found: " + str(e))
00031             assert True
00032 
00033     def test_not_find_node(self):
00034         node_name = rospy.get_param('non_existent_node_name', 'non_existent_node')
00035         try:
00036             found_nodes = rocon_python_comms.find_node(node_name, unique=False)
00037             rospy.logerr("Found non-existent node '" + node_name + "'. Not good!")
00038             assert True
00039         except rocon_python_comms.NotFoundException as e:
00040             rospy.loginfo("Non-existent node not found. Good!")
00041 
00042 if __name__ == '__main__':
00043     rostest.rosrun('rocon_python_comms',
00044                    'test_find_node',
00045                    TestFindNode)


rocon_python_comms
Author(s): Daniel Stonier
autogenerated on Fri May 2 2014 10:35:42