mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
update
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import typing
|
||||
|
||||
import pytest
|
||||
from nonebug.app import App
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
|
||||
sys.path.append("./src/plugins")
|
||||
from nonebot_bison.config.config_legacy import Config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config_legacy(app: App, use_legacy_config):
|
||||
from nonebot_bison import config
|
||||
from nonebot_bison.config import config_legacy as config
|
||||
|
||||
config.start_up()
|
||||
return config.Config()
|
||||
|
||||
|
||||
def test_create_and_get(config_legacy: "Config", app: App):
|
||||
from nonebot_bison import types
|
||||
from nonebot_bison.types import Target
|
||||
|
||||
config_legacy.add_subscribe(
|
||||
user=123,
|
||||
user_type="group",
|
||||
target="weibo_id",
|
||||
target_name="weibo_name",
|
||||
target_type="weibo",
|
||||
cats=[],
|
||||
tags=[],
|
||||
)
|
||||
confs = config_legacy.list_subscribe(123, "group")
|
||||
assert len(confs) == 1
|
||||
assert config_legacy.target_user_cache["weibo"][Target("weibo_id")] == [
|
||||
types.User(123, "group")
|
||||
]
|
||||
assert confs[0]["cats"] == []
|
||||
config_legacy.update_subscribe(
|
||||
user=123,
|
||||
user_type="group",
|
||||
target="weibo_id",
|
||||
target_name="weibo_name",
|
||||
target_type="weibo",
|
||||
cats=["1"],
|
||||
tags=[],
|
||||
)
|
||||
confs = config_legacy.list_subscribe(123, "group")
|
||||
assert len(confs) == 1
|
||||
assert confs[0]["cats"] == ["1"]
|
||||
@@ -0,0 +1,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
async def test_migration(use_legacy_config, db_migration):
|
||||
from nonebot_bison.config.config_legacy import config as config_legacy
|
||||
from nonebot_bison.config.db import data_migrate
|
||||
Reference in New Issue
Block a user