- 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.
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
import pytest
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_group_curd():
|
|
"""测试数据库的增删改查"""
|
|
from sqlmodels import database, migration
|
|
from sqlmodels.group import Group
|
|
|
|
await database.init_db(url='sqlite+aiosqlite:///:memory:')
|
|
|
|
await migration.migration()
|
|
|
|
async for session in database.get_session():
|
|
# 测试增 Create
|
|
test_group = Group(name='test_group')
|
|
created_group = await test_group.save(session)
|
|
|
|
assert created_group is not None
|
|
assert created_group.id is not None
|
|
assert created_group.name == 'test_group'
|
|
|
|
# 测试查 Read
|
|
fetched_group = await Group.get(session, Group.id == created_group.id)
|
|
assert fetched_group is not None
|
|
assert fetched_group.id == created_group.id
|
|
assert fetched_group.name == 'test_group'
|
|
|
|
# 测试更新 Update
|
|
updated_group = await fetched_group.update(session, {"name": "updated_group"})
|
|
|
|
assert updated_group is not None
|
|
assert updated_group.id == fetched_group.id
|
|
assert updated_group.name == 'updated_group'
|
|
|
|
# 测试删除 Delete
|
|
await updated_group.delete(session)
|
|
deleted_group = await Group.get(session, Group.id == updated_group.id)
|
|
assert deleted_group is None
|
|
break
|