def test_default_constructor(self): robot = RobotModel.MobileRobot() self.assertFalse(robot.get_position().is_valid()) self.assertEqual( Geometry.Point(Geometry.Point.INVALID_POSITION, Geometry.Point.INVALID_POSITION), robot.get_position()) self.assertFalse(robot.get_orientation().is_valid())
def test_is_valid_position_in_margin_board(self): self.VALID_BOARD = RobotModel.Board(Geometry.Point(0, 0), Geometry.Point(10, 10)) left_margin_point = Geometry.Point( self.VALID_BOARD.get_bottom_left().get_x(), self.VALID_BOARD.get_bottom_left().get_y() + 1) bottom_margin_point = Geometry.Point( self.VALID_BOARD.get_bottom_left().get_x() + 1, self.VALID_BOARD.get_bottom_left().get_y()) right_margin_point = Geometry.Point( self.VALID_BOARD.get_top_right().get_x(), self.VALID_BOARD.get_top_right().get_y() - 1) top_margin_point = Geometry.Point( self.VALID_BOARD.get_top_right().get_x() - 1, self.VALID_BOARD.get_top_right().get_y()) bottom_left_margin_point = self.VALID_BOARD.get_bottom_left() top_left_margin_point = self.VALID_BOARD.get_top_right() top_right_margin_point = self.VALID_BOARD.get_top_right() bottom_right_margin_point = self.VALID_BOARD.get_bottom_left() self.assertTrue(self.VALID_BOARD.is_valid_position(left_margin_point)) self.assertTrue( self.VALID_BOARD.is_valid_position(bottom_margin_point)) self.assertTrue(self.VALID_BOARD.is_valid_position(right_margin_point)) self.assertTrue(self.VALID_BOARD.is_valid_position(top_margin_point)) self.assertTrue( self.VALID_BOARD.is_valid_position(bottom_left_margin_point)) self.assertTrue( self.VALID_BOARD.is_valid_position(top_left_margin_point)) self.assertTrue( self.VALID_BOARD.is_valid_position(top_right_margin_point)) self.assertTrue( self.VALID_BOARD.is_valid_position(bottom_right_margin_point))
def test_is_valid_position_outside_board(self): self.VALID_BOARD = RobotModel.Board(Geometry.Point(0, 0), Geometry.Point(10, 10)) out_left_point = Geometry.Point( self.VALID_BOARD.get_bottom_left().get_x() - 1, self.VALID_BOARD.get_bottom_left().get_y()) out_bottom_point = Geometry.Point( self.VALID_BOARD.get_bottom_left().get_x(), self.VALID_BOARD.get_bottom_left().get_y() - 1) out_right_point = Geometry.Point( self.VALID_BOARD.get_top_right().get_x() + 1, self.VALID_BOARD.get_top_right().get_y()) out_top_point = Geometry.Point( self.VALID_BOARD.get_top_right().get_x(), self.VALID_BOARD.get_top_right().get_y() + 1) out_bottom_left_point = Geometry.Point( self.VALID_BOARD.get_bottom_left().get_x() - 1, self.VALID_BOARD.get_bottom_left().get_y() - 1) out_top_left_point = Geometry.Point( self.VALID_BOARD.get_bottom_left().get_x() - 1, self.VALID_BOARD.get_top_right().get_y() + 1) out_top_right_point = Geometry.Point( self.VALID_BOARD.get_top_right().get_x() + 1, self.VALID_BOARD.get_top_right().get_y() + 1) out_bottom_right_point = Geometry.Point( self.VALID_BOARD.get_top_right().get_x() + 1, self.VALID_BOARD.get_bottom_left().get_y() - 1) self.assertFalse(self.VALID_BOARD.is_valid_position(out_left_point)) self.assertFalse(self.VALID_BOARD.is_valid_position(out_bottom_point)) self.assertFalse(self.VALID_BOARD.is_valid_position(out_right_point)) self.assertFalse(self.VALID_BOARD.is_valid_position(out_top_point)) self.assertFalse( self.VALID_BOARD.is_valid_position(out_bottom_left_point)) self.assertFalse( self.VALID_BOARD.is_valid_position(out_top_left_point)) self.assertFalse( self.VALID_BOARD.is_valid_position(out_top_right_point)) self.assertFalse( self.VALID_BOARD.is_valid_position(out_bottom_right_point))
def set_request_arguments_from_input_interpreter_arguments( arguments, place_request): if len(arguments) == 3: place_request.set_position( Geometry.Point(int(arguments[0]), int(arguments[1]))) place_request.set_orientation(Geometry.Orientation[arguments[2]])