Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 import rospy
00011 import sys
00012 import rocon_console.console as console
00013 from rocon_gateway import Graph
00014 from rocon_gateway import GatewayError
00015 import unittest
00016 import rosunit
00017 import rocon_gateway_utils
00018
00019
00020
00021
00022
00023 def printtest(msg):
00024 print("[TEST] %s" % msg)
00025
00026
00027
00028
00029
00030 class TestGraph(unittest.TestCase):
00031
00032 def setUp(self):
00033 rospy.init_node('test_graph')
00034 self.graph = Graph()
00035
00036 def test_graph(self):
00037 flips = None
00038 while not flips:
00039 printtest("Waiting for flips")
00040 self.graph.update()
00041 flips = self.graph._local_gateway.flip_watchlist
00042 rospy.rostime.wallsleep(0.2)
00043 printtest("********************************************************************")
00044 printtest("* Local Gateway")
00045 printtest("********************************************************************")
00046 printtest("%s" % self.graph._local_gateway)
00047 self.assertEquals("1", str(len(flips)))
00048
00049 self.assertEquals("remote_gateway", flips[0].gateway)
00050 self.assertEquals("publisher", flips[0].rule.type)
00051 self.assertEquals("/chatter", flips[0].rule.name)
00052
00053 printtest("********************************************************************")
00054 printtest("* Remote Gateway")
00055 printtest("********************************************************************")
00056 printtest("%s" % self.graph._remote_gateways)
00057 for remote_gateway in self.graph._remote_gateways:
00058 self.assertEquals("remote_gateway", rocon_gateway_utils.gateway_basename(remote_gateway.name))
00059
00060 def tearDown(self):
00061 pass
00062
00063 NAME = 'test_graph'
00064 if __name__ == '__main__':
00065 rosunit.unitrun('test_graph', NAME, TestGraph, sys.argv, coverage_packages=['rocon_gateway'])
00066