41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import json
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
SCRIPT = Path(__file__).resolve().parents[1] / "scripts/disable-recycler.sh"
|
|
|
|
|
|
class ModListTests(unittest.TestCase):
|
|
def test_disables_recycler_without_changing_other_mods(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
path = Path(directory) / "mod-list.json"
|
|
path.write_text(json.dumps({"mods": [
|
|
{"name": "base", "enabled": True},
|
|
{"name": "recycler", "enabled": True},
|
|
{"name": "my-mod", "enabled": True},
|
|
]}))
|
|
|
|
subprocess.run(["bash", str(SCRIPT), str(path)], check=True)
|
|
mods = {mod["name"]: mod["enabled"] for mod in json.loads(path.read_text())["mods"]}
|
|
|
|
self.assertFalse(mods["recycler"])
|
|
self.assertTrue(mods["base"])
|
|
self.assertTrue(mods["my-mod"])
|
|
|
|
def test_adds_recycler_disabled_to_new_mod_list(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
path = Path(directory) / "mods" / "mod-list.json"
|
|
|
|
subprocess.run(["bash", str(SCRIPT), str(path)], check=True)
|
|
mods = {mod["name"]: mod["enabled"] for mod in json.loads(path.read_text())["mods"]}
|
|
|
|
self.assertTrue(mods["base"])
|
|
self.assertFalse(mods["recycler"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|