Skip to content

Commit

Permalink
umu_test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed Sep 5, 2024
1 parent 8634b2b commit cf20bcc
Showing 1 changed file with 58 additions and 11 deletions.
69 changes: 58 additions & 11 deletions umu/umu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -1439,23 +1437,49 @@ 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(
test_command, tuple, "Expected a tuple from build_command"
)
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")
Expand All @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit cf20bcc

Please sign in to comment.