Files
WoW-Hybrid-gateway/tests/debug_client_owner_poll_spellbook_mode_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.7 KiB
Python

"""The optional registrar preserves the installed poll-host launch contract."""
import ast,sys,unittest
from pathlib import Path
from unittest.mock import Mock
import debug_client_owner_spellbook_registration_test as previous_fixture
ROOT=Path(__file__).resolve().parents[1]
class PollHostRegistrationModeTests(unittest.TestCase):
def test_poll_mode_keeps_original_route_and_initial_observer_needs_no_roster_config(self):
tree=ast.parse((ROOT/'ops/debug_client_owner.py').read_text())
main=next(n for n in tree.body if isinstance(n,ast.If) and isinstance(n.test,ast.Compare) and isinstance(n.test.left,ast.Name) and n.test.left.id=='__name__')
def mode(name):
serve=Mock();scope={'__name__':'__main__','sys':type('Args',(),{'argv':['debug_client_owner.py',name]})(),'serve':serve}
exec(compile(ast.Module(body=[main],type_ignores=[]),'<existing-owner-mode-dispatch>','exec'),scope)
serve.assert_called_once();return serve.call_args
original=mode('serve-poll-host');observed=mode('serve-poll-host-tooltip-registration')
self.assertEqual(original.args,observed.args)
self.assertEqual(original.kwargs,{'clean_copy':True,'poll_host':True})
self.assertEqual(observed.kwargs,{**original.kwargs,'early_spellbook_registration':True})
self.assertNotIn('native_roster',observed.kwargs)
# Execute the existing initial-child hook with the changed False role.
# Its actual lifetime/observer factory remains in the accepted fixture.
fixture=previous_fixture.EarlyRegistrationTests(methodName='test_initial_owned_child_uses_exact_filter_and_current_launch_result')
fixture.setUp();self.addCleanup(fixture.doCleanups)
observer,report=fixture.call(native_roster=False)
self.assertIs(observer,fixture.factory.return_value)
self.assertEqual(report['status'],'started-not-yet-armed')
self.assertEqual(observer.owned_lifetime,fixture.identity)
fixture.policy.assert_not_called()
# The new mode must pass the existing serve admission before any IO.
serve_node=next(n for n in tree.body if isinstance(n,ast.FunctionDef) and n.name=='serve')
guard=serve_node.body[0];scope=dict(experimental=False,clean_copy=True,poll_host=True,native_roster=False,early_spellbook_registration=True)
exec(compile(ast.Module(body=[guard],type_ignores=[]),'<serve-mode-admission>','exec'),scope)
for changed in ({'experimental':True},{'clean_copy':False},{'poll_host':False}):
with self.subTest(changed=changed),self.assertRaises(RuntimeError):
exec(compile(ast.Module(body=[guard],type_ignores=[]),'<serve-mode-admission>','exec'),{**scope,**changed})
if __name__=='__main__':
unittest.main()