Feature Complete Shipping V1.0
This commit is contained in:
@@ -66,11 +66,66 @@ class InGameLuaContractTests(unittest.TestCase):
|
||||
"shared/PaintMyKI5/TimedActions/ISPaintMyKI5Vehicle.lua",
|
||||
"client/PaintMyKI5/ISPaintMyKI5UI.lua",
|
||||
"client/PaintMyKI5/PaintVehicleContextMenu.lua",
|
||||
"shared/PaintMyKI5/TextureName.lua",
|
||||
)
|
||||
|
||||
def test_runtime_files_exist(self) -> None:
|
||||
self.assertEqual([], [name for name in self.EXPECTED_FILES if not (LUA_ROOT / name).is_file()])
|
||||
|
||||
def test_art_assets_are_packaged_for_mod_and_context_menus(self) -> None:
|
||||
source_icon = (PROJECT_ROOT / "art/icon.png").read_bytes()
|
||||
source_preview = (PROJECT_ROOT / "art/preview.png").read_bytes()
|
||||
|
||||
for directory in (PROJECT_ROOT, PROJECT_ROOT / "42.20"):
|
||||
self.assertEqual(source_icon, (directory / "icon.png").read_bytes())
|
||||
self.assertEqual(source_preview, (directory / "preview.png").read_bytes())
|
||||
metadata = (directory / "mod.info").read_text(encoding="utf-8")
|
||||
self.assertIn("icon=icon.png", metadata)
|
||||
self.assertIn("poster=preview.png", metadata)
|
||||
|
||||
self.assertEqual(
|
||||
source_icon,
|
||||
(PROJECT_ROOT / "common/media/textures/PaintMyKI5_ContextMenu.png").read_bytes(),
|
||||
)
|
||||
context_source = (LUA_ROOT / self.EXPECTED_FILES[4]).read_text(encoding="utf-8")
|
||||
self.assertIn(
|
||||
'getTexture("media/textures/PaintMyKI5_ContextMenu.png")',
|
||||
context_source,
|
||||
)
|
||||
|
||||
def test_sandpaper_item_icon_translation_and_loot_loader_are_packaged(self) -> None:
|
||||
item_script = (
|
||||
PROJECT_ROOT / "42.20/media/scripts/PaintMyKI5_items.txt"
|
||||
).read_text(encoding="utf-8")
|
||||
sandpaper = re.search(r"item\s+Sandpaper\s*\{(.*?)\}", item_script, re.S)
|
||||
self.assertIsNotNone(sandpaper)
|
||||
self.assertIn("ItemType = base:normal", sandpaper.group(1))
|
||||
self.assertIn("Icon = Sandpaper", sandpaper.group(1))
|
||||
self.assertEqual(
|
||||
(PROJECT_ROOT / "art/sandpaper.png").read_bytes(),
|
||||
(PROJECT_ROOT / "common/media/textures/Item_Sandpaper.png").read_bytes(),
|
||||
)
|
||||
|
||||
translations = json.loads(
|
||||
(
|
||||
PROJECT_ROOT
|
||||
/ "42.20/media/lua/shared/Translate/EN/ItemName.json"
|
||||
).read_text(encoding="utf-8")
|
||||
)
|
||||
self.assertEqual("Sandpaper", translations["ItemName_PaintMyKI5.Sandpaper"])
|
||||
self.assertFalse(
|
||||
(
|
||||
PROJECT_ROOT
|
||||
/ "42.20/media/lua/shared/Translate/EN/ItemName_EN.json"
|
||||
).exists()
|
||||
)
|
||||
self.assertTrue(
|
||||
(
|
||||
PROJECT_ROOT
|
||||
/ "42.20/media/lua/server/Items/PaintMyKI5_SandpaperDistribution.lua"
|
||||
).is_file()
|
||||
)
|
||||
|
||||
def test_server_authoritative_timed_action_contract(self) -> None:
|
||||
source = (LUA_ROOT / self.EXPECTED_FILES[2]).read_text(encoding="utf-8")
|
||||
|
||||
@@ -78,6 +133,7 @@ class InGameLuaContractTests(unittest.TestCase):
|
||||
self.assertIn("function ISPaintMyKI5Vehicle:complete()", source)
|
||||
self.assertIn("PaintRequirements.getRequirements", source)
|
||||
self.assertIn("PaintInventory.consumeRequirements", source)
|
||||
self.assertGreaterEqual(source.count("checkPaintingRequirements"), 2)
|
||||
self.assertIn("vehicle:setSkinIndex", source)
|
||||
self.assertIn("vehicle:transmitSkinIndex", source)
|
||||
self.assertNotRegex(source, r"sendClientCommand\([^\n]+setSkinIndex")
|
||||
@@ -91,8 +147,26 @@ class InGameLuaContractTests(unittest.TestCase):
|
||||
self.assertIn("getTexture", ui_source)
|
||||
self.assertIn("or getTexture(textureData.texture)", ui_source)
|
||||
self.assertIn("drawTextureScaledAspect", ui_source)
|
||||
self.assertGreaterEqual(ui_source.count("PaintRequirements.isValidTarget"), 2)
|
||||
self.assertIn("PaintMyKI5.TextureName.buildLabels", ui_source)
|
||||
self.assertIn("paintButton:setTooltip", ui_source)
|
||||
self.assertIn("checkPaintingRequirements", ui_source)
|
||||
self.assertGreaterEqual(ui_source.count("PaintRequirements.isValidSelection"), 2)
|
||||
self.assertNotIn("PaintRequirements.isValidTarget", ui_source)
|
||||
self.assertIn("ISTimedActionQueue.add", ui_source)
|
||||
self.assertLess(
|
||||
ui_source.index("ISPathFindAction:pathToVehicleArea"),
|
||||
ui_source.index("ISPaintMyKI5Vehicle:new"),
|
||||
)
|
||||
|
||||
translations = json.loads(
|
||||
(LUA_ROOT / "shared/Translate/EN/IG_UI.json").read_text(encoding="utf-8")
|
||||
)
|
||||
self.assertEqual(
|
||||
"Missing requirements:",
|
||||
translations["IGUI_PaintMyKI5_MissingRequirements"],
|
||||
)
|
||||
self.assertIn("%1", translations["IGUI_PaintMyKI5_MissingTool"])
|
||||
self.assertIn("%1", translations["IGUI_PaintMyKI5_MissingPaint"])
|
||||
|
||||
def test_b42_translation_files_are_valid_json(self) -> None:
|
||||
context = json.loads(
|
||||
@@ -121,6 +195,31 @@ class InGameLuaContractTests(unittest.TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def test_generated_mustang_green_skin_is_classified_as_green(self) -> None:
|
||||
manifest = (
|
||||
LUA_ROOT / "shared/PaintMyKI5/PaintMyKI5VehiclePaintData.lua"
|
||||
).read_text(encoding="utf-8")
|
||||
vehicle = re.search(
|
||||
r'\["Base\.93mustangGT"\] = \{(.*?)\n \},\n'
|
||||
r' \["Base\.93mustangSSP"\]',
|
||||
manifest,
|
||||
re.S,
|
||||
)
|
||||
self.assertIsNotNone(vehicle)
|
||||
green_skin = re.search(
|
||||
r'texture = "Vehicles/Vehicles_93mustangGT_Shell_Green",'
|
||||
r"(.*?)\n \},",
|
||||
vehicle.group(1),
|
||||
re.S,
|
||||
)
|
||||
self.assertIsNotNone(green_skin)
|
||||
green_percentage = re.search(
|
||||
r'item = "Base\.PaintGreen", percent = ([\d.]+)',
|
||||
green_skin.group(1),
|
||||
)
|
||||
self.assertIsNotNone(green_percentage)
|
||||
self.assertGreaterEqual(float(green_percentage.group(1)), 90.0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user