示例#1
0
    def get_robots_output(self):
        """ Given a set of commands and plateau dimensions parses this values
            run robot commands, and yield the current coordinates and
            orientations.

        """
        while self.commands:
            coordinates_and_orientation = self.commands.pop(0)
            coordinates = list(
                map(int,
                    coordinates_and_orientation.split(' ')[:2]))
            orientation = coordinates_and_orientation.split(' ')[-1]
            robot_commands = self.commands.pop(0)

            robot = Robot(coordinates, orientation, self.plateau_dimensions)
            [robot.run(command) for command in robot_commands]
            yield robot.get_coordinate_and_orientation_text()
示例#2
0
 def test__do__given_invalid_command__it_should_raise_invalid_command_error(
         self):
     target = Robot([2, 2], 'N', [5, 5])
     with pytest.raises(InvalidCommandError):
         target.run('foo')
示例#3
0
 def test__do__given_valid_command__it_should_run_without_errors(
         self, command):
     target = Robot([2, 2], 'N', [5, 5])
     target.run(command)