This commit is contained in:
@@ -90,6 +90,7 @@ class LocalExtensionInventoryTests(unittest.TestCase):
|
||||
"debug-telemetry": OFFICIAL_AUTHOR,
|
||||
"dice": JWEBOT_AUTHOR,
|
||||
"coin": JWEBOT_AUTHOR,
|
||||
"coin-transfer": JWEBOT_AUTHOR,
|
||||
"random-number": JWEBOT_AUTHOR,
|
||||
"draw-lot": JWEBOT_AUTHOR,
|
||||
"daily-fortune": JWEBOT_AUTHOR,
|
||||
|
||||
@@ -191,6 +191,34 @@ class Release063GameTests(unittest.TestCase):
|
||||
self.assertIn("alice #2:抽奖 未中奖", history)
|
||||
self.assertIn("alice #1:抽奖 未中奖", history)
|
||||
|
||||
def test_transfer_requires_initialized_target_and_replays_once(self):
|
||||
self.assertIn("金币 1000", self.command("/金币"))
|
||||
missing = self.command("/转账 Bob 100", event_id="missing-target")
|
||||
self.assertIn("bob 还没有金币账户", missing)
|
||||
self.assertEqual(self.state()["balance"], 1000)
|
||||
|
||||
self.assertIn("金币 1000", self.command("/金币", sender="Bob"))
|
||||
first = self.command("/转账 Bob 250", event_id="transfer-1")
|
||||
replay = self.command(
|
||||
"/转账 Bob 250",
|
||||
sender="a1",
|
||||
event_id="transfer-1",
|
||||
)
|
||||
|
||||
self.assertEqual(replay, first)
|
||||
self.assertIn("alice:已向 bob 转账 250 金币", first)
|
||||
self.assertEqual(self.state()["balance"], 750)
|
||||
self.assertEqual(self.state("Bob")["balance"], 1250)
|
||||
|
||||
def test_transfer_rejects_invalid_self_and_insufficient_cases(self):
|
||||
self.assertIn("金币 1000", self.command("/金币"))
|
||||
self.assertIn("转账金额必须为 1~100000", self.command("/转账 Bob 0"))
|
||||
self.assertIn("不能给自己转账", self.command("/转账 a1 100"))
|
||||
self.assertIn("金币 1000", self.command("/金币", sender="Bob"))
|
||||
self.assertIn("金币不足", self.command("/transfer 1001 Bob"))
|
||||
self.assertEqual(self.state()["balance"], 1000)
|
||||
self.assertEqual(self.state("Bob")["balance"], 1000)
|
||||
|
||||
def test_open_round_and_history_survive_restart(self):
|
||||
root = Path(self.temp.name)
|
||||
self.command("/彩票开始")
|
||||
|
||||
@@ -6,6 +6,7 @@ import json
|
||||
import re
|
||||
import tempfile
|
||||
import unittest
|
||||
from importlib import resources
|
||||
from pathlib import Path
|
||||
|
||||
from test_jwebot_edge import MODULE, config
|
||||
@@ -161,6 +162,35 @@ class Release067AutochessTests(unittest.TestCase):
|
||||
self.assertEqual(new_state["season_number"], 2)
|
||||
self.assertEqual(new_state["status"], "registration")
|
||||
|
||||
def test_autochess_data_files_are_externalized_and_loaded(self):
|
||||
data_root = resources.files(AUTOCHESS.__package__).joinpath(
|
||||
AUTOCHESS.DATA_ROOT
|
||||
)
|
||||
payloads = {}
|
||||
for filename in AUTOCHESS.DATA_FILES:
|
||||
path = data_root.joinpath(filename)
|
||||
self.assertTrue(path.is_file(), filename)
|
||||
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||
self.assertEqual(payload["schema_version"], 1)
|
||||
payloads[filename] = payload
|
||||
|
||||
self.assertEqual(
|
||||
len(payloads["players.json"]["players"]),
|
||||
len(AUTOCHESS.PLAYER_POOL),
|
||||
)
|
||||
self.assertEqual(
|
||||
len(payloads["coaches.json"]["coaches"]),
|
||||
len(AUTOCHESS.COACH_POOL),
|
||||
)
|
||||
narrative_count = sum(
|
||||
len(items)
|
||||
for items in payloads["narratives.json"]["fragments"].values()
|
||||
)
|
||||
self.assertEqual(narrative_count, AUTOCHESS._narrative_inventory_size())
|
||||
self.assertGreaterEqual(narrative_count, 120)
|
||||
self.assertEqual(AUTOCHESS.MATCH_BEST_OF["group"], 3)
|
||||
self.assertEqual(AUTOCHESS.MATCH_BEST_OF["final"], 5)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user