MCPcopy Index your code
hub / github.com/waleedka/hiddenlayer / test_search

Method test_search

tests/test_ge.py:169–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

167 self.assertTrue(match)
168
169 def test_search(self):
170 g = hl.Graph()
171 a = hl.Node(uid="a", name="a", op="a")
172 b = hl.Node(uid="b", name="b", op="b")
173 c = hl.Node(uid="c", name="c", op="c")
174 d = hl.Node(uid="d", name="d", op="d")
175 g.add_node(a)
176 g.add_node(b)
177 g.add_node(c)
178 g.add_node(d)
179 g.add_edge(a, b)
180 g.add_edge(b, c)
181 g.add_edge(b, d)
182
183 pattern = ge.GEParser("a > b").parse()
184 match, following = g.search(pattern)
185 self.assertCountEqual(match, [a, b])
186 self.assertCountEqual(following, [c, d])
187
188 pattern = ge.GEParser("b > (c | d)").parse()
189 match, following = g.search(pattern)
190 self.assertCountEqual(match, [b, c, d])
191 self.assertEqual(following, [])
192
193 pattern = ge.GEParser("c|d").parse()
194 match, following = g.search(pattern)
195 self.assertCountEqual(match, [c, d])
196 self.assertEqual(following, [])
197
198
199class TestTransforms(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

add_nodeMethod · 0.95
add_edgeMethod · 0.95
searchMethod · 0.95
parseMethod · 0.80

Tested by

no test coverage detected