mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-08 04:43:00 +08:00
添加测试
This commit is contained in:
parent
8a4a7ad26c
commit
945f00f531
129
tests/platforms/static/tag_cases.json
vendored
Normal file
129
tests/platforms/static/tag_cases.json
vendored
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": [
|
||||||
|
"222"
|
||||||
|
],
|
||||||
|
"banned_tags": [
|
||||||
|
"555"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"result": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": [],
|
||||||
|
"banned_tags": [
|
||||||
|
"555"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"result": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": [],
|
||||||
|
"banned_tags": [
|
||||||
|
"444"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"result": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": [
|
||||||
|
"222"
|
||||||
|
],
|
||||||
|
"banned_tags": []
|
||||||
|
},
|
||||||
|
"result": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": [],
|
||||||
|
"banned_tags": []
|
||||||
|
},
|
||||||
|
"result": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": ["111","555","666"],
|
||||||
|
"banned_tags": []
|
||||||
|
},
|
||||||
|
"result": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": ["111","555"],
|
||||||
|
"banned_tags": ["333"]
|
||||||
|
},
|
||||||
|
"result": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": ["111","333"],
|
||||||
|
"banned_tags": ["111"]
|
||||||
|
},
|
||||||
|
"result": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"case": {
|
||||||
|
"post_tags": [
|
||||||
|
"111",
|
||||||
|
"222",
|
||||||
|
"333",
|
||||||
|
"444"
|
||||||
|
],
|
||||||
|
"subscribed_tags": ["222"],
|
||||||
|
"banned_tags": ["555","333"]
|
||||||
|
},
|
||||||
|
"result": true
|
||||||
|
}
|
||||||
|
]
|
19
tests/platforms/test_platform_tag_filter.py
Normal file
19
tests/platforms/test_platform_tag_filter.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import pytest
|
||||||
|
from nonebug.app import App
|
||||||
|
|
||||||
|
from .utils import get_json
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def test_cases():
|
||||||
|
return get_json("tag_cases.json")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_filter_user_custom_tag(app: App, test_cases):
|
||||||
|
from nonebot_bison.platform import platform_manager
|
||||||
|
|
||||||
|
bilibili = platform_manager["bilibili"]
|
||||||
|
for case in test_cases:
|
||||||
|
res = bilibili.is_banned_post(**case["case"])
|
||||||
|
assert res == case["result"]
|
Loading…
x
Reference in New Issue
Block a user