Exemplo n.º 1
0
 def test__queue(self):
     trail = trail_.Trail('graph')
     trail.enqueue('p')
     trail.enqueue('q')
     self.assertEqual(trail.queue, collections.deque(['p', 'q']))
     self.assertFalse(trail.queue_empty())
     self.assertEqual(trail.dequeue(), 'p')
     self.assertEqual(trail.dequeue(), 'q')
     self.assertTrue(trail.queue_empty())
Exemplo n.º 2
0
 def test__nodes__3(self):
     trail = trail_.Trail('graph')
     trail.explore_and_append_node('p')
     trail.explore_and_append_node('q')
     self.assertEqual(trail.nodes, ['p', 'q'])
     self.assertEqual(trail.explored_nodes, set(['p', 'q']))
     self.assertTrue(trail.node_explored('p'))
     self.assertTrue(trail.node_explored('q'))
     self.assertFalse(trail.node_explored('x'))
Exemplo n.º 3
0
 def test__callbacks(self):
     e, l, b = (lambda *args: False, lambda *args: False,
                lambda *args: False)
     trail = trail_.Trail('graph',
                          ingress_func=e,
                          egress_func=l,
                          backedge_func=b)
     self.assertIs(trail.ingress_func, e)
     self.assertIs(trail.egress_func, l)
     self.assertIs(trail.backedge_func, b)
Exemplo n.º 4
0
 def test__edges__2(self):
     trail = trail_.Trail('graph')
     trail.append_edge(('p', 'q'))
     trail.append_edge(('q', 'r'))
     trail.append_backedge(('r', 'p'))
     self.assertEqual(trail.edges, [('p', 'q'), ('q', 'r')])
     self.assertEqual(trail.backedges, [('r', 'p')])
     self.assertEqual(trail.explored_edges, set())
     self.assertFalse(trail.edge_explored(('p', 'q')))
     self.assertFalse(trail.edge_explored(('q', 'r')))
     self.assertFalse(trail.edge_explored(('r', 'p')))
     self.assertFalse(trail.edge_explored(('x', 'y')))
Exemplo n.º 5
0
 def test__init__0(self):
     trail = trail_.Trail('graph')
     self.assertEqual(trail.graph, 'graph')
     self.assertEqual(trail.explored_nodes, set())
     self.assertEqual(trail.explored_edges, set())
     self.assertEqual(trail.nodes, list())
     self.assertEqual(trail.edges, list())
     self.assertEqual(trail.backedges, list())
     self.assertIsNone(trail.result)
     self.assertEqual(trail.queue, collections.deque())
     self.assertTrue(callable(trail.ingress_func))
     self.assertTrue(callable(trail.egress_func))
     self.assertTrue(callable(trail.backedge_func))
Exemplo n.º 6
0
 def test__result(self):
     trail = trail_.Trail('graph')
     self.assertIsNone(trail.result)
     trail.result = 'result'
     self.assertEqual(trail.result, 'result')