mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🐛 修复测试
This commit is contained in:
parent
08721ad219
commit
07ea6b060e
169
poetry.lock
generated
169
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -41,9 +41,9 @@ python-jose = { extras = ["cryptography"], version = "^3.3.0" }
|
|||||||
python-multipart = "^0.0.9"
|
python-multipart = "^0.0.9"
|
||||||
aiocache = "^0.12.2"
|
aiocache = "^0.12.2"
|
||||||
py-cpuinfo = "^9.0.0"
|
py-cpuinfo = "^9.0.0"
|
||||||
nonebot-plugin-uninfo = "^0.4.1"
|
|
||||||
nonebot-plugin-alconna = "^0.54.0"
|
nonebot-plugin-alconna = "^0.54.0"
|
||||||
tenacity = "^9.0.0"
|
tenacity = "^9.0.0"
|
||||||
|
nonebot-plugin-uninfo = ">0.4.1"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
nonebug = "^0.4"
|
nonebug = "^0.4"
|
||||||
|
|||||||
@ -12,7 +12,7 @@ from pytest_asyncio import is_async_test
|
|||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
from respx import MockRouter
|
from respx import MockRouter
|
||||||
|
|
||||||
from tests.config import BotId, UserId
|
from tests.config import BotId, GroupId, UserId
|
||||||
|
|
||||||
nonebot.load_plugin("nonebot_plugin_session")
|
nonebot.load_plugin("nonebot_plugin_session")
|
||||||
|
|
||||||
@ -64,6 +64,37 @@ def _init_bot(nonebug_init: None):
|
|||||||
nonebot.load_plugins("zhenxun/builtin_plugins")
|
nonebot.load_plugins("zhenxun/builtin_plugins")
|
||||||
nonebot.load_plugins("zhenxun/plugins")
|
nonebot.load_plugins("zhenxun/plugins")
|
||||||
|
|
||||||
|
# 手动缓存 uninfo 所需信息
|
||||||
|
from nonebot_plugin_uninfo import (
|
||||||
|
Scene,
|
||||||
|
SceneType,
|
||||||
|
Session,
|
||||||
|
SupportAdapter,
|
||||||
|
SupportScope,
|
||||||
|
User,
|
||||||
|
)
|
||||||
|
from nonebot_plugin_uninfo.adapters.onebot11.main import fetcher as onebot11_fetcher
|
||||||
|
from nonebot_plugin_uninfo.adapters.onebot12.main import fetcher as onebot12_fetcher
|
||||||
|
|
||||||
|
onebot11_fetcher.session_cache = {
|
||||||
|
f"group_{GroupId.GROUP_ID_LEVEL_5}_{UserId.SUPERUSER}": Session(
|
||||||
|
self_id="test",
|
||||||
|
adapter=SupportAdapter.onebot11,
|
||||||
|
scope=SupportScope.qq_client,
|
||||||
|
scene=Scene(str(GroupId.GROUP_ID_LEVEL_0), SceneType.GROUP),
|
||||||
|
user=User(str(UserId.SUPERUSER)),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
onebot12_fetcher.session_cache = {
|
||||||
|
f"group_{GroupId.GROUP_ID_LEVEL_5}_{UserId.SUPERUSER}": Session(
|
||||||
|
self_id="test",
|
||||||
|
adapter=SupportAdapter.onebot12,
|
||||||
|
scope=SupportScope.qq_client,
|
||||||
|
scene=Scene(str(GroupId.GROUP_ID_LEVEL_0), SceneType.GROUP),
|
||||||
|
user=User(str(UserId.SUPERUSER)),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def app(app: App, tmp_path: Path, mocker: MockerFixture):
|
async def app(app: App, tmp_path: Path, mocker: MockerFixture):
|
||||||
|
|||||||
@ -249,29 +249,32 @@ class ShopManage:
|
|||||||
else:
|
else:
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
plugin_path = base_path / "/".join(module_path.split("."))
|
plugin_path = base_path / "/".join(module_path.split("."))
|
||||||
req_files = repo_api.get_files(
|
try:
|
||||||
f"{replace_module_path}/{REQ_TXT_FILE_STRING}", False
|
req_files = repo_api.get_files(
|
||||||
)
|
f"{replace_module_path}/{REQ_TXT_FILE_STRING}", False
|
||||||
req_files.extend(
|
|
||||||
repo_api.get_files(f"{replace_module_path}/requirement.txt", False)
|
|
||||||
)
|
|
||||||
logger.debug(f"获取插件依赖文件列表: {req_files}", "插件管理")
|
|
||||||
req_download_urls = [
|
|
||||||
await repo_info.get_raw_download_urls(file) for file in req_files
|
|
||||||
]
|
|
||||||
req_paths: list[Path | str] = [plugin_path / file for file in req_files]
|
|
||||||
logger.debug(f"插件依赖文件下载路径: {req_paths}", "插件管理")
|
|
||||||
if req_files:
|
|
||||||
result = await AsyncHttpx.gather_download_file(
|
|
||||||
req_download_urls, req_paths
|
|
||||||
)
|
)
|
||||||
for success in result:
|
req_files.extend(
|
||||||
if not success:
|
repo_api.get_files(f"{replace_module_path}/requirement.txt", False)
|
||||||
raise Exception("插件依赖文件下载失败")
|
)
|
||||||
logger.debug(f"插件依赖文件列表: {req_paths}", "插件管理")
|
logger.debug(f"获取插件依赖文件列表: {req_files}", "插件管理")
|
||||||
install_requirement(plugin_path)
|
req_download_urls = [
|
||||||
|
await repo_info.get_raw_download_urls(file) for file in req_files
|
||||||
|
]
|
||||||
|
req_paths: list[Path | str] = [plugin_path / file for file in req_files]
|
||||||
|
logger.debug(f"插件依赖文件下载路径: {req_paths}", "插件管理")
|
||||||
|
if req_files:
|
||||||
|
result = await AsyncHttpx.gather_download_file(
|
||||||
|
req_download_urls, req_paths
|
||||||
|
)
|
||||||
|
for success in result:
|
||||||
|
if not success:
|
||||||
|
raise Exception("插件依赖文件下载失败")
|
||||||
|
logger.debug(f"插件依赖文件列表: {req_paths}", "插件管理")
|
||||||
|
install_requirement(plugin_path)
|
||||||
|
except ValueError as e:
|
||||||
|
logger.warning("未获取到依赖文件路径...", e=e)
|
||||||
return True
|
return True
|
||||||
raise Exception("插件下载失败")
|
raise Exception("插件下载失败...")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def remove_plugin(cls, plugin_id: str) -> str:
|
async def remove_plugin(cls, plugin_id: str) -> str:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user