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

38 lines
2.6 KiB
Python

from pathlib import Path
import json
import sys
import tempfile
import unittest
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
from diagnostics_packet_report import summarize,STREAMS
class Report(unittest.TestCase):
def setUp(self):
base=Path(__file__).resolve().parents[1]/'runtime/continuation-20261113/codex/W36-wire-drops-20261118';base.mkdir(parents=True,exist_ok=True)
self.temp=tempfile.TemporaryDirectory(dir=base);self.root=Path(self.temp.name)
def tearDown(self):self.temp.cleanup()
def stream(self,name,rows,tail=''):
head={'schema':1,'stream':name,'client_build':'1.60.1.70334','server_kind':'octo','realm_id':70,'stack_commit':'48f8cdd'}
path=self.root/(name+'.jsonl');path.write_text('\n'.join(json.dumps(x)for x in [head,*rows])+'\n'+tail);return path
def test_cumulative_counts_and_incomplete_tail(self):
self.stream(STREAMS[0],[{'t':1,'opcode':645,'size':4,'count':10},{'t':2,'opcode':645,'size':4,'count':100},{'t':3,'opcode':645,'size':4,'count':100}],'{"t":4')
report=summarize(self.root);row=report['streams'][STREAMS[0]]
self.assertEqual(row['packets'],100);self.assertEqual(row['body_bytes'],400);self.assertTrue(row['truncated_tail_ignored']);self.assertEqual(report['missing_streams'],list(STREAMS[1:]))
def test_rejects_payload_and_regression(self):
for rows in [[{'t':1,'opcode':1,'size':1,'count':1,'payload_hex':'PRIVATE_SENTINEL'}],[{'t':1,'opcode':1,'size':1,'count':3},{'t':2,'opcode':1,'size':1,'count':2}]]:
self.stream(STREAMS[0],rows)
with self.assertRaises(ValueError):summarize(self.root)
def test_never_follows_counter_symlink(self):
target=self.root/'unrelated-private.bin';target.write_text('DO_NOT_READ')
(self.root/(STREAMS[0]+'.jsonl')).symlink_to(target)
with self.assertRaises(ValueError):summarize(self.root)
def test_rejects_mixed_session_headers(self):
self.stream(STREAMS[0],[]);path=self.stream(STREAMS[1],[]);path.write_text(path.read_text().replace('"octo"','"local"'))
with self.assertRaises(ValueError):summarize(self.root)
def test_qualifies_known_pre_specialist_counter_build(self):
path=self.stream(STREAMS[0],[{'t':1,'opcode':0x2fb,'size':73,'count':1463}])
path.write_text(path.read_text().replace('48f8cdd','dc11050'))
report=summarize(self.root)
self.assertEqual(report['streams'][STREAMS[0]]['packets'],1463)
self.assertTrue(any('before downstream' in note for note in report['qualifications']))
if __name__=='__main__':unittest.main()