def test_review_changes_docker_path_translation():
    """Test that review_changes tool properly translates Docker paths"""

    with tempfile.TemporaryDirectory() as tmpdir:
        # Set up directories to simulate Docker mount
        host_workspace = Path(tmpdir) / "host_workspace"
        host_workspace.mkdir()
        container_workspace = Path(tmpdir) / "container_workspace"
        container_workspace.mkdir()

        # Create a git repository in the container workspace
        project_dir = container_workspace / "project"
        project_dir.mkdir()

        # Initialize git repo
        import subprocess

        subprocess.run(["git", "init"], cwd=project_dir, capture_output=True)

        # Create a test file
        test_file = project_dir / "test.py"
        test_file.write_text("print('hello')")

        # Stage the file
        subprocess.run(["git", "add", "test.py"], cwd=project_dir, capture_output=True)

        original_env = os.environ.copy()
        try:
            # Simulate Docker environment
            os.environ["WORKSPACE_ROOT"] = str(host_workspace)

            # Reload the module
            importlib.reload(utils.file_utils)
            utils.file_utils.CONTAINER_WORKSPACE = container_workspace

            # Import after reloading to get updated environment
            from tools.precommit import Precommit

            # Create tool instance
            tool = Precommit()

            # Test path translation in prepare_prompt
            request = tool.get_request_model()(
                path=str(host_workspace / "project"),  # Host path that needs translation
                review_type="quick",
                severity_filter="all",
            )

            # This should translate the path and find the git repository
            import asyncio

            result = asyncio.run(tool.prepare_prompt(request))

            # Should find the repository (not raise an error about inaccessible path)
            # If we get here without exception, the path was successfully translated
            assert isinstance(result, str)
            # The result should contain git diff information or indicate no changes
            assert "No git repositories found" not in result or "changes" in result.lower()

        finally:
            os.environ.clear()
            os.environ.update(original_env)
            importlib.reload(utils.file_utils)
Test that review_changes tool properly translates Docker paths
tests/test_docker_path_integration.py