Files
WoW-Hybrid-gateway/tests/octo_social_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

18 lines
1.4 KiB
Python

import json,sys,unittest
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
from octo_social_capture import extract,summarize
class SocialCapture(unittest.TestCase):
def raw(self,rows=None):
rows=rows or '[1] = { ["direction"] = "outgoing-api", ["name"] = "SendChatMessage", ["args"] = { [1] = "private{} message", [2] = "WHISPER", [4] = "private-name" } }'
return 'pfUI_cache = { ["unrelated"] = "preserve",\n ["WoWHybridSocialCapture"] = { ["schema"] = 1, ["bytes"] = 100, ["dropped"] = 0, ["rows"] = {'+rows+'} } }'
def test_extract_sparse_positions_quoted_braces_and_private_summary(self):
c=extract(self.raw());self.assertEqual(c['rows'][0]['args'][4],'private-name');s=summarize(c);self.assertEqual(s['rows'],1);self.assertNotIn('private',json.dumps(s));self.assertFalse(s['raw_wire_capture'])
def test_missing_duplicate_truncated_or_unknown_fields_rejected(self):
for text in ['not saved',self.raw()+self.raw(),self.raw()[:-6],self.raw().replace('outgoing-api','arbitrary'),self.raw().replace('[4] =','[12] =')]:
with self.subTest(text=text[:20]),self.assertRaises(ValueError):extract(text)
def test_empty_rows_and_loss_counts(self):
c=extract(self.raw(' '));self.assertEqual(c['rows'],[])
with self.assertRaises(ValueError):extract(self.raw().replace('["dropped"] = 0','["dropped"] = -1'))
if __name__=='__main__':unittest.main()