import unittest from ranch_assistant.gifts import GiftPlanner from ranch_assistant.model import Catalog, Policy from ranch_assistant.tests.test_gift_timing import gift_snapshot class GiftTargetSelectionTests(unittest.TestCase): def setUp(self): self.catalog = Catalog() self.snapshot = gift_snapshot(self.catalog) self.planner = GiftPlanner(self.catalog) self.representative = next(iter(self.planner.cultivation.select(self.snapshot).values())) self.manual_target = next(mon for mon in self.snapshot.raw["monsters"] if int(mon["id"]) != int(self.representative["id"])) def policy(self, auto=False): return Policy(gift_enabled=True, gift_auto_representative=auto, gift_targets={} if auto else {str(self.manual_target["id"]): 1}, gift_liked_only=False, gift_items={"30005": {"enabled": True, "reserve": 0}}) def test_auto_representative_is_the_effective_target_without_manual_targets(self): policy = self.policy(auto=True) self.assertEqual([mon["id"] for mon in self.planner.candidates(self.snapshot, policy)], [self.representative["id"]]) self.assertEqual([action.payload["monsterId"] for action in self.planner.plan(self.snapshot, policy)], [self.representative["id"]]) def test_manual_mode_uses_gift_targets_instead_of_representative(self): policy = self.policy() self.assertEqual([mon["id"] for mon in self.planner.candidates(self.snapshot, policy)], [self.manual_target["id"]]) self.assertEqual([action.payload["monsterId"] for action in self.planner.plan(self.snapshot, policy)], [self.manual_target["id"]]) if __name__ == "__main__": unittest.main()