Build independent base gameplay and source-bound native verification
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
"""Offline resource compatibility checks; these are not native loading tests."""
|
||||
import hashlib
|
||||
import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CORE = ROOT / "addons/core"
|
||||
VANILLA_NORMALIZED_SHA256 = {
|
||||
"US": "d8d16abbecadc6987ca7eed3b114446d0af5753535c891fcefc20d5b2d7db583",
|
||||
"USSR": "2d3d3af74d0da33017ae3132c613fc9c19c0d20cd850a9830bb208db59e4bf25",
|
||||
}
|
||||
OLD_VEHICLES = {
|
||||
"US": "{D83A5EFEEF6CBF61}Configs/EntityCatalog/US/Vehicles_EntityCatalog_US.conf",
|
||||
"USSR": "{09C2ED5F617A0390}Configs/EntityCatalog/USSR/Vehicles_EntityCatalog_USSR.conf",
|
||||
}
|
||||
|
||||
|
||||
class FactionCatalogScopeTests(unittest.TestCase):
|
||||
def test_only_vehicle_catalog_changes_from_installed_faction_profiles(self):
|
||||
for side in ("US", "USSR"):
|
||||
with self.subTest(side=side):
|
||||
text = (CORE / f"Configs/ERR/Factions/{side}.conf").read_text()
|
||||
restored, count = re.subn(
|
||||
r"\{[A-F0-9]{16}\}Configs/ERR/Factions/MissionVehicles\.conf",
|
||||
lambda _: OLD_VEHICLES[side], text,
|
||||
)
|
||||
self.assertEqual(count, 1)
|
||||
# Pin every other vanilla field, including all inventory/group
|
||||
# references, radio/identity/callsign/rank settings and base.
|
||||
self.assertEqual(hashlib.sha256(restored.encode()).hexdigest(),
|
||||
VANILLA_NORMALIZED_SHA256[side])
|
||||
|
||||
def test_vehicle_catalog_has_only_the_two_authored_assets(self):
|
||||
text = (CORE / "Configs/ERR/Factions/MissionVehicles.conf").read_text()
|
||||
self.assertRegex(text, r"^SCR_EntityCatalogMultiList\s*\{")
|
||||
prefabs = re.findall(r'm_sEntityPrefab\s+"([^\"]+)"', text)
|
||||
self.assertCountEqual(prefabs, [
|
||||
"{259EE7B78C51B624}Prefabs/Vehicles/Wheeled/UAZ469/UAZ469.et",
|
||||
"{DF5CCB7C0FF049F4}Prefabs/Vehicles/Helicopters/Mi8MT/Mi8MT_unarmed_transport.et",
|
||||
])
|
||||
self.assertEqual(len(prefabs), 2)
|
||||
|
||||
def test_world_uses_own_manager_without_full_vanilla_faction_inheritance(self):
|
||||
manager = (CORE / "Prefabs/ERR/FactionManager.et").read_text()
|
||||
self.assertIn("Prefabs/MP/Managers/Factions/FactionManager_Base.et", manager)
|
||||
self.assertNotIn("FactionManager_USxUSSR.et", manager)
|
||||
for side in ("US", "USSR"):
|
||||
self.assertIn(f"Configs/ERR/Factions/{side}.conf", manager)
|
||||
self.assertNotIn(f"Configs/Factions/{side}.conf", manager)
|
||||
layer = (CORE / "Worlds/ERR_Everon_Layers/default.layer").read_text()
|
||||
self.assertEqual(layer.count("Prefabs/ERR/FactionManager.et"), 1)
|
||||
self.assertNotIn("FactionManager_USxUSSR.et", layer)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user