mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-03 18:06:13 +08:00
move test
This commit is contained in:
parent
ec22fc39f1
commit
74b754f283
14
test/init.py
14
test/init.py
@ -1,14 +0,0 @@
|
||||
import typing
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
import nonebot
|
||||
|
||||
nonebot.init()
|
||||
plugins = nonebot.load_plugins('src/plugins')
|
||||
plugin = list(filter(lambda x: x.name == 'nonebot_hk_reporter', plugins))[0]
|
||||
if typing.TYPE_CHECKING:
|
||||
plugin_module : nonebot_hk_reporter = plugin.module
|
||||
else:
|
||||
plugin_module = plugin.module
|
10
tests/conftest.py
Normal file
10
tests/conftest.py
Normal file
@ -0,0 +1,10 @@
|
||||
import pytest
|
||||
import nonebot
|
||||
|
||||
@pytest.fixture#(scope="module")
|
||||
def plugin_module(tmpdir):
|
||||
nonebot.init(hk_reporter_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]
|
||||
return plugin.module
|
26
tests/test_config_manager.py
Normal file
26
tests/test_config_manager.py
Normal file
@ -0,0 +1,26 @@
|
||||
import pytest
|
||||
import typing
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
|
||||
@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'):
|
||||
config.add_subscribe(
|
||||
user='123',
|
||||
user_type='group',
|
||||
target='weibo_id',
|
||||
target_name='weibo_name',
|
||||
target_type='weibo',
|
||||
cats=[],
|
||||
tags=[])
|
||||
confs = config.list_subscribe('123', 'group')
|
||||
assert(len(confs) == 1)
|
||||
assert(config.target_user_cache['weibo']['weibo_id'] == \
|
||||
[plugin_module.types.User('123', 'group')])
|
@ -1,5 +1,10 @@
|
||||
import pytest
|
||||
from .init import plugin_module
|
||||
import typing
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
import sys
|
||||
sys.path.append('./src/plugins')
|
||||
import nonebot_hk_reporter
|
||||
|
||||
merge_source_9 = [
|
||||
'https://wx1.sinaimg.cn/large/0071VPLMgy1gq0vib7zooj30dx0dxmz5.jpg',
|
||||
@ -18,13 +23,13 @@ merge_source_9 = [
|
||||
]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_9_merge():
|
||||
async def test_9_merge(plugin_module: 'nonebot_hk_reporter'):
|
||||
post = plugin_module.post.Post('', '', '', pics=merge_source_9)
|
||||
await post._pic_merge()
|
||||
assert len(post.pics) == 5
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_6_merge():
|
||||
async def test_6_merge(plugin_module):
|
||||
post = plugin_module.post.Post('', '', '', pics=merge_source_9[0:6]+merge_source_9[9:])
|
||||
await post._pic_merge()
|
||||
assert len(post.pics) == 5
|
Loading…
x
Reference in New Issue
Block a user