def test_achieve(self): current = ['hand empty', 'arm down'] goal = 'baseball in air' expected = [ 'arm down', 'baseball in air', 'grabbing baseball', 'raising arm', 'throwing baseball' ] final = gps.achieve(current, ops, goal, []) self.assertEqual(set(expected), set(final))
def test_achieve(self): current = ['hand empty', 'arm down'] goal = 'baseball in air' expected = ['arm down', 'baseball in air', 'grabbing baseball', 'raising arm', 'throwing baseball'] final = gps.achieve(current, ops, goal, []) self.assertEqual(set(expected), set(final))
def test_achieve_try_another_op(self): current = ['hand empty', 'arm down'] levitate_baseball = {'action': 'levitate baseball', 'preconds': ['magic'], 'add': ['baseball in air'], 'delete': []} goal = 'baseball in air' new_ops = [levitate_baseball] + ops final = gps.achieve(current, new_ops, goal, []) expected = ['arm down', 'baseball in air', 'grabbing baseball', 'raising arm', 'throwing baseball'] self.assertEqual(set(expected), set(final))
def test_achieve_try_another_op(self): current = ['hand empty', 'arm down'] levitate_baseball = { 'action': 'levitate baseball', 'preconds': ['magic'], 'add': ['baseball in air'], 'delete': [] } goal = 'baseball in air' new_ops = [levitate_baseball] + ops final = gps.achieve(current, new_ops, goal, []) expected = [ 'arm down', 'baseball in air', 'grabbing baseball', 'raising arm', 'throwing baseball' ] self.assertEqual(set(expected), set(final))
def test_achieve_prevent_loop(self): current = ['hand empty', 'arm down'] goal = 'baseball in air' stack = ['baseball in air', 'levitate'] self.assertFalse(gps.achieve(current, ops, goal, stack))
def test_achieve_already_done(self): expected = ['hand empty', 'arm down'] final = gps.achieve(expected, ops, 'arm down', []) self.assertEqual(set(expected), set(final))