Files
AVA2/tests/pack_assets_test.py
T
shenandshen 281418f351 Fix cross-platform rendering and optimize frame performance
Correct selection orientation, game-entry lifecycle, mounted NPCs, labels and skill panels. Add the native GPU scene path, resident geometry, bounded texture and Python caches, and collision broad phase.

Pin the independently maintained Metin2 SDK through a submodule and document reproducible setup. Include rendering regressions and macOS packaging improvements.

Validation: client Debug build and 12 targeted client tests passed; SDK build and all 14 SDK tests passed.
2026-10-11 17:55:53 -07:00

46 lines
2.3 KiB
Python

import sys
import tempfile
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tools'))
from pack_assets import package_assets, verify_assets
class PackagingTests(unittest.TestCase):
def test_virtual_patch_paths_and_required_files(self):
with tempfile.TemporaryDirectory() as tmp:
base = Path(tmp)
source = base / 'client'
source.mkdir()
scripts = source / 'upstream/python-root'
scripts.mkdir(parents=True)
(scripts / 'uiCommon.py').write_text('class Dialog: pass\n')
(scripts / 'pack_maker').symlink_to(base / 'outside')
packs = base / 'pack_maker'
packs.mkdir()
loose = base / 'svside/empty.jpg'
loose.parent.mkdir()
loose.write_bytes(b'loose UI texture')
data = packs / 'patch_design_wa/rework_inv/new_equipment_bg.tga'
data.parent.mkdir(parents=True)
data.write_bytes(b'patch texture')
xml = packs / 'patch_design_wa_create.xml'
xml.write_text('<File ArchivedPath="rework_inv/new_equipment_bg.tga"><![CDATA[pack_maker/patch_design_wa/rework_inv/new_equipment_bg.tga]]></File>')
output = base / 'bundle'
manifest = package_assets(source, output, pack_maker=packs)
self.assertIn('root/uiCommon.py', manifest['files'])
self.assertTrue((output / 'root/uiCommon.py').is_file())
self.assertFalse((output / 'root/pack_maker').exists())
self.assertEqual((output / 'svside/empty.jpg').read_bytes(), loose.read_bytes())
self.assertIn('rework_inv/new_equipment_bg.tga', manifest['files'])
self.assertEqual((output / 'rework_inv/new_equipment_bg.tga').read_bytes(), data.read_bytes())
self.assertTrue(verify_assets(output / 'asset_manifest.json', output))
data.unlink()
with self.assertRaises(FileNotFoundError):
package_assets(source, base / 'broken', pack_maker=packs)
xml.write_text('<File ArchivedPath="../escape"><![CDATA[pack_maker/patch_design_wa/rework_inv/new_equipment_bg.tga]]></File>')
with self.assertRaises(ValueError):
package_assets(source, base / 'unsafe', pack_maker=packs)
if __name__ == '__main__':
unittest.main()