mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-03 18:06:13 +08:00
* 🚧 第一次尝试 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>
28 lines
686 B
Python
28 lines
686 B
Python
import importlib
|
|
|
|
from nonebug import App
|
|
from pytest_mock import MockerFixture
|
|
|
|
|
|
async def test_without_proxy(app: App):
|
|
from nonebot_bison.utils import http_client
|
|
|
|
c = http_client()
|
|
assert not c._mounts
|
|
req = c.build_request("GET", "http://example.com")
|
|
assert "Chrome" in req.headers["User-Agent"]
|
|
|
|
|
|
async def test_with_proxy(app: App, mocker: MockerFixture):
|
|
from nonebot_bison.plugin_config import plugin_config
|
|
|
|
mocker.patch.object(plugin_config, "bison_proxy", "http://example.com")
|
|
from nonebot_bison.utils import http
|
|
|
|
importlib.reload(http)
|
|
|
|
from nonebot_bison.utils.http import http_client
|
|
|
|
c = http_client()
|
|
assert c._mounts
|