mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-06 03:46:10 +08:00
添加了mcbbsnews中Java版本资讯的单元测试
This commit is contained in:
parent
4091b7228e
commit
5fd50ddc85
@ -58,7 +58,7 @@ class McbbsJavaNews(NewMessage):
|
||||
|
||||
return post_list
|
||||
|
||||
def _gen_post_list(self, raw_post_list):
|
||||
def _gen_post_list(self, raw_post_list) -> list[RawPost]:
|
||||
post_list = []
|
||||
for raw_post in raw_post_list:
|
||||
post = {}
|
||||
@ -80,7 +80,8 @@ class McbbsJavaNews(NewMessage):
|
||||
return post["id"]
|
||||
|
||||
def get_date(self, post: RawPost) -> int:
|
||||
return post["date"]
|
||||
# return post["date"]
|
||||
return None
|
||||
|
||||
def get_category(self, post: RawPost) -> Category:
|
||||
match post["category"]:
|
||||
@ -114,7 +115,8 @@ class McbbsJavaNews(NewMessage):
|
||||
for del_tag in soup.find_all(["div", "span"]):
|
||||
del_tag.extract()
|
||||
# 进一步删除无用尾部
|
||||
soup.select("blockquote > strong")[0].extract()
|
||||
# orig_info=soup.select("blockquote > strong")
|
||||
# orig_info[0].extract()
|
||||
# 展开所有的a,u和strong标签,展开ul,font标签里的font标签
|
||||
for unwrap_tag in soup.find_all(["a", "strong", "u", "ul", "font"]):
|
||||
match unwrap_tag.name:
|
||||
@ -136,7 +138,7 @@ class McbbsJavaNews(NewMessage):
|
||||
if isinstance(sub, NavigableString):
|
||||
text += sub
|
||||
if self._check_str_chinese(text):
|
||||
post_text += "\n{}".format(_format_text(text, 1))
|
||||
post_text += "{}\n".format(_format_text(text, 1))
|
||||
last_is_empty_line = False
|
||||
case "ul":
|
||||
for li_tag in element.find_all("li"):
|
||||
@ -145,7 +147,7 @@ class McbbsJavaNews(NewMessage):
|
||||
if isinstance(sub, NavigableString):
|
||||
text += sub
|
||||
if self._check_str_chinese(text):
|
||||
post_text += "\n{}".format(_format_text(text, 1))
|
||||
post_text += "{}\n".format(_format_text(text, 1))
|
||||
last_is_empty_line = False
|
||||
case _:
|
||||
continue
|
||||
@ -155,7 +157,7 @@ class McbbsJavaNews(NewMessage):
|
||||
post_text += "\n"
|
||||
last_is_empty_line = True
|
||||
else:
|
||||
post_text += "\n{}".format(_format_text(element, 1))
|
||||
post_text += "{}\n".format(_format_text(element, 1))
|
||||
last_is_empty_line = False
|
||||
else:
|
||||
continue
|
||||
@ -167,15 +169,18 @@ class McbbsJavaNews(NewMessage):
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/51.0.2704.63 Safari/537.36"
|
||||
}
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
html = await client.get(post_url, headers=headers)
|
||||
match raw_post["category"]:
|
||||
case "Java版本资讯":
|
||||
text, pic_urls = self._javanews_parser(html)
|
||||
case _:
|
||||
raise CategoryNotSupport(
|
||||
"McbbsNews订阅暂不支持 `{}".format(raw_post["category"])
|
||||
)
|
||||
|
||||
match raw_post["category"]:
|
||||
case "Java版本资讯":
|
||||
text, pic_urls = self._javanews_parser(html.text)
|
||||
case _:
|
||||
raise CategoryNotSupport(
|
||||
"McbbsNews订阅暂不支持 `{}".format(raw_post["category"])
|
||||
)
|
||||
|
||||
return Post(
|
||||
self.name,
|
||||
text=text,
|
||||
|
65
tests/platforms/static/mcbbsnews_java_post-0.txt
Normal file
65
tests/platforms/static/mcbbsnews_java_post-0.txt
Normal file
@ -0,0 +1,65 @@
|
||||
稀有的周四快照!除修复了一些错误以及对一些花里胡哨的标签和命令进行了更改以外,我们还引入了“聊天预览”作为对服务器动态样式的聊天消息进行加密的一种方式。针对这个快照,我们在
|
||||
中保留了测试选项
|
||||
,该选项可以用于测试的
|
||||
选项一起设置为
|
||||
。如果你对此感兴趣,尤其是如果你在开服务器的话,我们希望您对此提供反馈
|
||||
玩的愉快!
|
||||
|
||||
22W19A的修改内容
|
||||
|
||||
监守者和铁傀儡现在只能在固体方块上生成
|
||||
|
||||
22W19A的技术性修改
|
||||
|
||||
服务器现在可以启用聊天预览,这会在聊天框上显示一个受服务器控制的预览
|
||||
对locate和place命令的更改
|
||||
PointofInteresttagsCHATPREVIEW聊天预览COMMANDS命令PLACETEMPLATEPLACE模板Theplacecommandcannowalsoplacetemplatesatagivenlocation.Syntax:placetemplate<template>[pos][rotation][mirror][integrity][-seed](seed前面没有-,加-只是因为不加会变成论坛表情)place命令现在还可以将模板放置在指定位置。用法:placetemplate<template>[pos][rotation][mirror][integrity][-seed]Parameters:参数:POINTOFINTERESTTYPES兴趣点类型FIXEDBUGSIN22W19A22W19A修复的漏洞【寂华、满床迷离译自官网2022年05月12日发布的MinecraftSnapshot22w19a;原作者AdrianÖstergård】
|
||||
服务器现在可以在server.properties中设置previews-chat=true来启用聊天预览
|
||||
当它启动后,聊天框上将出现一个受服务器控制的预览界面,显示消息发送时的样子
|
||||
服务器里可以使用这个功能来预览消息,例如表情和彩色聊天
|
||||
聊天预览会在你输入聊天消息时,甚至是发送之前将其发送给服务器
|
||||
然后服务器将实时返回带样式的预览
|
||||
这允许服务器使用动态消息样式,同时仍允许对聊天进行安全签名
|
||||
当你使用聊天预览进入服务器的时候,客户端上将显示一个警告窗口,但你可以在“聊天设置”中完全禁用这个窗口
|
||||
动态聊天的的样式可以有服务器决定,这只在启用聊天预览启动后才会生效
|
||||
玩家可以在“聊天设置”中启用“仅显示已签名的聊天”来始终显示原始签名的消息
|
||||
添加了用于place命令的模板子命令
|
||||
locate命令移动到了locatestructure,locatebiome移动到了locatebiome
|
||||
添加了locatepoi<type:point_of_interest_type>
|
||||
服务器现在还将在玩家连接后发送一个额外的图标和MOTD数据包
|
||||
这允许设置enable-status=false的服务器给已上线的玩家设置图标和MOTD
|
||||
placetemplate现在的使用方式类似于在UI中使用结构方块的加载按钮
|
||||
template:需要加载和放置的模板(“结构方块文件”)命名空间ID
|
||||
rotation:需要应用的旋转参数(如果省略,则不会选择)
|
||||
mirror:需要应用的镜像参数(如果省略,则不会镜像)
|
||||
integrity:结构完整性介于0和1之间
|
||||
seed:当结构完整性小于1时用于随机补全的种子(?)
|
||||
移除了unemployed和nitwitpoint_of_interest_type标签
|
||||
为所有没有职业的村民添加了point_of_interest_type/acquirable_job_site标签
|
||||
为村庄中的兴趣点添加了point_of_interest_type/village标签
|
||||
为蜜蜂的兴趣点添加了point_of_interest_type/bee_home标签
|
||||
MC-197647-如果有一个方块在头顶,在按住shift键时,玩家无法从方块边缘跳下
|
||||
MC-231600-在被红石充能的大型垂滴叶旁边时,幽匿感测体持续收到震动
|
||||
MC-249130-蝌蚪会在邻近的方块内部孵化,导致他们窒息死亡
|
||||
MC-249161-在睡莲下方时,青蛙会频繁地被卡住
|
||||
MC-249634-监守者被分散注意力后仍会进行闻嗅动作
|
||||
MC-249664-监守者在远离之后会被刷新掉
|
||||
MC-249801-废弃矿井可以分割古代城市
|
||||
MC-249888-监守者在被火球击中时不会被激怒
|
||||
MC-249910-监守者的“迫近”音效未被使用
|
||||
MC-249966-监守者可能停止追逐一个刚刚咆哮过的目标
|
||||
MC-250172-监守者在发射音波时不会转向
|
||||
MC-250233-通过刷怪蛋召唤的监守者会突然丢失AI
|
||||
MC-250255-监守者的音波不会伤害末影龙,只会推开他
|
||||
MC-250272-在方块中生成的监守者没有碰撞箱
|
||||
MC-250353-监守者无法像其他怪物一样在一层雪上生成
|
||||
MC-250357-幽匿感测体和监守者会探测到玩家举起盾牌的动作
|
||||
MC-250948-监守者的攻击范围不会被游戏难度影响
|
||||
MC-250966-监守者的声波造成的死亡不算监守者的击杀
|
||||
MC-251029-监守者会停下并且取消与玩家的敌对状态
|
||||
MC-251263-在打开一个单人游戏时,会显示“Invalidsignatureforprofilepublickey”
|
||||
MC-251316-游戏会在加载含有拼图方块的的区块时会崩溃
|
||||
MC-251321-在生成时,监守者可以被爆炸推开
|
||||
MC-251350-执行/give@sgoat_horn会给予玩家一个没有属性的山羊角
|
||||
MC-251396java.lang.IllegalArgumentException:名字和身份识别号不可以同时是空的
|
||||
MC-251464-中立生物在被监守者的声波打中时,他们不会因为恐慌而逃逸
|
76
tests/platforms/static/mcbbsnews_java_post-1.txt
Normal file
76
tests/platforms/static/mcbbsnews_java_post-1.txt
Normal file
@ -0,0 +1,76 @@
|
||||
1.19:荒野更新的第一个预发布版已发布!
|
||||
这个版本之后的改动,应该都会是漏洞修复。因此,预发布版不会遵循普通快照周三发布的规律,所以请关注后续预发布版的消息;)
|
||||
如同往常,我们对社区给予的反馈、漏洞报告和对快照提出的好主意表示衷心的感谢。迎接预发布版的到来吧!
|
||||
|
||||
1.19-pre1的修改内容
|
||||
|
||||
稍微下调了红树木沼泽中红树的生成数量
|
||||
末影人,骷髅,凋灵骷髅和猪灵现在会在下界中更广的光照强度范围中生成(从光照强度等级0到11)
|
||||
在开始或结束“使用”一个物品时,与物品交互会产生振动(例如弓、十字弩、山羊角、盾和食物)
|
||||
现在潜行时与物品交互不会产生振动
|
||||
在装备栏中装备非盔甲的物品(如南瓜和头颅)现在有单独的装备音效
|
||||
|
||||
1.19-pre1的技术性修改
|
||||
|
||||
自动补全现在可用于placetemplate的模板参数
|
||||
自定义服务器现在可以通过发送新的网络数据包的方式以对特定客户端启用或禁用聊天预览
|
||||
现在,聊天预览在聊天相关指令中也会展示。例如/say和/msg
|
||||
test-rainbow-chat从server.properties中移除了
|
||||
|
||||
添加的游戏事件
|
||||
|
||||
note_block_play带有振动频率6
|
||||
instrument_play带有振动频率15
|
||||
|
||||
1.19-pre1修复的漏洞
|
||||
|
||||
MC-94060-通过物品栏或发射器装备盔甲/鞘翅时不会播放声音
|
||||
MC-134892-PacketBuffer.writeString以byte类型检查最大长度,而readString按字符串长度检查
|
||||
MC-209222-尝试打开MinecraftRealms菜单时会声称客户端已过时,即使快照的版本比正式版更新
|
||||
MC-210279-刷怪笼生成实体时,幽匿感测体不会激活
|
||||
MC-213915-通过物品栏装备盔甲不被算作振动
|
||||
MC-218222-幽匿感测体的距离值被限制为整数,从而导致某些值永远不会被输出
|
||||
MC-225195-山羊在被它们喜爱的食物引诱时不会惊慌
|
||||
MC-230735-“视场角效果”在设置中的描述不准确
|
||||
MC-249141-青蛙行走时没有相应的字幕
|
||||
MC-249164-声音名称entity.frog.tounge拼写错误
|
||||
MC-249209-青蛙在被它们喜爱的食物引诱时不会惊慌
|
||||
MC-249260-蝌蚪不会被黏液球引诱
|
||||
MC-249328-青蛙被黏液球引诱时会跳来跳去
|
||||
MC-249456-与其它幼年生物不同,蝌蚪死亡后会掉落经验
|
||||
MC-249619-幽匿感测体在有实体压在正上方时发出的红石信号强度是它最后感受到声音的强度
|
||||
MC-249711-物品被悦灵从地上捡起时会飞到比悦灵碰撞箱更高的位置
|
||||
MC-249757-“它蔓延了”成就不是“怪物猎人”的子项
|
||||
MC-249834-与玩家的副手交换物品时会产生振动
|
||||
MC-249980-进度“生日快乐歌”的描述中有不正确的大小写
|
||||
MC-250006-英国短毛猫的纹理名称与ID不匹配
|
||||
MC-250019-当村民被僵尸转换为僵尸村民时,幽匿催化体会被触发
|
||||
MC-250317-用桶装一只蝌蚪的字幕为通用的“桶:装满”字幕
|
||||
MC-250351-/tp“参数”在Tab键选项中重复
|
||||
MC-250919-当尝试加载包括由前一个输出字段中的大量字符组成的含有命令方块的区块时,服务器会崩溃
|
||||
MC-250932-山羊角(Goathorn)的字幕未正确大小写
|
||||
MC-250940-使用山羊角时不会检测为振动
|
||||
MC-251132-服务器日志的“游戏测试服务器”消息
|
||||
MC-251312-/say命令里的实体选择器不再被计算
|
||||
MC-251355-红树胎生苗盆栽的模型不正确
|
||||
MC-251405-结构方块的消息被当作聊天消息来格式化
|
||||
MC-251479-语言文件里出现重复的键值对
|
||||
MC-251550-无法在32位操作系统中启动游戏
|
||||
MC-251640-在聊天消息中使用特殊字符时报错:io.netty.handler.codec.EncoderException
|
||||
MC-251641-与监守者发怒有关的游戏崩溃
|
||||
MC-251647-如果打开聊天栏的按键绑定为Enter键,则聊天栏会自动关闭
|
||||
MC-251649-点击“命令不完整”提示后会移除输入框中的斜杠
|
||||
MC-251650-铁傀儡可以在树叶、玻璃、海晶灯等非生成方块上生成
|
||||
MC-251652-除非玩家先看见监守者,否则监守者的出现/咆哮/蓄力/掘地动画不会启动
|
||||
MC-251656-不像/msg命令,/say命令被命令方块、服务器控制台或RCON执行时,应用服务器消息格式会失败
|
||||
MC-251690-监守者可以在任何非完整的固体方块上生成
|
||||
MC-251736-恶魂的火球在反弹后不能击中恶魂
|
||||
MC-251762-使用两条斜杠作前缀时也可执行命令
|
||||
MC-251773-数据生成器的--dev参数不再正确地将NBT转换为SNBT
|
||||
|
||||
【希铁石z译自
|
||||
|
||||
官网2022年05月18日发布的Minecraft1.19Pre-Release1
|
||||
|
||||
;原作者AdrianÖstergård】
|
||||
|
6504
tests/platforms/static/mcbbsnews_new_post_html.html
Normal file
6504
tests/platforms/static/mcbbsnews_new_post_html.html
Normal file
File diff suppressed because one or more lines are too long
2552
tests/platforms/static/mcbbsnews_post_list_html-0.html
Normal file
2552
tests/platforms/static/mcbbsnews_post_list_html-0.html
Normal file
File diff suppressed because one or more lines are too long
2601
tests/platforms/static/mcbbsnews_post_list_html-1.html
Normal file
2601
tests/platforms/static/mcbbsnews_post_list_html-1.html
Normal file
File diff suppressed because one or more lines are too long
218
tests/platforms/static/mcbbsnews_raw_post_list_update.json
Normal file
218
tests/platforms/static/mcbbsnews_raw_post_list_update.json
Normal file
@ -0,0 +1,218 @@
|
||||
[
|
||||
{
|
||||
"url": "thread-1340927-1-1.html",
|
||||
"title": "Minecraft Java版 1.19-pre1 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "希铁石z",
|
||||
"id": "normalthread_1340927",
|
||||
"date": 1652889600
|
||||
},
|
||||
{
|
||||
"url": "thread-1340080-1-1.html",
|
||||
"title": "Mojang Status:服务器出现一些小问题",
|
||||
"category": "快讯",
|
||||
"author": "DreamVoid",
|
||||
"id": "normalthread_1340080",
|
||||
"date": 1652630400
|
||||
},
|
||||
{
|
||||
"url": "thread-1339940-1-1.html",
|
||||
"title": "kinbdogz 就近期荒野更新的风波发表看法",
|
||||
"category": "快讯",
|
||||
"author": "卡狗",
|
||||
"id": "normalthread_1339940",
|
||||
"date": 1652630400
|
||||
},
|
||||
{
|
||||
"url": "thread-1339097-1-1.html",
|
||||
"title": "Minecraft 基岩版 1.18.33 发布(仅 Switch)",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "电量量",
|
||||
"id": "normalthread_1339097",
|
||||
"date": 1652457600
|
||||
},
|
||||
{
|
||||
"url": "thread-1338607-1-1.html",
|
||||
"title": "Minecraft Java版 22w19a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "寂华",
|
||||
"id": "normalthread_1338607",
|
||||
"date": 1652371200
|
||||
},
|
||||
{
|
||||
"url": "thread-1338592-1-1.html",
|
||||
"title": "Minecraft 基岩版 Beta & Preview 1.19.0.32/33 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "苦力怕553",
|
||||
"id": "normalthread_1338592",
|
||||
"date": 1652371200
|
||||
},
|
||||
{
|
||||
"url": "thread-1338588-1-1.html",
|
||||
"title": "请给我们一个真正的“荒野更新”",
|
||||
"category": "时评",
|
||||
"author": "斯乌",
|
||||
"id": "normalthread_1338588",
|
||||
"date": 1652371200
|
||||
},
|
||||
{
|
||||
"url": "thread-1338496-1-1.html",
|
||||
"title": "slicedlime:周三无快照,推迟至周四",
|
||||
"category": "快讯",
|
||||
"author": "橄榄Chan",
|
||||
"id": "normalthread_1338496",
|
||||
"date": 1652198400
|
||||
},
|
||||
{
|
||||
"url": "thread-1336371-1-1.html",
|
||||
"title": "Minecraft 基岩版 1.18.32 发布(仅 Android、NS)【新增 NS 平台】",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "电量量",
|
||||
"id": "normalthread_1336371",
|
||||
"date": 1651766400
|
||||
},
|
||||
{
|
||||
"url": "thread-1335897-1-1.html",
|
||||
"title": "Minecraft 基岩版 Beta & Preview 1.19.0.30/31 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "AzureZeng",
|
||||
"id": "normalthread_1335897",
|
||||
"date": 1651680000
|
||||
},
|
||||
{
|
||||
"url": "thread-1335891-1-1.html",
|
||||
"title": "Minecraft Java版 22w18a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "Aurora_Feather",
|
||||
"id": "normalthread_1335891",
|
||||
"date": 1651680000
|
||||
},
|
||||
{
|
||||
"url": "thread-1333196-1-1.html",
|
||||
"title": "Minecraft 基岩版 Beta & Preview 1.19.0.28/29 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "希铁石z",
|
||||
"id": "normalthread_1333196",
|
||||
"date": 1651161600
|
||||
},
|
||||
{
|
||||
"url": "thread-1332834-1-1.html",
|
||||
"title": "Minecraft 基岩版 1.18.31 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "希铁石z",
|
||||
"id": "normalthread_1332834",
|
||||
"date": 1651075200
|
||||
},
|
||||
{
|
||||
"url": "thread-1332811-1-1.html",
|
||||
"title": "Minecraft Java版 22w17a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "卡狗",
|
||||
"id": "normalthread_1332811",
|
||||
"date": 1651075200
|
||||
},
|
||||
{
|
||||
"url": "thread-1332424-1-1.html",
|
||||
"title": "Mojang Status:正在寻找1.18.30更新问题的解决方案",
|
||||
"category": "基岩快讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1332424",
|
||||
"date": 1650988800
|
||||
},
|
||||
{
|
||||
"url": "thread-1329712-1-1.html",
|
||||
"title": "Minecraft 基岩版 Beta & Preview 1.19.0.26/27 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1329712",
|
||||
"date": 1650470400
|
||||
},
|
||||
{
|
||||
"url": "thread-1329651-1-1.html",
|
||||
"title": "Minecraft Java版 22w16b 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "卡狗",
|
||||
"id": "normalthread_1329651",
|
||||
"date": 1650470400
|
||||
},
|
||||
{
|
||||
"url": "thread-1329644-1-1.html",
|
||||
"title": "Minecraft Java版 22w16a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "希铁石z",
|
||||
"id": "normalthread_1329644",
|
||||
"date": 1650470400
|
||||
},
|
||||
{
|
||||
"url": "thread-1329335-1-1.html",
|
||||
"title": "Minecraft 基岩版 1.18.30 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1329335",
|
||||
"date": 1650384000
|
||||
},
|
||||
{
|
||||
"url": "thread-1328892-1-1.html",
|
||||
"title": "“海王” 杰森·莫玛 有望主演《我的世界》大电影",
|
||||
"category": "快讯",
|
||||
"author": "广药",
|
||||
"id": "normalthread_1328892",
|
||||
"date": 1650297600
|
||||
},
|
||||
{
|
||||
"url": "thread-1327089-1-1.html",
|
||||
"title": "Minecraft 基岩版 Beta & Preview 1.19.0.24/25 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1327089",
|
||||
"date": 1649952000
|
||||
},
|
||||
{
|
||||
"url": "thread-1326640-1-1.html",
|
||||
"title": "Minecraft Java版 22w15a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1326640",
|
||||
"date": 1649865600
|
||||
},
|
||||
{
|
||||
"url": "thread-1323762-1-1.html",
|
||||
"title": "Minecraft 基岩版 Beta & Preview 1.19.0.20 发布",
|
||||
"category": "基岩版本资讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1323762",
|
||||
"date": 1649260800
|
||||
},
|
||||
{
|
||||
"url": "thread-1323662-1-1.html",
|
||||
"title": "Minecraft Java版 22w14a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "卡狗",
|
||||
"id": "normalthread_1323662",
|
||||
"date": 1649260800
|
||||
},
|
||||
{
|
||||
"url": "thread-1321419-1-1.html",
|
||||
"title": "[愚人节] Minecraft Java版 22w13oneBlockAtATime 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "希铁石z",
|
||||
"id": "normalthread_1321419",
|
||||
"date": 1648742400
|
||||
},
|
||||
{
|
||||
"url": "thread-1320986-1-1.html",
|
||||
"title": "Minecraft:近期没有为主机平台添加光线追踪的计划",
|
||||
"category": "基岩快讯",
|
||||
"author": "ArmorRush",
|
||||
"id": "normalthread_1320986",
|
||||
"date": 1648742400
|
||||
},
|
||||
{
|
||||
"url": "thread-1320931-1-1.html",
|
||||
"title": "Minecraft Java版 22w13a 发布",
|
||||
"category": "Java版本资讯",
|
||||
"author": "卡狗",
|
||||
"id": "normalthread_1320931",
|
||||
"date": 1648742400
|
||||
}
|
||||
]
|
@ -9,14 +9,53 @@ from .utils import get_file, get_json
|
||||
@pytest.fixture
|
||||
def mcbbsnews(app: App):
|
||||
from nonebot_bison.platform import platform_manager
|
||||
|
||||
return platform_manager['mcbbsnews']
|
||||
|
||||
return platform_manager["mcbbsnews"]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def raw_post_list():
|
||||
return get_json('mcbbsnews_raw_post_list.json')
|
||||
return get_json("mcbbsnews_raw_post_list.json")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def javanews_post_0():
|
||||
return get_file("mcbbsnews_java_post-0.txt")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def javanews_post_1():
|
||||
return get_file("mcbbsnews_java_post-1.txt")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_javanews_parser(mcbbsnews,raw_post_list):
|
||||
post = await mcbbsnews.parse(raw_post_list)
|
||||
assert post.text==''
|
||||
async def test_javanews_parser(mcbbsnews, raw_post_list, javanews_post):
|
||||
post = await mcbbsnews.parse(raw_post_list[3])
|
||||
assert post.text == javanews_post
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@respx.mock
|
||||
async def test_fetch_new(mcbbsnews, dummy_user_subinfo, javanews_post_1):
|
||||
news_router = respx.get("https://www.mcbbs.net/forum-news-1.html")
|
||||
news_router.mock(
|
||||
return_value=Response(200, text=get_file("mcbbsnews_post_list_html-0.html"))
|
||||
)
|
||||
new_post = respx.get("https://www.mcbbs.net/thread-1340927-1-1.html")
|
||||
new_post.mock(
|
||||
return_value=Response(200, text=get_file("mcbbsnews_new_post_html.html"))
|
||||
)
|
||||
target = ""
|
||||
res = await mcbbsnews.fetch_new_post(target, [dummy_user_subinfo])
|
||||
assert news_router.called
|
||||
assert len(res) == 0
|
||||
news_router.mock(
|
||||
return_value=Response(200, text=get_file("mcbbsnews_post_list_html-1.html"))
|
||||
)
|
||||
res = await mcbbsnews.fetch_new_post(target, [dummy_user_subinfo])
|
||||
assert news_router.called
|
||||
post = res[0][1][0]
|
||||
assert post.target_type == "MCBBS幻翼块讯"
|
||||
assert post.text == javanews_post_1
|
||||
assert post.url == "https://www.mcbbs.net/thread-1340927-1-1.html"
|
||||
assert post.target_name == "Java版本资讯"
|
||||
|
Loading…
x
Reference in New Issue
Block a user