From 9964c673340659d947f08ff141e8a491434fded2 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 24 Apr 2026 15:48:15 +0100 Subject: [PATCH] Fix GUI upload route annotations --- src/repixelizer/gui.py | 2 -- tests/test_gui.py | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/repixelizer/gui.py b/src/repixelizer/gui.py index 01b9669..12a9b6a 100644 --- a/src/repixelizer/gui.py +++ b/src/repixelizer/gui.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import base64 import io import json diff --git a/tests/test_gui.py b/tests/test_gui.py index 066b6dc..77de7ac 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -1,8 +1,12 @@ from __future__ import annotations import importlib.util +import io from pathlib import Path +from PIL import Image +from starlette.datastructures import UploadFile + from repixelizer.pipeline import run_pipeline_rgba from repixelizer.synthetic import fake_pixelize, make_emblem @@ -61,3 +65,20 @@ def test_repo_gui_runner_dispatches_to_gui_main(monkeypatch) -> None: exit_code = module.main(["--host", "127.0.0.1", "--port", "8123", "--reload"]) assert exit_code == 0 assert called == {"host": "127.0.0.1", "port": 8123, "reload": True} + + +def test_create_job_upload_field_validates_without_forward_ref_errors() -> None: + from repixelizer.gui import create_app + + image = Image.new("RGBA", (1, 1), (12, 34, 56, 255)) + buffer = io.BytesIO() + image.save(buffer, format="PNG") + + app = create_app() + route = next(route for route in app.routes if getattr(route, "path", None) == "/api/jobs") + image_field = next(field for field in route.dependant.body_params if field.name == "image") + upload = UploadFile(filename="tiny.png", file=io.BytesIO(buffer.getvalue())) + value, errors = image_field.validate(upload, {}, loc=("body", "image")) + + assert errors == [] + assert value.filename == "tiny.png"