Skip to content

Commit

Permalink
Add more tests for deleting plugins
Browse files Browse the repository at this point in the history
Additionally, add tests that help ensure plugins don't show up when
they're not under the Data folder.
  • Loading branch information
cyberrumor committed Mar 19, 2024
1 parent fd82643 commit 297ec07
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Binary file added test/Downloads/mult_plugins_same_name.7z
Binary file not shown.
Binary file added test/Downloads/plugin_wrong_spot.7z
Binary file not shown.
27 changes: 27 additions & 0 deletions test/test_conflict_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,33 @@ def test_conflicting_plugins_delete_plugin():
), "A plugin provided by multiple mods came back from the grave!"


def test_conflicting_plugins_mult_delete_plugin():
"""
Install two mods with the same plugin. One of those mods has an extra
plugin by the same name but in somewhere besides Data. Expect the plugin
to be deleted from both mods, but the plugin that was in the wrong spot
is not removed.
"""
with AmmoController() as controller:
for mod in ["plugin_wrong_spot", "mult_plugins_same_name"]:
install_mod(controller, mod)

controller.delete(DeleteEnum.PLUGIN, 0)
files = controller.mods[[i.name for i in controller.mods].index("plugin_wrong_spot")].files
file = controller.game.ammo_mods_dir / "plugin_wrong_spot/Data/test/plugin.esp"
# Check that we didn't delete a plugin that wasn't in Data
assert file in files

files = controller.mods[[i.name for i in controller.mods].index("mult_plugins_same_name")].files
file = controller.game.ammo_mods_dir / "mult_plugins_same_name/Data/plugin.esp"
# Check that we deleted what we intended to
assert file not in files

file = controller.game.ammo_mods_dir / "mult_plugins_same_name/Data/test/plugin.esp"
# Check that we didn't delete a plugin that wasn't in Data
assert file in files


def test_conflicting_mods_have_conflict_flag_after_install():
"""
Test that only conflicting mods have mod.conflict set to True
Expand Down
20 changes: 20 additions & 0 deletions test/test_controller_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
)
from common import (
AmmoController,
extract_mod,
install_everything,
install_mod,
)
Expand Down Expand Up @@ -463,3 +464,22 @@ def test_controller_delete_plugin():
controller.activate(ComponentEnum.MOD, 0)
# Ensure the plugin hasn't returned.
assert len(controller.plugins) == 0


def test_controller_plugin_wrong_spot():
"""
Test that a plugin which isn't under Data or the root
directory of a mod doesn't appear in mod.plugins.
"""
with AmmoController() as controller:
extract_mod(controller, "plugin_wrong_spot")
assert controller.mods[0].plugins == []
controller.activate(ComponentEnum.MOD, 0)
assert controller.mods[0].plugins == []
controller.deactivate(ComponentEnum.MOD, 0)
assert controller.mods[0].plugins == []
controller.commit()
assert controller.mods[0].plugins == []
controller.rename(ComponentEnum.MOD, 0, "new_name")
assert controller.mods[0].plugins == []

0 comments on commit 297ec07

Please sign in to comment.