Add reliable execution reporting and coordinated dashboard views
This commit is contained in:
@@ -4,14 +4,32 @@ import json
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0,str(ROOT/'scripts'))
|
||||
import mirror
|
||||
from mirror import visible_items,sync
|
||||
from worker import message_prompt
|
||||
|
||||
|
||||
class MirrorTests(unittest.TestCase):
|
||||
def test_transient_connection_retry_recovers_without_process_failure(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
config=Path(root)/'config.json';config.write_text(json.dumps({'control':{},'state_file':str(Path(root)/'state.json'),'thread_id':'t'}))
|
||||
with patch.object(sys,'argv',['mirror.py','--config',str(config)]),patch.object(mirror,'Client'),patch.object(mirror,'AppServer'),patch.object(mirror,'sync',side_effect=[RuntimeError('offline'),1]) as sync_call,patch.object(mirror.time,'sleep',side_effect=[None,KeyboardInterrupt]):
|
||||
with self.assertRaises(KeyboardInterrupt):mirror.main()
|
||||
self.assertEqual(sync_call.call_count,2)
|
||||
self.assertEqual(json.loads((Path(root)/'mirror-health.json').read_text())['status'],'ok')
|
||||
|
||||
def test_connection_retry_is_bounded(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
config=Path(root)/'config.json';config.write_text(json.dumps({'control':{},'state_file':str(Path(root)/'state.json'),'thread_id':'t'}))
|
||||
with patch.object(sys,'argv',['mirror.py','--config',str(config)]),patch.object(mirror,'Client'),patch.object(mirror,'AppServer'),patch.object(mirror,'sync',side_effect=RuntimeError('offline')) as sync_call,patch.object(mirror.time,'sleep'):
|
||||
with self.assertRaises(RuntimeError):mirror.main()
|
||||
self.assertEqual(sync_call.call_count,3)
|
||||
self.assertEqual(json.loads((Path(root)/'mirror-health.json').read_text())['attempt'],3)
|
||||
|
||||
def test_quoted_marker_does_not_hide_human_or_reply(self):
|
||||
turns=[{'id':'t','status':'completed','items':[
|
||||
{'type':'userMessage','id':'u','content':[{'type':'text','text':'Please explain web-message-id: quotation'}]},
|
||||
|
||||
Reference in New Issue
Block a user