import unittest
from unittest.mock import patch

from mower.solvers.recruit import RecruitSolver

result_check = {
    ("召唤", "辅助干员", "控场"): ["梅尔", "格劳克斯"],
    ("特种干员", "生存", "削弱"): ["狮蝎", "槐琥"],
    ("重装干员", "输出", "防护"): ["星极", "雷蛇", "火神", "石棉"],
    ("狙击干员", "输出", "削弱", "远程位", "近战位"): ["槐琥"],
    ("狙击干员", "输出", "削弱", "远程位"): ["流星", "夜烟"],
    ("快速复活", "削弱", "近战位"): ["槐琥"],
    ("输出", "防护", "爆发", "狙击干员"): ["石棉", "雷蛇", "星极", "守林人", "火神"],
    ("爆发", "远程位", "治疗", "输出"): ["夜魔", "守林人", "莱恩哈特"],
    ("狙击干员", "生存", "减速"): ["白雪", "安比尔", "杰西卡", "梅"],
    ("生存", "减速"): ["梓兰", "泡普卡", "玫兰莎"],
    ("先锋干员", "支援", "控场"): ["德克萨斯", "极境", "凛冬"],
    ("减速", "支援"): ["清流", "杜宾"],
    ("特种干员",): ["砾", "孑", "暗索", "阿消"],
    ("控场",): ["卡达"],
    ("爆发",): ["刻刀"],
    ("支援",): ["杜宾", "清流"],
    ("削弱",): ["夜烟", "流星"],
    ("快速复活",): ["砾", "孑"],
    ("位移",): ["暗索", "阿消"],
}


class TestRecruitCal(unittest.TestCase):
    @patch.object(RecruitSolver, "__init__", lambda x: None)
    def setUp(self):
        self.test_class = RecruitSolver()

    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__":
    unittest.main()
