Browse Source

Add a find_modpack test.

master
poikilos 10 months ago
parent
commit
6f893bf24f
  1. 1
      tests/data/mod_game/mods/extra_parent/modpack1/mod1/mod.conf
  2. 0
      tests/data/modpack_game/mods/extra_parent/modpack1/mod1/init.lua
  3. 1
      tests/data/modpack_game/mods/extra_parent/modpack1/mod1/mod.conf
  4. 1
      tests/data/modpack_game/mods/extra_parent/modpack1/mod1/not_this_folder/init.lua
  5. 1
      tests/data/modpack_game/mods/extra_parent/modpack1/modpack.conf
  6. 0
      tests/data/modpack_game/mods/extra_parent/modpack2/mod2/init.lua
  7. 1
      tests/data/modpack_game/mods/extra_parent/modpack2/mod2/mod.conf
  8. 1
      tests/data/modpack_game/mods/extra_parent/modpack2/mod2/not_this_folder/init.lua
  9. 1
      tests/data/modpack_game/mods/extra_parent/modpack2/modpack.conf
  10. 40
      tests/test_mtpatches.py

1
tests/data/mod_game/mods/extra_parent/modpack1/mod1/mod.conf

@ -0,0 +1 @@
name = mod1

0
tests/data/modpack_game/mods/extra_parent/modpack1/mod1/init.lua

1
tests/data/modpack_game/mods/extra_parent/modpack1/mod1/mod.conf

@ -0,0 +1 @@
name = mod1

1
tests/data/modpack_game/mods/extra_parent/modpack1/mod1/not_this_folder/init.lua

@ -0,0 +1 @@
-- This represents a backup of init.lua that should be ignored by the test.

1
tests/data/modpack_game/mods/extra_parent/modpack1/modpack.conf

@ -0,0 +1 @@
name = modpack1

0
tests/data/modpack_game/mods/extra_parent/modpack2/mod2/init.lua

1
tests/data/modpack_game/mods/extra_parent/modpack2/mod2/mod.conf

@ -0,0 +1 @@
name = mod2

1
tests/data/modpack_game/mods/extra_parent/modpack2/mod2/not_this_folder/init.lua

@ -0,0 +1 @@
-- This represents a backup of init.lua that should be ignored by the test.

1
tests/data/modpack_game/mods/extra_parent/modpack2/modpack.conf

@ -0,0 +1 @@
name = modpack2

40
tests/test_mtpatches.py

@ -14,6 +14,7 @@ from pyenliven.mtpatches import ( # noqa F402
get_shallowest_files_sub,
diff_only_head,
find_mod,
find_modpack,
)
@ -97,6 +98,11 @@ class TestMTPatches(unittest.TestCase):
find_mod(game_path, "mod1"),
os.path.join("mods", "extra_parent", "modpack1", "mod1")
)
self.assertEqual(
find_mod(os.path.join(TESTS_DATA_DIR, "modpack_game"), "mod2"),
os.path.join("mods", "extra_parent", "modpack2", "mod2")
)
self.assertEqual(
find_mod(os.path.join(game_path, "mods", "extra_parent",
"modpack1", "mod1"),
@ -108,6 +114,40 @@ class TestMTPatches(unittest.TestCase):
os.path.join("extra_parent", "modpack1", "mod1"),
)
def test_find_modpack(self):
game_path = os.path.join(TESTS_DATA_DIR, "modpack_game")
self.assertEqual(
find_modpack(game_path, "wrong_modpack"),
None
)
self.assertEqual(
find_modpack(game_path, "modpack1"),
os.path.join("mods", "extra_parent", "modpack1")
)
self.assertEqual(
find_modpack(os.path.join(TESTS_DATA_DIR, "modpack_game"),
"modpack2"),
os.path.join("mods", "extra_parent", "modpack2")
)
self.assertEqual(
find_modpack(os.path.join(game_path, "mods", "extra_parent",
"modpack1"),
"modpack1"), # Yes, still find mod1 ("") if root
""
)
self.assertEqual(
find_modpack(os.path.join(game_path, "mods", "extra_parent",
"modpack2"),
"modpack2"), # Yes, still find mod1 ("") if root
""
)
self.assertEqual(
find_modpack(os.path.join(game_path, "mods"), "modpack1"),
os.path.join("extra_parent", "modpack1"),
)
if __name__ == "__main__":
unittest.main()

Loading…
Cancel
Save