Merge owned systems into one addon while preserving resource identities. Gate player admission on the replicated prison scene, restore the original framed door, and hold enemy AI until escape. Correct scenario branding and author metadata, include publishing assets, and retain regression and native verification evidence.
51 lines
3.7 KiB
Python
51 lines
3.7 KiB
Python
"""Actual external profile regression; all fixtures live in temporary directories."""
|
|
from pathlib import Path
|
|
import unittest,sys
|
|
sys.path[:0]=[str(Path(__file__).resolve().parent),str(Path(__file__).resolve().parents[1]/'tools')]
|
|
import test_external_addons as existing
|
|
import external_addons as ext
|
|
class ReviewTests(existing.ExternalAddonsTests):
|
|
# Parent tests stay in their separate unchanged module; only new cases run here.
|
|
def verify(self,records):return ext.verify_profile(records,self.source,self.value,self.cache,self.addons)
|
|
def test_review_retargeted_private_link_rejected(self):
|
|
records=ext.prepare_profile(self.addons,self.source,self.value,self.cache)
|
|
link=self.addons/('ERRI_'+ext.DIRECT[0]);link.unlink();link.symlink_to(self.source/ext.DIRECT[1],target_is_directory=True)
|
|
with self.assertRaisesRegex(ValueError,'link changed'):self.verify(records)
|
|
def test_review_missing_link_rejected(self):
|
|
records=ext.prepare_profile(self.addons,self.source,self.value,self.cache)
|
|
(self.addons/('ERRI_'+ext.DIRECT[0])).unlink()
|
|
with self.assertRaisesRegex(ValueError,'link changed'):self.verify(records)
|
|
def test_review_added_source_directory_rejected(self):
|
|
records=ext.prepare_profile(self.addons,self.source,self.value,self.cache)
|
|
source=self.source/ext.DIRECT[0]/'Scripts/Game/ForeignChange.c';source.parent.mkdir(parents=True);source.write_text('class ForeignChange {}')
|
|
with self.assertRaisesRegex(ValueError,'flat regular file'):self.verify(records)
|
|
def test_review_loose_root_resource_and_symlink_rejected(self):
|
|
records=ext.prepare_profile(self.addons,self.source,self.value,self.cache);p=self.source/ext.DIRECT[0]/'unaudited.et';p.write_text('Entity {}')
|
|
with self.assertRaisesRegex(ValueError,'Unreviewed'):self.verify(records)
|
|
p.unlink();p=self.source/ext.DIRECT[0]/'thumbnail.png';p.symlink_to(self.source/ext.DIRECT[0]/'data.pak')
|
|
with self.assertRaisesRegex(ValueError,'flat regular file'):self.verify(records)
|
|
def test_review_metadata_media_and_sidecars_remain_allowed_and_bound(self):
|
|
folder=self.source/ext.DIRECT[0]
|
|
for name in ('meta','ServerData.json','thumbnail.png','gallery0_776x436.jpg','addon.gproj_0.16.5208_manifest.json','data.pak_0.16.5208_manifest.json'):
|
|
(folder/name).write_bytes(b'metadata/media')
|
|
records=ext.prepare_profile(self.addons,self.source,self.value,self.cache)
|
|
self.assertTrue(self.verify(records));self.assertIn('thumbnail.png',records[ext.DIRECT[0]]['files'])
|
|
(folder/'thumbnail.png').write_bytes(b'changed');self.assertFalse(self.verify(records))
|
|
def test_review_added_allowed_media_invalidates_snapshot(self):
|
|
records=ext.prepare_profile(self.addons,self.source,self.value,self.cache)
|
|
(self.source/ext.DIRECT[0]/'gallery1_776x436.jpg').write_bytes(b'new');self.assertFalse(self.verify(records))
|
|
def test_review_package_guard_sees_new_scripts(self):
|
|
# Native package imports the shared implementation; exercise its real compare.
|
|
import native_package as n
|
|
from unittest.mock import patch
|
|
self.home.joinpath('docs').mkdir();import json
|
|
policy=self.home/'docs/external-addons.json';policy.write_text(json.dumps(self.value))
|
|
context=n.external_request('core',self.source,self.home);session=self.home/'session';session.mkdir()
|
|
with patch.object(n,'external_installed',ext.installed):
|
|
n.capture_external(context,session)
|
|
folder=self.source/ext.DIRECT[0]/'Scripts';folder.mkdir()
|
|
with self.assertRaisesRegex(ValueError,'flat regular file'):n.verify_external(context)
|
|
if __name__=='__main__':
|
|
suite=unittest.TestSuite(ReviewTests(n) for n in unittest.defaultTestLoader.getTestCaseNames(ReviewTests) if n.startswith('test_review_'))
|
|
result=unittest.TextTestRunner(verbosity=2).run(suite);raise SystemExit(not result.wasSuccessful())
|