Example #1
0
 def test_forced_plan(self):
     g = build_graph('ab bc cd de ef fd')
     p = planning.Planner(seed='cthulhu')
     p._setup(g, EhmNo(), 'a', '<ctx>')
     self.assertEqual(p.plan, [])
     p.forced_plan()
     self.assertEqual([s[0] for s in p.plan], ['ab', 'b'])
Example #2
0
 def test_visit_not_own(self):
     p = planning.Planner(seed='cthulhu')
     p.stop, p.plan, extrap = set(), [], []
     p.visit('moo', extrap)
     self.assert_('moo' in p.stop)
     self.assertEqual(p.plan, [])
     self.assertEqual(extrap, ['moo'])
Example #3
0
    def test_setup_results(self):
        p = planning.Planner()
        V, E, plan, v = p._setup(g, EhmNo().start(None), 'a', '<ctx>')
        self.assert_(V is g.V)
        self.assert_(E is g.E)
        self.assert_(v is vert)

        self.assert_(p.g is g)
        self.assert_(plan is p.plan)
        self.assert_(v is p.vert)
Example #4
0
    def test_step(self):
        visited, plan = [], []

        class g:
            V = {'to': 'dest'}

        class e:
            src = 'fm'
            tgt = 'to'

        class v:
            id = 'fm'

        p = planning.Planner(seed='cthulhu')
        p.stop, p.plan, p.g = set(), [], g
        p.visit = lambda thing, plan: visited.append(thing)

        result = p.step(v, e, plan)
        self.assertEqual(result, 'dest')
        self.assertEqual(visited, [e, 'dest'])
        self.assertEqual(p.plan, [])
Example #5
0
 def test_ctor_smoke(self):
     self.assert_(planning.Planner())