添加测试

This commit is contained in:
Azide 2022-09-01 01:59:46 +08:00
parent 8a4a7ad26c
commit 945f00f531
2 changed files with 148 additions and 0 deletions

129
tests/platforms/static/tag_cases.json vendored Normal file
View 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
}
]

View 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"]