mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
update test
This commit is contained in:
parent
b5e8a508f3
commit
4aae3a8c6f
@ -5,18 +5,18 @@ import typing
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
@pytest.fixture#(scope="module")
|
||||
def plugin_module(tmpdir):
|
||||
nonebot.init(hk_reporter_config_path=str(tmpdir))
|
||||
nonebot.init(bison_config_path=str(tmpdir))
|
||||
nonebot.load_plugins('src/plugins')
|
||||
plugins = nonebot.get_loaded_plugins()
|
||||
plugin = list(filter(lambda x: x.name == 'nonebot_hk_reporter', plugins))[0]
|
||||
plugin = list(filter(lambda x: x.name == 'nonebot_bison', plugins))[0]
|
||||
return plugin.module
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_user_subinfo(plugin_module: 'nonebot_hk_reporter'):
|
||||
def dummy_user_subinfo(plugin_module: 'nonebot_bison'):
|
||||
user = plugin_module.types.User('123', 'group')
|
||||
return plugin_module.types.UserSubInfo(
|
||||
user=user,
|
||||
|
@ -7,12 +7,12 @@ import feedparser
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
from .utils import get_json, get_file
|
||||
|
||||
@pytest.fixture
|
||||
def arknights(plugin_module: 'nonebot_hk_reporter'):
|
||||
def arknights(plugin_module: 'nonebot_bison'):
|
||||
return plugin_module.platform.platform_manager['arknights']
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
|
@ -5,7 +5,7 @@ from httpx import Response
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
from .utils import get_json
|
||||
|
||||
@ -14,7 +14,7 @@ def bing_dy_list():
|
||||
return get_json('bilibili_bing_list.json')['data']['cards']
|
||||
|
||||
@pytest.fixture
|
||||
def bilibili(plugin_module: 'nonebot_hk_reporter'):
|
||||
def bilibili(plugin_module: 'nonebot_bison'):
|
||||
return plugin_module.platform.platform_manager['bilibili']
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -7,12 +7,12 @@ import feedparser
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
from .utils import get_json, get_file
|
||||
|
||||
@pytest.fixture
|
||||
def monster_siren(plugin_module: 'nonebot_hk_reporter'):
|
||||
def monster_siren(plugin_module: 'nonebot_bison'):
|
||||
return plugin_module.platform.platform_manager['monster-siren']
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
|
@ -8,10 +8,10 @@ from httpx import Response
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
@pytest.fixture
|
||||
def ncm_artist(plugin_module: 'nonebot_hk_reporter'):
|
||||
def ncm_artist(plugin_module: 'nonebot_bison'):
|
||||
return plugin_module.platform.platform_manager['ncm-artist']
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
|
@ -7,9 +7,9 @@ import pytest
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
from nonebot_hk_reporter.types import *
|
||||
from nonebot_hk_reporter.post import Post
|
||||
import nonebot_bison
|
||||
from nonebot_bison.types import *
|
||||
from nonebot_bison.post import Post
|
||||
|
||||
from time import time
|
||||
now = time()
|
||||
@ -26,18 +26,18 @@ raw_post_list_2 = raw_post_list_1 + [
|
||||
]
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_user(plugin_module: 'nonebot_hk_reporter'):
|
||||
def dummy_user(plugin_module: 'nonebot_bison'):
|
||||
user = plugin_module.types.User('123', 'group')
|
||||
return user
|
||||
|
||||
@pytest.fixture
|
||||
def user_info_factory(plugin_module: 'nonebot_hk_reporter', dummy_user):
|
||||
def user_info_factory(plugin_module: 'nonebot_bison', dummy_user):
|
||||
def _user_info(category_getter, tag_getter):
|
||||
return plugin_module.types.UserSubInfo(dummy_user, category_getter, tag_getter)
|
||||
return _user_info
|
||||
|
||||
@pytest.fixture
|
||||
def mock_platform_without_cats_tags(plugin_module: 'nonebot_hk_reporter'):
|
||||
def mock_platform_without_cats_tags(plugin_module: 'nonebot_bison'):
|
||||
class MockPlatform(plugin_module.platform.platform.NewMessage,
|
||||
plugin_module.platform.platform.TargetMixin):
|
||||
|
||||
@ -76,7 +76,7 @@ def mock_platform_without_cats_tags(plugin_module: 'nonebot_hk_reporter'):
|
||||
return MockPlatform()
|
||||
|
||||
@pytest.fixture
|
||||
def mock_platform(plugin_module: 'nonebot_hk_reporter'):
|
||||
def mock_platform(plugin_module: 'nonebot_bison'):
|
||||
class MockPlatform(plugin_module.platform.platform.NewMessage,
|
||||
plugin_module.platform.platform.TargetMixin):
|
||||
|
||||
@ -123,7 +123,7 @@ def mock_platform(plugin_module: 'nonebot_hk_reporter'):
|
||||
return MockPlatform()
|
||||
|
||||
@pytest.fixture
|
||||
def mock_platform_no_target(plugin_module: 'nonebot_hk_reporter'):
|
||||
def mock_platform_no_target(plugin_module: 'nonebot_bison'):
|
||||
class MockPlatform(plugin_module.platform.platform.NewMessage,
|
||||
plugin_module.platform.platform.NoTargetMixin):
|
||||
|
||||
@ -174,7 +174,7 @@ def mock_platform_no_target(plugin_module: 'nonebot_hk_reporter'):
|
||||
return MockPlatform()
|
||||
|
||||
@pytest.fixture
|
||||
def mock_platform_no_target_2(plugin_module: 'nonebot_hk_reporter'):
|
||||
def mock_platform_no_target_2(plugin_module: 'nonebot_bison'):
|
||||
class MockPlatform(plugin_module.platform.platform.NewMessage,
|
||||
plugin_module.platform.platform.NoTargetMixin):
|
||||
|
||||
@ -230,7 +230,7 @@ def mock_platform_no_target_2(plugin_module: 'nonebot_hk_reporter'):
|
||||
return MockPlatform()
|
||||
|
||||
@pytest.fixture
|
||||
def mock_status_change(plugin_module: 'nonebot_hk_reporter'):
|
||||
def mock_status_change(plugin_module: 'nonebot_bison'):
|
||||
class MockPlatform(plugin_module.platform.platform.StatusChange,
|
||||
plugin_module.platform.platform.NoTargetMixin):
|
||||
|
||||
@ -359,7 +359,7 @@ async def test_status_change(mock_status_change, user_info_factory):
|
||||
assert(len(res4) == 0)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_group(plugin_module: 'nonebot_hk_reporter', mock_platform_no_target, mock_platform_no_target_2, user_info_factory):
|
||||
async def test_group(plugin_module: 'nonebot_bison', mock_platform_no_target, mock_platform_no_target_2, user_info_factory):
|
||||
group_platform = plugin_module.platform.platform.NoTargetGroup([mock_platform_no_target, mock_platform_no_target_2])
|
||||
res1 = await group_platform.fetch_new_post('dummy', [user_info_factory(lambda _: [1,4], lambda _: [])])
|
||||
assert(len(res1) == 0)
|
||||
|
@ -9,12 +9,12 @@ import feedparser
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
from .utils import get_json, get_file
|
||||
|
||||
@pytest.fixture
|
||||
def weibo(plugin_module: 'nonebot_hk_reporter'):
|
||||
def weibo(plugin_module: 'nonebot_bison'):
|
||||
return plugin_module.platform.platform_manager['weibo']
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
|
@ -4,14 +4,14 @@ import typing
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
@pytest.fixture
|
||||
def config(plugin_module):
|
||||
plugin_module.config.start_up()
|
||||
return plugin_module.config.Config()
|
||||
|
||||
def test_create_and_get(config: 'nonebot_hk_reporter.config.Config', plugin_module: 'nonebot_hk_reporter'):
|
||||
def test_create_and_get(config: 'nonebot_bison.config.Config', plugin_module: 'nonebot_bison'):
|
||||
config.add_subscribe(
|
||||
user='123',
|
||||
user_type='group',
|
||||
|
@ -4,7 +4,7 @@ import typing
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
merge_source_9 = [
|
||||
'https://wx1.sinaimg.cn/large/0071VPLMgy1gq0vib7zooj30dx0dxmz5.jpg',
|
||||
@ -23,7 +23,7 @@ merge_source_9 = [
|
||||
]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_9_merge(plugin_module: 'nonebot_hk_reporter'):
|
||||
async def test_9_merge(plugin_module: 'nonebot_bison'):
|
||||
post = plugin_module.post.Post('', '', '', pics=merge_source_9)
|
||||
await post._pic_merge()
|
||||
assert len(post.pics) == 5
|
||||
|
@ -4,11 +4,11 @@ import typing
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot_bison
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.render
|
||||
async def test_render(plugin_module: 'nonebot_hk_reporter'):
|
||||
async def test_render(plugin_module: 'nonebot_bison'):
|
||||
render = plugin_module.utils.Render()
|
||||
res = await render.text_to_pic('''a\nbbbbbbbbbbbbbbbbbbbbbb\ncd
|
||||
<h1>中文</h1>
|
||||
|
Loading…
x
Reference in New Issue
Block a user