883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
18 lines
1.2 KiB
Python
18 lines
1.2 KiB
Python
import importlib.util,json,sys,unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
spec=importlib.util.spec_from_file_location('frontend',Path(__file__).resolve().parents[1]/'launcher/launcher.py');f=importlib.util.module_from_spec(spec);spec.loader.exec_module(f)
|
|
class WindowsFrontend(unittest.TestCase):
|
|
def event(self):return {'schema':1,'phase':'realms','message':'Choose','realms':[{'index':2,'name':'Realm','offline':False}]}
|
|
def test_native_realm_choice_uses_validated_server_index(self):
|
|
with patch.object(f.platform,'system',return_value='Windows'),patch.object(f,'choose_windows_realm',return_value=2)as dialog:
|
|
self.assertEqual(f.choose_authenticated_realm(self.event()),2);self.assertEqual(set(dialog.call_args.args[0]),{'2'})
|
|
def test_invalid_realm_event_rejected_before_ui(self):
|
|
value=self.event();value['realms'][0]['index']=True
|
|
with patch.object(f,'choose_windows_realm')as dialog:
|
|
with self.assertRaises(ValueError):f.choose_authenticated_realm(value)
|
|
dialog.assert_not_called()
|
|
def test_windows_failure_event_matches_shared_frontend_protocol(self):
|
|
self.assertIsNotNone(f.public_event(json.dumps({'schema':1,'phase':'blocked','message':'Preserved'})))
|
|
if __name__=='__main__':unittest.main()
|