예제 #1
0
 def test_startReturnsActions(self):
     wanderer = RandomWalk(make_mock_environment())
     actions = wanderer.dispatch(Start(), None)
     self.assertIsNotNone(
         actions, "dispatch has failed to return an initial action")
     self.assertTrue(
         len(actions) > 0, "dispatch has returned an empty list of actions")
예제 #2
0
 def test_start_plan(self):
     actionExecutor = MockActionExecutor()
     plan = [Turn(math.pi), WalkForwardsIndefinitely()]
     env = make_mock_environment()
     save_plan(env, plan)
     print "Stored plan = " + repr(load_plan(env))
     executor = PlanExecutor(env, actionExecutor)
     executor.perform_next_action()
     executor.perform_next_action()
     executor.perform_next_action()
     self.assertEqual(1, actionExecutor.allDoneCount, "all_done() should have been called once")
     self.assertItemsEqual(plan, actionExecutor.actions, "Executed actions should match plan")
예제 #3
0
 def test_start_plan(self):
     actionExecutor = MockActionExecutor()
     plan = [Turn(math.pi), WalkForwardsIndefinitely()]
     env = make_mock_environment()
     save_plan(env, plan)
     print "Stored plan = "+repr(load_plan(env))
     executor = PlanExecutor(env, actionExecutor)
     executor.perform_next_action()
     executor.perform_next_action()
     executor.perform_next_action()
     print "Executed actions = "+repr(actionExecutor.actions)
     self.assertEqual(1, actionExecutor.allDoneCount, "all_done() should have been called once")
     self.assertEqual(plan, actionExecutor.actions, "Executed actions should match plan")
예제 #4
0
 def test_Bump(self):
     wanderer = RandomWalk(make_mock_environment())
     actions = wanderer.dispatch(ObstacleDetected('LeftBumper', {'LeftBumper':True}), None)
     self.assertTrue(actions[0].distance < 0, "backoff after a bump")
예제 #5
0
 def test_startReturnsActions(self):
     wanderer = RandomWalk(make_mock_environment())
     actions = wanderer.dispatch(Start(), None)
     self.assertIsNotNone(actions, "dispatch has failed to return an initial action")
     self.assertTrue(len(actions) > 0, "dispatch has returned an empty list of actions")
예제 #6
0
 def test_dispatch(self):
     wanderer = RandomWalk(make_mock_environment())
     event = ObstacleDetected('LeftBumper', {'LeftBumper':True})
     wanderer.dispatch(event, None)
예제 #7
0
 def test_make_updaters(self):
     env = make_mock_environment()
     updaters = make_updaters(env)
     print "updaters = {}".format(updaters)
     self.assertTrue(updaters, "updaters should not be none")
     self.assertEqual(1, len(updaters), "Should be one updater class")
예제 #8
0
 def test_dispatch(self):
     wanderer = RandomWalk(make_mock_environment())
     event = ObstacleDetected('LeftBumper', self.sensors, self.position)
     wanderer.dispatch(event, None)
예제 #9
0
def main():
    env = make_mock_environment()
    httpd = http.make_server(env, 8080)
    http.start_server(httpd)
예제 #10
0
 def test_no_plan(self):
     actionExecutor = MockActionExecutor()
     executor = PlanExecutor(make_mock_environment(), actionExecutor)
     executor.perform_next_action()
     self.assertEqual(1, actionExecutor.allDoneCount, "all_done() should have been called once")
     self.assertEqual([], actionExecutor.actions, "No actions should have been executed")
예제 #11
0
def main():
    env = make_mock_environment()
    httpd = http.make_server(env, 8080)
    http.start_server(httpd)
예제 #12
0
 def test_make_updaters(self):
     env = make_mock_environment()
     updaters = make_updaters(env)
     print "updaters = {}".format(updaters)
     self.assertTrue(updaters, "updaters should not be none")
     self.assertEqual(1, len(updaters), "Should be one updater class")
예제 #13
0
 def test_Bump(self):
     wanderer = RandomWalk(make_mock_environment())
     actions = wanderer.dispatch(
         ObstacleDetected('LeftBumper', self.sensors, self.position), None)
     self.assertTrue(actions[0].distance < 0, "backoff after a bump")
예제 #14
0
 def test_dispatch(self):
     wanderer = RandomWalk(make_mock_environment())
     event = ObstacleDetected('LeftBumper', self.sensors, self.position)
     wanderer.dispatch(event, None)