49 lines
2.1 KiB
Python
49 lines
2.1 KiB
Python
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.snapshot.raw["monsters"][0]["level"] += 1
|
|
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_requires_the_primary_to_be_explicitly_checked(self):
|
|
policy = self.policy()
|
|
|
|
self.assertEqual(self.planner.candidates(self.snapshot, policy), [])
|
|
self.assertEqual(self.planner.plan(self.snapshot, policy), [])
|
|
|
|
policy.gift_targets[str(self.representative["id"])] = 2
|
|
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"]])
|
|
|
|
self.representative["feel"] = self.catalog.max_feel(self.representative)
|
|
self.assertEqual(self.planner.plan(self.snapshot, policy), [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|