ycdemo / fastapi / tests/ test_tutorial/ test_custom_response/ test_tutorial009.py

from pathlib import Path
from typing import Any, cast

from fastapi.testclient import TestClient

from docs_src.custom_response import tutorial009_py310
from docs_src.custom_response.tutorial009_py310 import app

client = TestClient(app)


def test_get(tmp_path: Path):
    file_path: Path = tmp_path / "large-video-file.mp4"
    cast(Any, tutorial009_py310).some_file_path = str(file_path)
    test_content = b"Fake video bytes"
    file_path.write_bytes(test_content)
    response = client.get("/")
    assert response.content == test_content