添加recruitSolver测试和修复tag筛选错误
This commit is contained in:
parent
469a79919d
commit
522b7b0e8e
2 changed files with 57 additions and 23 deletions
|
@ -403,26 +403,35 @@ class RecruitSolver(SceneGraphSolver):
|
|||
}
|
||||
|
||||
for key, value in result_dict.items():
|
||||
if (
|
||||
min(item["star"] for item in value["result"]) == 1
|
||||
and max(item["star"] for item in value["result"]) > 1
|
||||
):
|
||||
try:
|
||||
if (
|
||||
min(item["star"] for item in value["result"]) == 1
|
||||
and max(item["star"] for item in value["result"]) > 1
|
||||
):
|
||||
value["result"] = [
|
||||
item for item in value["result"] if item["star"] >= 3
|
||||
]
|
||||
if "高级资深干员" not in key:
|
||||
value["result"] = [
|
||||
item for item in value["result"] if item["star"] < 6
|
||||
]
|
||||
|
||||
value["star"] = min(item["star"] for item in value["result"])
|
||||
value["result"] = [
|
||||
item for item in value["result"] if item["star"] >= 3
|
||||
item for item in value["result"] if item["star"] == value["star"]
|
||||
]
|
||||
|
||||
value["star"] = min(item["star"] for item in value["result"])
|
||||
value["result"] = [
|
||||
item for item in value["result"] if item["star"] == value["star"]
|
||||
]
|
||||
|
||||
except ValueError:
|
||||
pass
|
||||
result_dict = {
|
||||
key: value for key, value in result_dict.items() if value["result"]
|
||||
}
|
||||
result = {
|
||||
6: [],
|
||||
5: [],
|
||||
1: [],
|
||||
4: [],
|
||||
3: [],
|
||||
2: [],
|
||||
1: [],
|
||||
}
|
||||
for tag in result_dict:
|
||||
result[result_dict[tag]["star"]].append(
|
||||
|
|
|
@ -1,23 +1,48 @@
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from mower.solvers.recruit import RecruitSolver
|
||||
|
||||
result_check = {
|
||||
("召唤", "辅助干员", "控场"): ["梅尔", "格劳克斯"],
|
||||
("特种干员", "生存", "削弱"): ["狮蝎", "槐琥"],
|
||||
("重装干员", "输出", "防护"): ["星极", "雷蛇", "火神", "石棉"],
|
||||
("狙击干员", "输出", "削弱", "远程位", "近战位"): ["槐琥"],
|
||||
("狙击干员", "输出", "削弱", "远程位"): ["流星", "夜烟"],
|
||||
("快速复活", "削弱", "近战位"): ["槐琥"],
|
||||
("输出", "防护", "爆发", "狙击干员"): ["石棉", "雷蛇", "星极", "守林人", "火神"],
|
||||
("爆发", "远程位", "治疗", "输出"): ["夜魔", "守林人", "莱恩哈特"],
|
||||
("狙击干员", "生存", "减速"): ["白雪", "安比尔", "杰西卡", "梅"],
|
||||
("生存", "减速"): ["梓兰", "泡普卡", "玫兰莎"],
|
||||
("先锋干员", "支援", "控场"): ["德克萨斯", "极境", "凛冬"],
|
||||
("减速", "支援"): ["清流", "杜宾"],
|
||||
("特种干员",): ["砾", "孑", "暗索", "阿消"],
|
||||
("控场",): ["卡达"],
|
||||
("爆发",): ["刻刀"],
|
||||
("支援",): ["杜宾", "清流"],
|
||||
("削弱",): ["夜烟", "流星"],
|
||||
("快速复活",): ["砾", "孑"],
|
||||
("位移",): ["暗索", "阿消"],
|
||||
}
|
||||
|
||||
|
||||
class TestRecruitCal(unittest.TestCase):
|
||||
@unittest.mock.patch.object(RecruitSolver, "__init__", lambda x: None)
|
||||
@patch.object(RecruitSolver, "__init__", lambda x: None)
|
||||
def setUp(self):
|
||||
self.test_class = RecruitSolver()
|
||||
self.test_class.recruit_order = [6, 5, 1, 4, 3, 2]
|
||||
|
||||
def test_recruit_cal_with_order_1(self):
|
||||
recruit_tags = ["重装干员", "先锋干员", "高级资深干员", "支援", "支援机械"]
|
||||
results = self.test_class.recruit_cal(recruit_tags)
|
||||
print(f"顺序为 {self.test_class.recruit_order}")
|
||||
print(results.keys())
|
||||
for i in results:
|
||||
for result in results[i]:
|
||||
for agent in result["result"]:
|
||||
print(f"{i} {result['tag']} {agent['name']}")
|
||||
def test_recruit_cal(self):
|
||||
for tags in result_check:
|
||||
results = self.test_class.recruit_cal(tags)
|
||||
results = {key: value for key, value in results.items() if value}
|
||||
results = list(results.items())[0][1] # [0]["result"]["result"]
|
||||
agent = []
|
||||
for i in results:
|
||||
for res in i["result"]["result"]:
|
||||
agent.append(res["name"])
|
||||
|
||||
agent = list(set(agent))
|
||||
self.assertCountEqual(result_check[tags], agent)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue