okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
a37d0a57e
main
1"""The app's host reads its launch-policy tables from apps/host/server/policy-generated.mjs, which strata_control/app_policy.py writes from the Python that owns them. 2A table changed in Python and not regenerated, or edited by hand in the JavaScript, fails here.""" 3from __future__import annotations 4 5import unittest 6 7from strata_control import app_policy ,drafting ,speed_switches 8 9 10class GeneratedPolicy (unittest .TestCase ): 11def test_the_committed_file_is_what_the_python_makes_now (self ): 12have = app_policy .TARGET .read_text (encoding = "utf-8" ) 13self .assertEqual (have ,app_policy .render (),"run: python -m strata_control.app_policy" ) 14 15def test_the_committed_vectors_are_what_the_python_answers_now (self ): 16self .assertEqual (app_policy .VECTORS .read_text (encoding = "utf-8" ),app_policy .render_vectors (),"run: python -m strata_control.app_policy" ) 17 18def test_the_app_shows_every_switch_but_the_terminal_only_one (self ): 19ids = [r ["id" ]for r in app_policy .table ()] 20self .assertEqual (ids , [s .id for s in speed_switches .SWITCHES if not s .terminal_only ]) 21self .assertNotIn ("qwen_defaults_026" ,ids ) 22 23def test_a_row_carries_exactly_what_the_python_switch_holds (self ): 24for row in app_policy .table (): 25sw = speed_switches .BY_ID [row ["id" ]] 26self .assertEqual ((row ["label" ],row ["hint" ],row ["default" ],row ["env" ],row .get ("legacy" , {})), 27 (sw .label ,sw .effect ,sw .default ,dict (sw .env ),dict (sw .legacy ))) 28 29def test_the_drafting_families_and_names_are_drafting_py_own (self ): 30text = app_policy .render () 31for family in drafting .SUPPORTED_FAMILIES : 32self .assertIn (f'" { family } "' ,text ) 33self .assertIn (drafting ._SUPPORTED_NAME .pattern .replace ("\\" ,"\\\\" ),text ) 34 35 36if __name__ == "__main__" : 37unittest .main ()