883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
34 lines
1.7 KiB
Python
34 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""A timed-out reload needs fresh persistence, never input replay or stale data."""
|
|
from pathlib import Path
|
|
import sys,unittest
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from native_item_metadata_test import persist_probe
|
|
|
|
class Session:
|
|
def __init__(self,error=None):self.calls=[];self.error=error;self.world=False
|
|
def macro(self,text):
|
|
self.calls.append(text)
|
|
if self.error:raise RuntimeError(self.error)
|
|
def wait_world(self,timeout):self.world=True
|
|
class Controller:
|
|
def wait(self,predicate,timeout):
|
|
data=predicate()
|
|
if not data:raise RuntimeError('no fresh saved nonce')
|
|
return data
|
|
class Persistence(unittest.TestCase):
|
|
def test_timeout_with_fresh_result_is_confirmed_without_replay(self):
|
|
s=Session('Chat edit readiness/submission unconfirmed; no automatic replay')
|
|
data,warning=persist_probe(s,Controller(),lambda:dict(run='fresh'))
|
|
self.assertEqual(data,dict(run='fresh'));self.assertTrue(warning)
|
|
self.assertEqual(s.calls,['/run ReloadUI()']);self.assertTrue(s.world)
|
|
def test_stale_result_does_not_turn_timeout_into_success(self):
|
|
s=Session('Chat edit readiness/submission unconfirmed; no automatic replay')
|
|
with self.assertRaisesRegex(RuntimeError,'no fresh'):persist_probe(s,Controller(),lambda:None)
|
|
self.assertFalse(s.world);self.assertEqual(len(s.calls),1)
|
|
def test_unrelated_failure_stops_without_claiming_world_or_saved_success(self):
|
|
s=Session('Focus changed')
|
|
with self.assertRaisesRegex(RuntimeError,'Focus changed'):persist_probe(s,Controller(),lambda:dict(run='fresh'))
|
|
self.assertFalse(s.world)
|
|
if __name__=='__main__':unittest.main()
|