"""Tests for validation utilities.""" import pytest from pathlib import Path from unreal_mcp.utils.validation import ( validate_path, validate_class_name, validate_unreal_path, validate_location, validate_rotation, ) def test_validate_path(tmp_path: Path) -> None: """Test path validation.""" # Valid path test_file = tmp_path / "test.txt" test_file.write_text("test") result = validate_path(test_file) assert result == test_file # Path with must_exist=True result = validate_path(test_file, must_exist=True) assert result == test_file # Non-existent path with must_exist=True with pytest.raises(ValueError, match="does not exist"): validate_path(tmp_path / "nonexistent.txt", must_exist=True) def test_validate_class_name() -> None: """Test class name validation.""" # Valid names assert validate_class_name("AWeapon") == "AWeapon" assert validate_class_name("BP_Enemy") == "BP_Enemy" assert validate_class_name("UHealthComponent") == "UHealthComponent" assert validate_class_name("FVector") == "FVector" # Invalid names with pytest.raises(ValueError, match="Invalid class name"): validate_class_name("lowercase") with pytest.raises(ValueError, match="Invalid class name"): validate_class_name("Has Space") with pytest.raises(ValueError, match="Invalid class name"): validate_class_name("123Number") def test_validate_unreal_path() -> None: """Test Unreal content path validation.""" # Valid paths assert validate_unreal_path("/Game/Weapons/BP_Rifle") == "/Game/Weapons/BP_Rifle" assert validate_unreal_path("/Engine/Content/Test") == "/Engine/Content/Test" # Invalid paths with pytest.raises(ValueError, match="must start with"): validate_unreal_path("Game/Weapons") with pytest.raises(ValueError, match="must start with one of"): validate_unreal_path("/Invalid/Path") def test_validate_location() -> None: """Test location validation.""" # Valid locations assert validate_location([0, 0, 0]) == (0.0, 0.0, 0.0) assert validate_location([100.5, -200, 50.25]) == (100.5, -200.0, 50.25) # Invalid locations with pytest.raises(ValueError, match="must have 3 components"): validate_location([0, 0]) with pytest.raises(ValueError, match="must have 3 components"): validate_location([0, 0, 0, 0]) def test_validate_rotation() -> None: """Test rotation validation.""" # Valid rotations assert validate_rotation([0, 0, 0]) == (0.0, 0.0, 0.0) assert validate_rotation([45, 90, -30]) == (45.0, 90.0, -30.0) # Invalid rotations with pytest.raises(ValueError, match="must have 3 components"): validate_rotation([0, 0])