mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
* 🐛 调整ruff的pytest警告 * 🐛 调整导入关系警告 * 🐛 删除奇怪无用的赋值和取值逻辑 * ✅ 不同测试部分所用变量应加以区分 * 🐛 subs_io model添加默认值 * 🐛 修完所有的 ruff PT001 警告 * 🔧 按ruff建议修改ruff配置 warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`: - 'ignore' -> 'lint.ignore' - 'select' -> 'lint.select' --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
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.config import config_legacy as config
|
|
|
|
config.start_up()
|
|
|
|
yield config.Config()
|
|
|
|
config.Config().db.close()
|
|
|
|
|
|
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"]
|