def test_walk_right(self): # Test all valid walk right commands expected_cmds = ["<WK=WR,0>"] + ["<WK=WR,{}>".format(i) for i in range(2, 10)] for i in range(1, 10): builder = WalkCommandBuilder(WalkDirection.right, steps=i) actual_cmd = builder.build() expected_cmd = expected_cmds[i - 1] self.assertEqual(expected_cmd, actual_cmd)
def test_invalid_range(self): # Test invalid walk commands: 0, i.e. less than 1 with self.assertRaises(ValueError): WalkCommandBuilder(WalkDirection.forward, steps=0) # Test invalid walk commands: 11, i.e. greater than 10 with self.assertRaises(ValueError): WalkCommandBuilder(WalkDirection.forward, steps=11)
def walk_right(steps: int = 4) -> WalkCommandBuilder: """ An action to make the robot walk right a given number of steps. :param steps: the number of steps to take. Must be between 1 and 10 steps. A step means the left foot takes a single step, making the robot walk right. :return: a walk right command. """ return WalkCommandBuilder(WalkDirection.right, steps=steps)
def walk_backward(steps: int = 4) -> WalkCommandBuilder: """ Make the robot walk backward a given number of steps. :param steps: the number of steps to take. Must be between 1 and 10 steps. A step means both feet step backward once time each. :return: a walk backward command. """ return WalkCommandBuilder(WalkDirection.backward, steps=steps)