883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
52 lines
2.4 KiB
Python
52 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""A GM can switch only to the explicit, separate owned rank-0 fixture."""
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'ops'))
|
|
from owned_session_profile import validate_gm_bound_context, validate_gm_second
|
|
|
|
|
|
class OwnedSessionProfileTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.request = {'enabled': True, 'owned_gm_only': True, 'ctor_witness': False,
|
|
'map_registration': False, 'dungeon_route': False,
|
|
'stage_flight_fixture': False, 'second_guid': 4526,
|
|
'second_account': 514, 'second_rank': 0}
|
|
self.first = {'guid': 4509, 'account': 511, 'original_rank': 4, 'runtime_rank': 4}
|
|
self.second = {'guid': 4526, 'account': 514, 'original_rank': 0, 'runtime_rank': 0}
|
|
|
|
def test_default_does_not_enable_a_second_actor(self):
|
|
self.assertFalse(validate_gm_second(**dict(self.request, enabled=False)))
|
|
validate_gm_bound_context(self.first, None)
|
|
|
|
def test_explicit_reviewed_separate_rank0_actor_is_permitted(self):
|
|
self.assertTrue(validate_gm_second(**self.request))
|
|
validate_gm_bound_context(self.first, self.second)
|
|
|
|
def test_wrong_actor_rank_or_special_staging_is_rejected(self):
|
|
variants = [{'owned_gm_only': False}, {'ctor_witness': True},
|
|
{'map_registration': True}, {'dungeon_route': True},
|
|
{'stage_flight_fixture': True}, {'second_guid': 4510},
|
|
{'second_account': 511}, {'second_rank': 4}]
|
|
for changes in variants:
|
|
with self.subTest(changes=changes), self.assertRaises(ValueError):
|
|
validate_gm_second(**(self.request | changes))
|
|
|
|
def test_frontend_rejects_forged_or_rank_changed_gm_context(self):
|
|
variants = [dict(self.second, guid=4510), dict(self.second, account=511),
|
|
dict(self.second, original_rank=4), dict(self.second, runtime_rank=4)]
|
|
for second in variants:
|
|
with self.subTest(second=second), self.assertRaises(ValueError):
|
|
validate_gm_bound_context(self.first, second)
|
|
with self.assertRaises(ValueError):
|
|
validate_gm_bound_context(dict(self.first, account=513), self.second)
|
|
|
|
def test_other_existing_first_profile_remains_unchanged(self):
|
|
validate_gm_bound_context({'guid': 4510}, {'guid': 4514})
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|