Skip to content

Commit

Permalink
umu_test: update tests
Browse files Browse the repository at this point in the history
- Replace references to UnixUser class
  • Loading branch information
R1kaB3rN committed Mar 26, 2024
1 parent 5470ef7 commit 804b71f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions umu/umu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest.mock import patch
from pathlib import Path
from shutil import rmtree, copytree, copy
from pwd import getpwuid


class TestGameLauncher(unittest.TestCase):
Expand Down Expand Up @@ -42,6 +43,7 @@ def setUp(self):
"STORE": "",
"PROTON_VERB": "",
}
self.user = getpwuid(os.getuid()).pw_name
self.test_opts = "-foo -bar"
# Proton verb
# Used when testing build_command
Expand Down Expand Up @@ -1679,7 +1681,6 @@ def test_setup_pfx_symlinks_else(self):
"""
result = None
pattern = r"^/home/[\w\d]+"
user = umu_util.UnixUser()
unexpanded_path = re.sub(
pattern,
"~",
Expand All @@ -1695,7 +1696,7 @@ def test_setup_pfx_symlinks_else(self):

# Create the symlink to the test file itself
Path(unexpanded_path).joinpath("drive_c/users").joinpath(
user.get_user()
self.user
).expanduser().symlink_to(Path(self.test_file).absolute())
Path(unexpanded_path).joinpath("drive_c/users").joinpath(
"steamuser"
Expand All @@ -1716,7 +1717,6 @@ def test_setup_pfx_symlinks_unixuser(self):
"""
result = None
pattern = r"^/home/[\w\d]+"
user = umu_util.UnixUser()
unexpanded_path = re.sub(
pattern,
"~",
Expand All @@ -1727,7 +1727,7 @@ def test_setup_pfx_symlinks_unixuser(self):

# Create only the user dir
Path(unexpanded_path).joinpath("drive_c/users").joinpath(
user.get_user()
self.user
).expanduser().mkdir(parents=True, exist_ok=True)

result = umu_run.setup_pfx(unexpanded_path)
Expand All @@ -1745,7 +1745,7 @@ def test_setup_pfx_symlinks_unixuser(self):
)
self.assertEqual(
Path(self.test_file).joinpath("drive_c/users/steamuser").readlink(),
Path(user.get_user()),
Path(self.user),
"Expected steamuser -> user",
)

Expand All @@ -1755,7 +1755,6 @@ def test_setup_pfx_symlinks_steamuser(self):
Tests the case when only steamuser exist and the user dir does not exist
"""
result = None
user = umu_util.UnixUser()
pattern = r"^/home/[\w\d]+"
unexpanded_path = re.sub(
pattern,
Expand Down Expand Up @@ -1784,15 +1783,13 @@ def test_setup_pfx_symlinks_steamuser(self):
"Expected steamuser to be created",
)
self.assertTrue(
Path(unexpanded_path + "/drive_c/users/" + user.get_user())
Path(unexpanded_path + "/drive_c/users/" + self.user)
.expanduser()
.is_symlink(),
"Expected symbolic link for unixuser",
)
self.assertEqual(
Path(self.test_file)
.joinpath(f"drive_c/users/{user.get_user()}")
.readlink(),
Path(self.test_file).joinpath(f"drive_c/users/{self.user}").readlink(),
Path("steamuser"),
"Expected unixuser -> steamuser",
)
Expand Down Expand Up @@ -1876,7 +1873,6 @@ def test_setup_pfx_paths(self):
def test_setup_pfx(self):
"""Test setup_pfx."""
result = None
user = umu_util.UnixUser()
result = umu_run.setup_pfx(self.test_file)
self.assertIsNone(
result,
Expand All @@ -1896,7 +1892,7 @@ def test_setup_pfx(self):
"Expected steamuser to be created",
)
self.assertTrue(
Path(self.test_file + "/drive_c/users/" + user.get_user())
Path(self.test_file + "/drive_c/users/" + self.user)
.expanduser()
.is_symlink(),
"Expected symlink of username -> steamuser",
Expand Down

0 comments on commit 804b71f

Please sign in to comment.