test_graph.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # License: BSD
4 # https://raw.github.com/robotics-in-concert/rocon_multimaster/hydro_devel/rocon_gateway_tests/LICENSE
5 #
6 ##############################################################################
7 # Imports
8 ##############################################################################
9 
10 import rospy
11 import sys
12 import rocon_console.console as console
13 from rocon_gateway import Graph
14 from rocon_gateway import GatewayError
15 import unittest
16 import rosunit
17 import rocon_gateway_utils
18 
19 
20 ##############################################################################
21 # Logging
22 ##############################################################################
23 
24 def printtest(msg):
25  print("[TEST] %s" % msg)
26 
27 
28 ##############################################################################
29 # Main
30 ##############################################################################
31 
32 class TestGraph(unittest.TestCase):
33 
34  def setUp(self):
35  rospy.init_node('test_graph')
36  self.graph = Graph()
37 
38  def test_graph(self):
39  flips = None
40  while not flips:
41  printtest("Waiting for flips")
42  self.graph.update()
43  flips = self.graph._local_gateway.flip_watchlist
44  rospy.rostime.wallsleep(0.2)
45  printtest("********************************************************************")
46  printtest("* Local Gateway")
47  printtest("********************************************************************")
48  printtest("%s" % self.graph._local_gateway)
49  self.assertEquals("5", str(len(flips)))
50  # TODO: this is currently returning the base name, is should be returning the hash name
51 
52  self.assertEquals(len([flip for flip in flips if flip.gateway == "remote_gateway" and flip.rule.name == "/add_two_ints" and flip.rule.type == "service"]), 1)
53  self.assertEquals(len([flip for flip in flips if flip.gateway == "remote_gateway" and flip.rule.name == "/chatter" and flip.rule.type == "publisher"]), 1)
54  self.assertEquals(len([flip for flip in flips if flip.gateway == "remote_gateway" and flip.rule.name == "/chatter" and flip.rule.type == "subscriber"]), 1)
55  self.assertEquals(len([flip for flip in flips if flip.gateway == "remote_gateway" and flip.rule.name == "/fibonacci" and flip.rule.type == "action_server"]), 1)
56  self.assertEquals(len([flip for flip in flips if flip.gateway == "remote_gateway" and flip.rule.name == "/fibonacci" and flip.rule.type == "action_client"]), 1)
57 
58  printtest("********************************************************************")
59  printtest("* Remote Gateway")
60  printtest("********************************************************************")
61  printtest("%s" % self.graph._remote_gateways)
62  for remote_gateway in self.graph._remote_gateways:
63  self.assertEquals("remote_gateway", rocon_gateway_utils.gateway_basename(remote_gateway.name))
64 
65  def tearDown(self):
66  pass
67 
68 NAME = 'test_graph'
69 if __name__ == '__main__':
70  rosunit.unitrun('test_graph', NAME, TestGraph, sys.argv, coverage_packages=['rocon_gateway'])
71 
def tearDown(self)
Definition: test_graph.py:65
def test_graph(self)
Definition: test_graph.py:38
def printtest(msg)
Logging.
Definition: test_graph.py:24


rocon_gateway_tests
Author(s): Daniel Stonier, Jihoon Lee, Piyush Khandelwal
autogenerated on Mon Jun 10 2019 14:40:15