⬆️ 适配 Pydantic V2 (#484)

* ⬆️ 适配 Pydantic V2

* 🐛 修复测试报错

* 🐛 适配忘记的 from_orm

* 🐛 忘记的 class-based `config`

* 🐛 更新 red 适配器版本
This commit is contained in:
uy/sun
2024-02-29 19:21:25 +08:00
committed by GitHub
parent ca68964ee9
commit b6e68730b7
17 changed files with 300 additions and 128 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
import pytest
from nonebug.app import App
from nonebot.compat import model_dump
from .utils import get_json
@@ -41,14 +42,14 @@ async def test_subs_export(app: App, init_scheduler):
assert len(data) == 3
nbesf_data = await subscribes_export(lambda x: x)
assert nbesf_data.dict() == get_json("v2/subs_export.json")
assert model_dump(nbesf_data) == get_json("v2/subs_export.json")
nbesf_data_user_234 = await subscribes_export(
lambda stmt: stmt.where(User.user_target == {"platform_type": "QQ Group", "group_id": 2342})
)
assert len(nbesf_data_user_234.groups) == 1
assert len(nbesf_data_user_234.groups[0].subs) == 2
assert nbesf_data_user_234.groups[0].user_target == {
assert model_dump(nbesf_data_user_234.groups[0].user_target) == {
"group_id": 2342,
"platform_type": "QQ Group",
}