47 inc, exc = gen._split_filter_string(
'')
48 self.assertEqual([
'.*'], inc)
49 self.assertEqual(0, len(exc))
50 inc, exc = gen._split_filter_string(
'/')
51 self.assertEqual([
'.*'], inc)
52 self.assertEqual(0, len(exc))
56 inc, exc = gen._split_filter_string(
'foo')
57 self.assertEqual([
'foo'], inc)
58 self.assertEqual(0, len(exc))
59 inc, exc = gen._split_filter_string(
'foo,bar')
60 self.assertEqual([
'foo',
'bar'], inc)
61 self.assertEqual(0, len(exc))
65 inc, exc = gen._split_filter_string(
'-foo')
66 self.assertEqual([
'.*'], inc)
67 self.assertEqual([
'foo'], exc)
68 inc, exc = gen._split_filter_string(
'-foo,-bar')
69 self.assertEqual([
'.*'], inc)
70 self.assertEqual([
'foo',
'bar'], exc)
74 inc, exc = gen._split_filter_string(
'-foo , bar ,baz, -bam')
75 self.assertEqual([
'bar',
'baz'], inc)
76 self.assertEqual([
'foo',
'bam'], exc)
87 nmap = gen._get_node_edge_map([e1])
88 self.assertEqual(2, len(nmap))
89 self.assertTrue(
'foo' in nmap)
90 self.assertTrue(
'bar' in nmap)
91 self.assertEqual([], nmap[
'foo'].incoming)
92 self.assertEqual([e1], nmap[
'foo'].outgoing)
93 self.assertEqual([e1], nmap[
'bar'].incoming)
94 self.assertEqual([], nmap[
'bar'].outgoing)
101 nmap = gen._get_node_edge_map([e1, e2, e3])
102 self.assertEqual(3, len(nmap))
103 self.assertTrue(
'foo' in nmap)
104 self.assertTrue(
'bar' in nmap)
105 self.assertTrue(
'pam' in nmap)
106 self.assertEqual([e2], nmap[
'foo'].incoming)
107 self.assertEqual([e1, e3], nmap[
'foo'].outgoing)
108 self.assertEqual([e1], nmap[
'bar'].incoming)
109 self.assertEqual([e2], nmap[
'bar'].outgoing)
113 topic_nodes = [
'foo',
'bar',
'pam',
'boo']
120 edges = [e1, e2, e3, e4, e5, e6]
121 node_connections = gen._get_node_edge_map(edges)
122 print(node_connections)
123 hide_single_connection_topics =
True 124 hide_dead_end_topics =
False 125 rnodes, redges = gen._filter_leaf_topics(topic_nodes,
128 hide_single_connection_topics,
131 self.assertEqual([
'foo',
'bar'], rnodes)
132 self.assertEqual([e1, e2, e3, e4], redges)
133 self.assertEqual([
'foo',
'bar',
'pam',
'boo'], topic_nodes)
134 self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
138 topic_nodes = [
'foo',
'bar',
'pam',
'boo']
145 edges = [e1, e2, e3, e4, e5, e6]
146 node_connections = gen._get_node_edge_map(edges)
147 print(node_connections)
148 hide_single_connection_topics =
False 149 hide_dead_end_topics =
True 150 rnodes, redges = gen._filter_leaf_topics(topic_nodes,
153 hide_single_connection_topics,
156 self.assertEqual([
'bar',
'boo'], rnodes)
157 self.assertEqual([e3, e4, e6], redges)
158 self.assertEqual([
'foo',
'bar',
'pam',
'boo'], topic_nodes)
159 self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
163 topic_nodes = [
'foo',
'bar',
'pam',
'boo']
170 edges = [e1, e2, e3, e4, e5, e6]
171 node_connections = gen._get_node_edge_map(edges)
172 print(node_connections)
173 hide_single_connection_topics =
True 174 hide_dead_end_topics =
True 175 rnodes, redges = gen._filter_leaf_topics(topic_nodes,
178 hide_single_connection_topics,
181 self.assertEqual([
'bar'], rnodes)
182 self.assertEqual([e3, e4], redges)
183 self.assertEqual([
'foo',
'bar',
'pam',
'boo'], topic_nodes)
184 self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
188 topic_nodes = [
'foo/feedback',
'foo/goal',
'foo/cancel',
'foo/result',
'foo/status',
'bar']
189 e1 = self.
MockEdge(
'n1',
'foo/feedback')
190 e2 = self.
MockEdge(
'n1',
'foo/goal')
191 e3 = self.
MockEdge(
'n1',
'foo/cancel')
192 e4 = self.
MockEdge(
'n1',
'foo/result')
193 e5 = self.
MockEdge(
'n1',
'foo/status')
195 edges = [e1, e2, e3, e4, e5, e6]
196 node_connections = gen._get_node_edge_map(edges)
197 rnodes, redges, raction_nodes = gen._accumulate_action_topics(
198 topic_nodes, edges, node_connections)
199 self.assertEqual(1, len(rnodes))
200 self.assertEqual(1, len(redges))
201 self.assertEqual(1, len(raction_nodes))
203 [
'foo/feedback',
'foo/goal',
'foo/cancel',
'foo/result',
'foo/status',
'bar'], topic_nodes)
204 self.assertEqual([e1, e2, e3, e4, e5, e6], edges)
207 if __name__ ==
'__main__':
209 rosunit.unitrun(PKG,
'dotcode_test', DotcodeTest)
def test_get_node_edge_map(self)
def __init__(self, start, end)
def test_filter_leaf_topics_both(self)
def test_split_filter_both(self)
def test_filter_leaf_topics_dead_end(self)
def test_get_node_edge_map2(self)
def test_accumulate_action_topics(self)
def test_filter_leaf_topics_single_connection(self)
def test_split_filter_excludes(self)
def test_split_filter_empty(self)
def test_split_filter_includes(self)