mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
⬆️ 升级至 NoneBug 0.3
* 🚧 第一次尝试 50/82 * 62/82 调整了清除数据库的位置 * 🚧 pytest-mock * 🚧 fix test_send * 🚧 intruduce app request * 🚧 close and remove tinydb after each test * 🚧 clean ScheduleTimeWeight table * 🚧 reload http module to test proxy * ✅ 合并 main 的代码 * 🚧 在每次测试结束后关闭browser * 🧑💻 在mcbbsnews渲染异常时添加logger --------- Co-authored-by: hemengyang <hmy0119@gmail.com> Co-authored-by: Azide <rukuy@qq.com>
This commit is contained in:
@@ -3,6 +3,7 @@ from datetime import time
|
||||
from typing import Type
|
||||
|
||||
from nonebug import App
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from nonebot_bison.utils.scheduler_config import SchedulerConfig
|
||||
@@ -60,7 +61,7 @@ async def test_scheduler_without_time(init_scheduler):
|
||||
assert static_res["bilibili-live-t2"] == 3
|
||||
|
||||
|
||||
async def test_scheduler_with_time(app: App, init_scheduler):
|
||||
async def test_scheduler_with_time(app: App, init_scheduler, mocker: MockerFixture):
|
||||
from nonebot_bison.config import config, db_config
|
||||
from nonebot_bison.config.db_config import TimeWeightConfig, WeightConfig
|
||||
from nonebot_bison.platform.bilibili import BilibiliSchedConf
|
||||
@@ -93,7 +94,8 @@ async def test_scheduler_with_time(app: App, init_scheduler):
|
||||
|
||||
await init_scheduler()
|
||||
|
||||
app.monkeypatch.setattr(db_config, "_get_time", lambda: time(1, 30))
|
||||
mocker.patch.object(db_config, "_get_time", return_value=time(1, 30))
|
||||
|
||||
static_res = await get_schedule_times(BilibiliSchedConf, 6)
|
||||
assert static_res["bilibili-t1"] == 1
|
||||
assert static_res["bilibili-t2"] == 2
|
||||
@@ -104,7 +106,7 @@ async def test_scheduler_with_time(app: App, init_scheduler):
|
||||
assert static_res["bilibili-t2"] == 2
|
||||
assert static_res["bilibili-live-t2"] == 3
|
||||
|
||||
app.monkeypatch.setattr(db_config, "_get_time", lambda: time(10, 30))
|
||||
mocker.patch.object(db_config, "_get_time", return_value=time(10, 30))
|
||||
|
||||
static_res = await get_schedule_times(BilibiliSchedConf, 6)
|
||||
assert static_res["bilibili-t2"] == 6
|
||||
|
||||
Reference in New Issue
Block a user