diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-19 19:35:30 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2025-07-19 19:35:30 -0400 |
| commit | 1d044bf320cd0c9d03daa8213df078e834e20c49 (patch) | |
| tree | e48cb29f1d32942c04b1d40b7ddcc7cb79d24845 /tests/test_configuration.py | |
| parent | 3ce6ba534900e68c815b4012a456842d3003c6da (diff) | |
| download | decky-lsfg-vk-1d044bf320cd0c9d03daa8213df078e834e20c49.tar.gz decky-lsfg-vk-1d044bf320cd0c9d03daa8213df078e834e20c49.zip | |
restore script env var val on mount check and UI state set
Diffstat (limited to 'tests/test_configuration.py')
| -rw-r--r-- | tests/test_configuration.py | 83 |
1 files changed, 53 insertions, 30 deletions
diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 9b306e5..3e0ad79 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -7,46 +7,69 @@ from pathlib import Path from unittest.mock import Mock from lsfg_vk.configuration import ConfigurationService +from lsfg_vk.config_schema import ConfigurationManager def test_parse_script_content(): - """Test parsing of script content""" - mock_logger = Mock() + """Test parsing of script content with current environment variable format""" - with tempfile.TemporaryDirectory() as temp_dir: - temp_home = Path(temp_dir) - - # Create service with mocked home directory - service = ConfigurationService(logger=mock_logger) - service.user_home = temp_home - service.lsfg_script_path = temp_home / "lsfg" - - # Test script content - script_content = """#!/bin/bash + # Test script content matching current format + script_content = """#!/bin/bash +# lsfg-vk launch script generated by decky-lossless-scaling-vk plugin +# This script sets up the environment for lsfg-vk to work with the plugin configuration +export PROTON_USE_WOW64=1 +export SteamDeck=0 +export DXVK_FRAME_RATE=18 +export LSFG_PROCESS=decky-lsfg-vk +exec "$@" +""" + + script_values = ConfigurationManager.parse_script_content(script_content) + + assert script_values["enable_wow64"] is True + assert script_values["disable_steamdeck_mode"] is True # SteamDeck=0 means disable + assert script_values["dxvk_frame_rate"] == 18 -export ENABLE_LSFG=1 -export LSFG_MULTIPLIER=3 -export LSFG_FLOW_SCALE=1.5 -export LSFG_HDR=1 -# export LSFG_PERF_MODE=1 -export MESA_VK_WSI_PRESENT_MODE=immediate # - disable vsync +def test_parse_script_content_minimal(): + """Test parsing when only required exports are present""" + + script_content = """#!/bin/bash +# lsfg-vk launch script generated by decky-lossless-scaling-vk plugin +export LSFG_PROCESS=decky-lsfg-vk exec "$@" """ - - config = service._parse_script_content(script_content) - - assert config["enable_lsfg"] is True - assert config["multiplier"] == 3 - assert config["flow_scale"] == 1.5 - assert config["hdr"] is True - assert config["perf_mode"] is False # commented out - assert config["immediate_mode"] is True + + script_values = ConfigurationManager.parse_script_content(script_content) + + # Should be empty dict since no tracked env vars are present + assert script_values == {} -def test_parse_script_content_all_commented(): - """Test parsing when all optional features are commented out""" - mock_logger = Mock() +def test_merge_config_with_script(): + """Test merging TOML config with script environment variables""" + + # Get defaults + toml_config = ConfigurationManager.get_defaults() + + # Script values from parsing + script_values = { + "enable_wow64": True, + "disable_steamdeck_mode": True, + "dxvk_frame_rate": 30 + } + + merged = ConfigurationManager.merge_config_with_script(toml_config, script_values) + + # TOML fields should be preserved + assert merged["multiplier"] == 1 # default from TOML + assert merged["flow_scale"] == 0.8 # default from TOML + assert merged["performance_mode"] is True # default from TOML + + # Script fields should be overlaid + assert merged["enable_wow64"] is True + assert merged["disable_steamdeck_mode"] is True + assert merged["dxvk_frame_rate"] == 30 with tempfile.TemporaryDirectory() as temp_dir: temp_home = Path(temp_dir) |
