"""HEAD is served for GET Automation routes (contract matrix).""" from __future__ import annotations from fastapi import FastAPI from fastapi.testclient import TestClient from app.api.middleware import HeadAsGetMiddleware def test_head_as_get_middleware_strips_body() -> None: app = FastAPI() app.add_middleware(HeadAsGetMiddleware) @app.get("/api/vcenter/vm") def list_vms() -> list[dict[str, str]]: return [{"vm": "vm-101", "name": "web-01"}] client = TestClient(app) get = client.get("/api/vcenter/vm") assert get.status_code == 200 assert get.json()[0]["vm"] == "vm-101" head = client.head("/api/vcenter/vm") assert head.status_code == 200 assert head.content in (b"", None) or head.text == ""