Exemple #1
0
 def test_split_filter_includes(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('foo')
     self.assertEqual(['foo'], inc)
     self.assertEqual(0, len(exc))
     inc, exc = gen._split_filter_string('foo,bar')
     self.assertEqual(['foo', 'bar'], inc)
     self.assertEqual(0, len(exc))
Exemple #2
0
 def test_split_filter_excludes(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('-foo')
     self.assertEqual(['.*'], inc)
     self.assertEqual(['foo'], exc)
     inc, exc = gen._split_filter_string('-foo,-bar')
     self.assertEqual(['.*'], inc)
     self.assertEqual(['foo', 'bar'], exc)
 def test_split_filter_excludes(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('-foo')
     self.assertEqual(['.*'], inc)
     self.assertEqual(['foo'], exc)
     inc, exc = gen._split_filter_string('-foo,-bar')
     self.assertEqual(['.*'], inc)
     self.assertEqual(['foo', 'bar'], exc)
Exemple #4
0
 def test_split_filter_empty(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('')
     self.assertEqual(['.*'], inc)
     self.assertEqual(0, len(exc))
     inc, exc = gen._split_filter_string('/')
     self.assertEqual(['.*'], inc)
     self.assertEqual(0, len(exc))
 def test_split_filter_includes(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('foo')
     self.assertEqual(['foo'], inc)
     self.assertEqual(0, len(exc))
     inc, exc = gen._split_filter_string('foo,bar')
     self.assertEqual(['foo', 'bar'], inc)
     self.assertEqual(0, len(exc))
 def test_split_filter_empty(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('')
     self.assertEqual(['.*'], inc)
     self.assertEqual(0, len(exc))
     inc, exc = gen._split_filter_string('/')
     self.assertEqual(['.*'], inc)
     self.assertEqual(0, len(exc))
Exemple #7
0
 def test_get_node_edge_map(self):
     gen = RosGraphDotcodeGenerator()
     e1 = self.MockEdge('foo', 'bar')
     nmap = gen._get_node_edge_map([e1])
     self.assertEqual(2, len(nmap))
     self.assertTrue('foo' in nmap)
     self.assertTrue('bar' in nmap)
     self.assertEqual([], nmap['foo'].incoming)
     self.assertEqual([e1], nmap['foo'].outgoing)
     self.assertEqual([e1], nmap['bar'].incoming)
     self.assertEqual([], nmap['bar'].outgoing)
 def test_get_node_edge_map(self):
     gen = RosGraphDotcodeGenerator()
     e1 = self.MockEdge('foo', 'bar')
     nmap = gen._get_node_edge_map([e1])
     self.assertEqual(2, len(nmap))
     self.assertTrue('foo' in nmap)
     self.assertTrue('bar' in nmap)
     self.assertEqual([], nmap['foo'].incoming)
     self.assertEqual([e1], nmap['foo'].outgoing)
     self.assertEqual([e1], nmap['bar'].incoming)
     self.assertEqual([], nmap['bar'].outgoing)
Exemple #9
0
 def test_get_node_edge_map2(self):
     gen = RosGraphDotcodeGenerator()
     e1 = self.MockEdge('foo', 'bar')
     e2 = self.MockEdge('bar', 'foo')
     e3 = self.MockEdge('foo', 'pam')
     nmap = gen._get_node_edge_map([e1, e2, e3])
     self.assertEqual(3, len(nmap))
     self.assertTrue('foo' in nmap)
     self.assertTrue('bar' in nmap)
     self.assertTrue('pam' in nmap)
     self.assertEqual([e2], nmap['foo'].incoming)
     self.assertEqual([e1, e3], nmap['foo'].outgoing)
     self.assertEqual([e1], nmap['bar'].incoming)
     self.assertEqual([e2], nmap['bar'].outgoing)
 def test_accumulate_action_topics(self):
     gen = RosGraphDotcodeGenerator()
     topic_nodes = ['foo/feedback', 'foo/goal', 'foo/cancel', 'foo/result', 'foo/status', 'bar']
     e1 = self.MockEdge('n1', 'foo/feedback')
     e2 = self.MockEdge('n1', 'foo/goal')
     e3 = self.MockEdge('n1', 'foo/cancel')
     e4 = self.MockEdge('n1', 'foo/result')
     e5 = self.MockEdge('n1', 'foo/status')
     e6 = self.MockEdge('n2', 'bar')
     edges = [e1, e2, e3, e4, e5, e6]
     node_connections = gen._get_node_edge_map(edges)
     rnodes, redges, raction_nodes = gen._accumulate_action_topics(topic_nodes, edges, node_connections)
     self.assertEqual(1, len(rnodes)) # node 'bar'
     self.assertEqual(1, len(redges))
     self.assertEqual(1, len(raction_nodes))
     self.assertEqual(['foo/feedback', 'foo/goal', 'foo/cancel', 'foo/result', 'foo/status', 'bar'], topic_nodes)
     self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
Exemple #11
0
 def test_accumulate_action_topics(self):
     gen = RosGraphDotcodeGenerator()
     topic_nodes = ['foo/feedback', 'foo/goal', 'foo/cancel', 'foo/result', 'foo/status', 'bar']
     e1 = self.MockEdge('n1', 'foo/feedback')
     e2 = self.MockEdge('n1', 'foo/goal')
     e3 = self.MockEdge('n1', 'foo/cancel')
     e4 = self.MockEdge('n1', 'foo/result')
     e5 = self.MockEdge('n1', 'foo/status')
     e6 = self.MockEdge('n2', 'bar')
     edges = [e1, e2, e3, e4, e5, e6]
     node_connections = gen._get_node_edge_map(edges)
     rnodes, redges, raction_nodes = gen._accumulate_action_topics(
         topic_nodes, edges, node_connections)
     self.assertEqual(1, len(rnodes))  # node 'bar'
     self.assertEqual(1, len(redges))
     self.assertEqual(1, len(raction_nodes))
     self.assertEqual(
         ['foo/feedback', 'foo/goal', 'foo/cancel', 'foo/result', 'foo/status', 'bar'], topic_nodes)
     self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
Exemple #12
0
 def test_filter_leaf_topics_both(self):
     gen = RosGraphDotcodeGenerator()
     topic_nodes = ['foo', 'bar', 'pam', 'boo']
     e1 = self.MockEdge('n1', 'foo')
     e2 = self.MockEdge('n2', 'foo')
     e3 = self.MockEdge('n3', 'bar')
     e4 = self.MockEdge('bar', 'n4')
     e5 = self.MockEdge('n5', 'pam')
     e6 = self.MockEdge('boo', 'n6')
     edges = [e1, e2, e3, e4, e5, e6]
     node_connections = gen._get_node_edge_map(edges)
     print(node_connections)
     hide_single_connection_topics = True
     hide_dead_end_topics = True
     rnodes, redges = gen._filter_leaf_topics(
         topic_nodes, edges, node_connections,
         hide_single_connection_topics, hide_dead_end_topics)
     self.assertEqual(['bar'], rnodes)
     self.assertEqual([e3, e4], redges)
     self.assertEqual(['foo', 'bar', 'pam', 'boo'], topic_nodes)
     self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
 def test_filter_leaf_topics_both(self):
     gen = RosGraphDotcodeGenerator()
     topic_nodes = ['foo', 'bar', 'pam', 'boo']
     e1 = self.MockEdge('n1', 'foo')
     e2 = self.MockEdge('n2', 'foo')
     e3 = self.MockEdge('n3', 'bar')
     e4 = self.MockEdge('bar', 'n4')
     e5 = self.MockEdge('n5', 'pam')
     e6 = self.MockEdge('boo', 'n6')
     edges = [e1, e2, e3, e4, e5, e6]
     node_connections = gen._get_node_edge_map(edges)
     print(node_connections)
     rnodes, redges = gen._filter_leaf_topics(topic_nodes,
                             edges,
                             node_connections,
                             True, #hide_single_connection_topics,
                             True #hide_dead_end_topics
                             )
     self.assertEqual(['bar'], rnodes)
     self.assertEqual([e3, e4], redges)
     self.assertEqual(['foo', 'bar', 'pam', 'boo'], topic_nodes)
     self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
Exemple #14
0
 def test_split_filter_both(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('-foo , bar ,baz, -bam')
     self.assertEqual(['bar', 'baz'], inc)
     self.assertEqual(['foo', 'bam'], exc)
 def test_split_filter_both(self):
     gen = RosGraphDotcodeGenerator()
     inc, exc = gen._split_filter_string('-foo , bar ,baz, -bam')
     self.assertEqual(['bar', 'baz'], inc)
     self.assertEqual(['foo', 'bam'], exc)