Files
WoW-Hybrid-gateway/tests/octo_guild_bank_capture_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

34 lines
1.5 KiB
Python

import sys,unittest
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
from octo_guild_bank_capture import extract,summarize
RAW='''other_cache = { ["unrelated"] = "not exported" }
pfUI_cache = {
["WoWHybridGuildBankCapture"] = {
["schema"] = 1, ["bytes"] = 20, ["dropped"] = 0,
["rows"] = {
{ ["direction"] = "incoming-event", ["prefix"] = "TW_GUILDBANK",
["payload"] = "BankInfo:private } \\\" text", ["time"] = 1.2, ["channel"] = "WHISPER" }, -- [1]
},
},
["normal_chat"] = "unrelated private chat",
}
'''
class CaptureTest(unittest.TestCase):
def test_extract_only_our_table_without_executing_or_exporting_other_saved_data(self):
data=extract(RAW);self.assertEqual(len(data['rows']),1)
self.assertEqual(data['rows'][0]['payload'],'BankInfo:private } " text')
summary=summarize(data);self.assertEqual(summary['messages'][0]['verb'],'BankInfo')
self.assertNotIn(data['rows'][0]['payload'],str(summary));self.assertNotIn('unrelated',str(data))
self.assertFalse(summary['raw_wire_capture']);self.assertFalse(summary['server_acceptance_verified'])
def test_reject_executable_lua_and_truncation(self):
for raw in (RAW.replace('["schema"] = 1','["schema"] = os.execute("bad")'),RAW[:RAW.index(' -- [1]')],RAW.replace('TW_GUILDBANK','NORMAL_CHAT')):
with self.assertRaises(ValueError):extract(raw)
def test_duplicate_capture_and_missing_capture_are_not_success(self):
for raw in (RAW+RAW,'pfUI_cache = {}'):
with self.assertRaises(ValueError):extract(raw)
if __name__=='__main__':unittest.main()