- Implement PhysicalFile model to manage physical file references and reference counting. - Create Policy model with associated options and group links for storage policies. - Introduce Redeem and Report models for handling redeem codes and reports. - Add Settings model for site configuration and user settings management. - Develop Share model for sharing objects with unique codes and associated metadata. - Implement SourceLink model for managing download links associated with objects. - Create StoragePack model for managing user storage packages. - Add Tag model for user-defined tags with manual and automatic types. - Implement Task model for managing background tasks with status tracking. - Develop User model with comprehensive user management features including authentication. - Introduce UserAuthn model for managing WebAuthn credentials. - Create WebDAV model for managing WebDAV accounts associated with users.
28 lines
719 B
Python
28 lines
719 B
Python
import pytest
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_initialize_db():
|
|
"""测试创建数据库结构"""
|
|
from sqlmodels import database
|
|
|
|
await database.init_db(url='sqlite:///:memory:')
|
|
|
|
@pytest.fixture
|
|
async def db_session():
|
|
"""测试获取数据库连接Session"""
|
|
from sqlmodels import database
|
|
|
|
await database.init_db(url='sqlite:///:memory:')
|
|
|
|
async for session in database.get_session():
|
|
yield session
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_migration():
|
|
"""测试数据库创建并初始化配置"""
|
|
from sqlmodels import migration
|
|
from sqlmodels import database
|
|
|
|
await database.init_db(url='sqlite:///:memory:')
|
|
|
|
await migration.migration() |