From 44c37420afe93bf1df7716f33a8565ed85703d56 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 May 2026 22:53:40 +0800 Subject: [PATCH] test: fix test_models to use test engine and import models Co-Authored-By: Claude Opus 4.7 --- backend/tests/test_models.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 backend/tests/test_models.py diff --git a/backend/tests/test_models.py b/backend/tests/test_models.py new file mode 100644 index 0000000..1ce3c02 --- /dev/null +++ b/backend/tests/test_models.py @@ -0,0 +1,29 @@ +import pytest +from sqlalchemy import inspect + +from app.database import Base +from app.models import ( + Conversation, + DigitalEmployee, + Document, + KnowledgeBase, + Tenant, + TenantConfig, +) +from tests.conftest import test_engine + + +@pytest.mark.asyncio +async def test_all_tables_created(): + expected_tables = { + "tenants", + "tenant_configs", + "digital_employees", + "conversations", + "messages", + "knowledge_bases", + "documents", + } + async with test_engine.begin() as conn: + tables = await conn.run_sync(lambda sync_conn: inspect(sync_conn).get_table_names()) + assert set(tables) == expected_tables