From cf20bcc863a413055f2912774a278ab49d8a4972 Mon Sep 17 00:00:00 2001 From: R1kaB3rN <100738684+R1kaB3rN@users.noreply.github.com> Date: Thu, 5 Sep 2024 01:10:27 -0700 Subject: [PATCH] umu_test: update tests --- umu/umu_test.py | 69 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 11 deletions(-) diff --git a/umu/umu_test.py b/umu/umu_test.py index b0e6c63fb..5e048129a 100644 --- a/umu/umu_test.py +++ b/umu/umu_test.py @@ -1428,8 +1428,6 @@ def test_build_command_noruntime(self): os.environ["PROTONPATH"] = self.test_file os.environ["GAMEID"] = self.test_file os.environ["STORE"] = self.test_file - # Setting this mocks a Flatpak environment and UMU_NO_RUNTIME is - # only valid for Flatpak apps os.environ["UMU_NO_RUNTIME"] = "1" # Args result_args = umu_run.parse_args() @@ -1439,14 +1437,40 @@ def test_build_command_noruntime(self): umu_run.setup_pfx(self.env["WINEPREFIX"]) # Env umu_run.set_env(self.env, result_args) - # Mock setting UMU_NO_RUNTIME. This will not be set in the function - # because the FLATPAK_PATH constant will evaluate to None self.env["UMU_NO_RUNTIME"] = os.environ["UMU_NO_RUNTIME"] # Game drive umu_run.enable_steam_game_drive(self.env) os.environ |= self.env + # Mock setting up the runtime + with ( + patch.object(umu_runtime, "_install_umu", return_value=None), + ): + umu_runtime.setup_umu( + self.test_user_share, self.test_local_share, None + ) + copytree( + Path(self.test_user_share, "sniper_platform_0.20240125.75305"), + Path( + self.test_local_share, "sniper_platform_0.20240125.75305" + ), + dirs_exist_ok=True, + symlinks=True, + ) + copy( + Path(self.test_user_share, "run"), + Path(self.test_local_share, "run"), + ) + copy( + Path(self.test_user_share, "run-in-sniper"), + Path(self.test_local_share, "run-in-sniper"), + ) + copy( + Path(self.test_user_share, "umu"), + Path(self.test_local_share, "umu"), + ) + # Build test_command = umu_run.build_command(self.env, self.test_local_share) self.assertIsInstance( @@ -1454,8 +1478,8 @@ def test_build_command_noruntime(self): ) self.assertEqual( len(test_command), - 1, - f"Expected 1 element, received {len(test_command)}", + 5, + f"Expected 5 element, received {len(test_command)}", ) exe, *_ = [*test_command] self.assertEqual(exe, self.env["EXE"], "Expected the EXE") @@ -1482,8 +1506,6 @@ def test_build_command_nopv(self): os.environ["PROTONPATH"] = self.test_file os.environ["GAMEID"] = self.test_file os.environ["STORE"] = self.test_file - # Setting this mocks a Flatpak environment and UMU_NO_RUNTIME is - # only valid for Flatpak apps os.environ["UMU_NO_RUNTIME"] = "pressure-vessel" # Args result_args = umu_run.parse_args() @@ -1493,12 +1515,37 @@ def test_build_command_nopv(self): umu_run.setup_pfx(self.env["WINEPREFIX"]) # Env umu_run.set_env(self.env, result_args) - # Mock setting UMU_NO_RUNTIME. This will not be set in the function - # because the FLATPAK_PATH constant will evaluate to None - self.env["UMU_NO_RUNTIME"] = os.environ["UMU_NO_RUNTIME"] # Game drive umu_run.enable_steam_game_drive(self.env) + # Mock setting up the runtime + with ( + patch.object(umu_runtime, "_install_umu", return_value=None), + ): + umu_runtime.setup_umu( + self.test_user_share, self.test_local_share, None + ) + copytree( + Path(self.test_user_share, "sniper_platform_0.20240125.75305"), + Path( + self.test_local_share, "sniper_platform_0.20240125.75305" + ), + dirs_exist_ok=True, + symlinks=True, + ) + copy( + Path(self.test_user_share, "run"), + Path(self.test_local_share, "run"), + ) + copy( + Path(self.test_user_share, "run-in-sniper"), + Path(self.test_local_share, "run-in-sniper"), + ) + copy( + Path(self.test_user_share, "umu"), + Path(self.test_local_share, "umu"), + ) + os.environ |= self.env # Build