test: migrate OpenAPI and tool-file ORM entities (#40637)

This commit is contained in:
Asuka Minato 2026-08-14 05:34:56 +00:00 committed by GitHub
parent 4b189777c4
commit c36161a73f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 21 deletions

View File

@ -1,4 +1,4 @@
from types import SimpleNamespace
from datetime import datetime
from unittest.mock import MagicMock
from sqlalchemy.orm import Session
@ -6,25 +6,20 @@ from sqlalchemy.orm import Session
from controllers.openapi._input_schema import EMPTY_INPUT_SCHEMA
from controllers.openapi.apps import _EMPTY_PARAMETERS, build_app_describe_response
from controllers.service_api.app.error import AppUnavailableError
from models.model import App, AppMode
class _FakeApp(SimpleNamespace):
pass
def _app() -> _FakeApp:
from datetime import datetime
return _FakeApp(
def _app() -> App:
app = App(
id="11111111-1111-1111-1111-111111111111",
tenant_id="tenant-1",
name="Demo",
mode="chat",
mode=AppMode.CHAT,
description="d",
tags=[],
author_name="me",
updated_at=datetime(2026, 1, 1),
enable_api=True,
)
app.updated_at = datetime(2026, 1, 1)
return app
def test_fields_none_returns_all_blocks(monkeypatch, unbound_session: Session):

View File

@ -4,13 +4,7 @@ import pytest
import core.tools.utils.message_transformer as mt
from core.tools.entities.tool_entities import ToolInvokeMessage
class _FakeToolFile:
def __init__(self, mimetype: str, name: str | None):
self.id = "fake-tool-file-id"
self.mimetype = mimetype
self.name = name or "fake-tool-file.bin"
from models.tools import ToolFile
class _FakeToolFileManager:
@ -39,7 +33,17 @@ class _FakeToolFileManager:
"mimetype": mimetype,
"filename": filename,
}
return _FakeToolFile(mimetype, filename)
tool_file = ToolFile(
user_id=user_id,
tenant_id=tenant_id,
conversation_id=conversation_id,
file_key="tools/fake-tool-file-id",
mimetype=mimetype,
name=filename or "fake-tool-file.bin",
size=len(file_binary),
)
tool_file.id = "fake-tool-file-id"
return tool_file
@pytest.fixture(autouse=True)