okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
abd9b4581
main
1"""`strata launch --split-engine auto|on|off`: the owner's switch for the all-cards split engine (strata_control/split_engine.py). 2auto (nothing written) is the default; the choice is listed in --help, in the copyable flags, in the launch config and in a saved preset, so an 3"off" survives updates and restarts; the launcher's apply_split_engine honours it (off: nothing, auto: silent on a refusal, on: one line).""" 4 5from __future__import annotations 6 7import unittest 8 9from strata_cli .launch import settings as S 10from strata_cli .launch .runner import derive_config 11from strata_control import split_engine as SE 12from tests .terminal .launch_support import run_cli 13 14 15class Flag (unittest .TestCase ): 16BASE = {"exe" :"component:strata-engine" ,"args" : ["--pack" ,"/d/packs/x" ,"--mtp" ,"/d/mtp/rt" ],"port" :8080 ,"model_name" :"m" } 17 18def test_the_flag_is_listed_checked_copyable_and_saved_in_the_launch_config (self ): 19code ,out ,_ = run_cli (["launch" ,"--help" ]) 20self .assertIn ("--split-engine" ,out ) 21self .assertIn ("auto|on|off" ,out ) 22for mode in S .SPLIT_MODES : 23cfg = derive_config (self .BASE ,S .LaunchSettings (split_engine = mode ),bool_flags = frozenset ()) 24self .assertEqual (cfg ["split_engine" ],mode ) 25self .assertEqual (SE .mode (cfg , {}),mode ) 26self .assertNotIn ("split_engine" ,derive_config (self .BASE ,S .LaunchSettings (),bool_flags = frozenset ()),"nobody chose: auto writes nothing" ) 27self .assertEqual (SE .mode (derive_config (self .BASE ,S .LaunchSettings (),bool_flags = frozenset ()), {}),"auto" ) 28self .assertIn ("--split-engine off" ,S .flags_text (S .LaunchSettings (split_engine = "off" ))) 29self .assertNotIn ("--split-engine" ,S .flags_text (S .LaunchSettings ())) 30code ,out ,err = run_cli (["launch" ,"--plan" ,"--split-engine" ,"sometimes" ]) 31self .assertNotEqual (code ,0 ) 32 33def test_a_saved_off_survives_a_new_launch_config_and_a_preset_round_trip (self ): 34s = S .LaunchSettings .from_dict (S .LaunchSettings (split_engine = "off" ).to_dict ()) 35self .assertEqual (s .split_engine ,"off" ) 36self .assertIsNone (S .LaunchSettings .from_dict ({}).split_engine ) 37# a config written earlier with "off" is kept when this launch names nothing 38cfg = derive_config ({** self .BASE ,"split_engine" :"off" },S .LaunchSettings (),bool_flags = frozenset ()) 39self .assertEqual (cfg ["split_engine" ],"off" ) 40# and the person's flag of this launch wins over the old file 41cfg = derive_config ({** self .BASE ,"split_engine" :"off" },S .LaunchSettings (split_engine = "on" ),bool_flags = frozenset ()) 42self .assertEqual (cfg ["split_engine" ],"on" ) 43 44 45if __name__ == "__main__" : 46unittest .main ()