import pytest from robot.movement import RobotMovement from robot.controller import RobotController, Cell, CellStatus from robot.config import ConfigParser @pytest.fixture def robot_movement(): return RobotMovement() @pytest.fixture def robot_controller(): return RobotController(ConfigParser()) class TestRobotMovement: def test_init_position(self, robot_movement: RobotMovement): assert robot_movement.get_position() == (0.0, 0.0, 0.0) assert not robot_movement.is_moving def test_set_speed(self, robot_movement: RobotMovement): robot_movement.set_speed(200.0) assert robot_movement.speed == 200.0 with pytest.raises(ValueError): robot_movement.set_speed(-100.0) def test_move_to_position(self, robot_movement: RobotMovement): result = robot_movement.move_to_position(100.0, 200.0, 300.0) assert result is True assert robot_movement.get_position() == (100.0, 200.0, 300.0) def test_move_relative(self, robot_movement: RobotMovement): robot_movement.move_to_position(100.0, 100.0, 100.0) result = robot_movement.move_relative(50.0, -50.0, 25.0) assert result is True assert robot_movement.get_position() == (150.0, 50.0, 125.0) class TestRobotController: def test_init_controller(self, robot_controller: RobotController): assert len(robot_controller.devices) > 0 assert robot_controller.feeder is not None assert not robot_controller.gripper_occupied @pytest.mark.asyncio async def test_get_next_free_slot(self, robot_controller: RobotController): slot = robot_controller.get_next_free_slot() assert slot is not None assert not slot.occupied @pytest.mark.asyncio async def test_insert_and_collect_cell(self, robot_controller: RobotController): # Test cell insertion cell = Cell(id="test_cell", status=CellStatus.WAITING) slot = robot_controller.get_next_free_slot() robot_controller.gripper_occupied = True await robot_controller.insert_cell_to_slot(cell, slot) assert slot.occupied assert slot.cell_id == cell.id # Test cell collection collected_cell = await robot_controller.collect_cell_from_slot(slot) assert not slot.occupied assert slot.cell_id is None assert collected_cell == cell.id