mirror of
https://github.com/FelipePrado0/SpartanPort.git
synced 2026-11-07 10:45:59 -10:00
EN-US - Added EXEC and the language folders (ENGLISH, PORTUGUESE, ...) as mod roots - Dropped a mod's dvdroot_ps4/ prefix when the game has no dvdroot_ps4 (#473, #574) - Refused eboot.bin, sce_module and sce_sys, including through dvdroot_ps4/ - Matched conflicts across both layouts and documented the layout in docs/MODS.md - Credited @kris-c-anderson (#234), @jpthebaby (#473) and @reido601hz-lgtm (#574) --- PT-BR - Adicionadas EXEC e as pastas de idioma (ENGLISH, PORTUGUESE, ...) como raiz do mod - Descartado o prefixo dvdroot_ps4/ do mod quando o jogo não tem dvdroot_ps4 (#473, #574) - Recusados eboot.bin, sce_module e sce_sys, inclusive via dvdroot_ps4/ - Detectados conflitos entre os dois layouts e documentado o layout em docs/MODS.md - Creditados @kris-c-anderson (#234), @jpthebaby (#473) e @reido601hz-lgtm (#574)
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import paths # noqa: F401 (puts scripts/ on sys.path)
|
|
import mods
|
|
|
|
|
|
class ModConflictTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.temp = tempfile.TemporaryDirectory()
|
|
self.root = Path(self.temp.name)
|
|
|
|
def tearDown(self):
|
|
self.temp.cleanup()
|
|
|
|
def mod(self, name, *files):
|
|
for file in files:
|
|
path = self.root / name / 'dvdroot_ps4' / file
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_bytes(b'x')
|
|
|
|
def test_last_in_order_wins(self):
|
|
self.mod('a', 'chr/kratos.wad', 'ui/hud.wad')
|
|
self.mod('b', 'chr/kratos.wad')
|
|
self.mod('c', 'CHR/Kratos.wad', 'music.wad')
|
|
found = mods.conflicts(self.root, ['a', 'b', 'c'])
|
|
self.assertEqual(len(found), 1)
|
|
path, owners = found[0]
|
|
self.assertEqual(path.casefold(), 'chr/kratos.wad') # the game path: this game has no dvdroot_ps4
|
|
self.assertEqual(owners, ['a', 'b', 'c']) # c, the last one, wins
|
|
|
|
def test_only_given_mods_count(self):
|
|
self.mod('a', 'x.wad')
|
|
self.mod('b', 'x.wad')
|
|
self.assertEqual(mods.conflicts(self.root, ['a']), [])
|
|
|
|
def test_no_conflict_and_broken_mod(self):
|
|
self.mod('a', 'x.wad')
|
|
self.mod('b', 'y.wad')
|
|
(self.root / 'broken').mkdir()
|
|
self.assertEqual(mods.conflicts(self.root, ['a', 'b', 'broken', 'missing']), [])
|
|
|
|
def test_preset_skips_missing_and_appends_new(self):
|
|
order, disabled = mods.apply_preset({'order': ['b', 'gone', 'a'], 'disabled': ['a', 'gone']},
|
|
['a', 'b', 'c'])
|
|
self.assertEqual(order, ['b', 'a', 'c'])
|
|
self.assertEqual(disabled, ['a'])
|
|
|
|
def test_preset_with_bad_shape(self):
|
|
self.assertEqual(mods.apply_preset({'order': 'nope', 'disabled': None}, ['a']), (['a'], []))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|