feat: add models for physical files, policies, and user management

- 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.
This commit is contained in:
2026-02-10 16:25:49 +08:00
parent 62c671e07b
commit 209cb24ab4
92 changed files with 3640 additions and 1444 deletions

View File

@@ -3,9 +3,9 @@ import pytest
@pytest.mark.asyncio
async def test_user_curd():
"""测试数据库的增删改查"""
from models import database, migration
from models.group import Group
from models.user import User
from sqlmodels import database, migration
from sqlmodels.group import Group
from sqlmodels.user import User
await database.init_db(url='sqlite+aiosqlite:///:memory:')
@@ -17,7 +17,7 @@ async def test_user_curd():
created_group = await test_user_group.save(session)
test_user = User(
username='test_user',
email='test_user@test.local',
password='test_password',
group_id=created_group.id
)
@@ -27,7 +27,7 @@ async def test_user_curd():
# 验证用户是否存在
assert created_user.id is not None
assert created_user.username == 'test_user'
assert created_user.email == 'test_user@test.local'
assert created_user.password == 'test_password'
assert created_user.group_id == created_group.id
@@ -35,18 +35,18 @@ async def test_user_curd():
fetched_user = await User.get(session, User.id == created_user.id)
assert fetched_user is not None
assert fetched_user.username == 'test_user'
assert fetched_user.email == 'test_user@test.local'
assert fetched_user.password == 'test_password'
assert fetched_user.group_id == created_group.id
# 测试改 Update
updated_user = await fetched_user.update(
session,
{"username": "updated_user", "password": "updated_password"}
{"email": "updated_user@test.local", "password": "updated_password"}
)
assert updated_user is not None
assert updated_user.username == 'updated_user'
assert updated_user.email == 'updated_user@test.local'
assert updated_user.password == 'updated_password'
# 测试删除 Delete