okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
837909fdd
main
1r"""The Home() helper of the launch tests must keep every per-user file the code reads or writes inside its temp folder. 2 3A test that read the person's real %APPDATA%\Strata\settings.json (its remembered Strata folders) or ~/.config/strata saw the files of whoever ran it: the 4DeepSeek plan tests said "tight" / "spills" for UD-Q8_K_XL on a PC that had a Strata install, and "fits" everywhere else.""" 5import os 6import unittest 7from pathlib import Path 8from unittest import mock 9 10from tests .terminal .launch_support import Home 11 12 13def inside (path :Path ,base :Path )-> bool : 14try : 15Path (path ).resolve ().relative_to (base .resolve ()) 16return True 17except ValueError : 18return False 19 20 21class HomeIsHermetic (unittest .TestCase ): 22def test_every_per_user_location_is_inside_the_temp_folder (self ): 23from strata_control import discovery ,models ,profiles 24import setup 25from strata_cli import connections 26with Home ()as h : 27places = { 28"discovery.own_settings_file (Windows rule)" :discovery .own_settings_file (windows = True ), 29"discovery.own_settings_file (Linux/macOS rule)" :discovery .own_settings_file (windows = False ), 30"models.settings_path" :models .settings_path (), 31"profiles.profile_dir" :profiles .profile_dir (), 32"setup.settings_path" :setup .settings_path (), 33"connections.connection_dir" :connections .connection_dir (create = False ), 34 } 35for name ,path in places .items (): 36self .assertTrue (inside (path ,h .base ),f" { name } = { path } is outside { h . base } " ) 37 38def test_a_developers_own_settings_variable_does_not_reach_a_test (self ): 39with mock .patch .dict (os .environ , {"STRATA_SETTINGS_FILE" :"X:/mine.json" ,"STRATA_CONNECTION_DIR" :"X:/conn" }): 40with Home (): 41self .assertNotIn ("STRATA_SETTINGS_FILE" ,os .environ ) 42self .assertNotIn ("STRATA_CONNECTION_DIR" ,os .environ ) 43self .assertEqual (os .environ ["STRATA_SETTINGS_FILE" ],"X:/mine.json" ) 44 45 46if __name__ == "__main__" : 47unittest .main ()