feat: add CH5 cube renewal presentation, trade level UI, audit manifests, and test fixtures
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import quiver_assets as q
|
||||
|
||||
|
||||
class QuiverAssetTests(unittest.TestCase):
|
||||
def test_relative_windows_paths_and_cycles(self):
|
||||
files = {'d:/ymir work/pc/assassin/bow/' + n: b'' for n in q.MOTIONS}
|
||||
files.update({'d:/ymir work/pc2/assassin/bow/' + n: b'' for n in q.MOTIONS})
|
||||
special = 'd:/ymir work/pc/assassin/bow/attack_special.msa'
|
||||
raw = b'MotionFileName "attack.gr2"\nEffect "d:\\ymir work\\pc\\assassin\\effect\\arrow_02.msf"'
|
||||
files['d:/ymir work/pc/assassin/bow/attack.gr2'] = b'existing-model'
|
||||
files['d:/ymir work/pc/assassin/effect/arrow_02.msf'] = b'Effect "../bow/attack_special.msa"'
|
||||
del files[special]
|
||||
missing, records = q.collect(files.get, lambda p: raw if p == special else None)
|
||||
self.assertEqual(missing, {special: raw})
|
||||
self.assertEqual(len(records), 20)
|
||||
self.assertEqual(records[special]['origin'], 'ava2_reference')
|
||||
|
||||
def test_current_artwork_is_never_overridden(self):
|
||||
def reference(p):
|
||||
raise AssertionError('should not consult reference')
|
||||
missing, records = q.collect(lambda p: b'current', reference)
|
||||
self.assertEqual(missing, {})
|
||||
self.assertEqual(len(records), 18)
|
||||
|
||||
def test_missing_dependency_rejects(self):
|
||||
with self.assertRaisesRegex(ValueError, 'missing quiver dependency'):
|
||||
q.collect(lambda p: None, lambda p: None)
|
||||
|
||||
def test_path_escape_rejects(self):
|
||||
for raw in [b'"../../../../../private.tga"', b'"e:/private.tga"']:
|
||||
with self.assertRaises(ValueError):
|
||||
q.dependencies('d:/ymir work/pc/assassin/bow/attack_special.msa', raw)
|
||||
|
||||
def test_closure_limit(self):
|
||||
with self.assertRaisesRegex(ValueError, 'exceeds limit'):
|
||||
q.collect(lambda p: b'', lambda p: None, maximum=1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,52 @@
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
import stage_quiver_client as q
|
||||
|
||||
|
||||
class StagingTests(unittest.TestCase):
|
||||
def setup_tree(self, root):
|
||||
base=root/'base';candidate=root/'candidate'
|
||||
(base/'pack').mkdir(parents=True);candidate.mkdir()
|
||||
(base/'pack/Index').write_bytes(b'PACK\n*\nroot\n')
|
||||
(base/'pack/root.eix').write_bytes(b'base index')
|
||||
(base/'pack/root.epk').write_bytes(b'base data')
|
||||
(base/'locale.cfg').write_bytes(b'1 936 zh')
|
||||
for name in ('quiver.eix','quiver.epk'):(candidate/name).write_bytes(name.encode())
|
||||
path='d:/ymir work/pc/assassin/bow/attack_special.msa'
|
||||
asset=candidate/'assets'/path;asset.parent.mkdir(parents=True);asset.write_bytes(b'motion')
|
||||
report=dict(files={p.relative_to(candidate).as_posix():q.digest(p)
|
||||
for p in candidate.rglob('*') if p.is_file()},
|
||||
effective_client_base=dict(index_sha256=q.digest(base/'pack/Index')),
|
||||
motion_assets={path:dict(origin='ava2_reference',sha256=q.digest(asset))})
|
||||
(candidate/'manifest.json').write_text(json.dumps(report))
|
||||
return base,candidate
|
||||
|
||||
def test_private_overlay_does_not_modify_base(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
root=Path(folder);base,candidate=self.setup_tree(root)
|
||||
original=(base/'pack/Index').read_bytes()
|
||||
q.stage(base,candidate,root/'test',root/'unused-packer')
|
||||
self.assertEqual((base/'pack/Index').read_bytes(),original)
|
||||
self.assertEqual((root/'test/pack/Index').read_bytes(),b'PACK\n*\nch5_quiver_candidate\n*\nroot\n')
|
||||
self.assertTrue((root/'test/pack/root.epk').is_symlink())
|
||||
self.assertFalse((root/'test/locale.cfg').is_symlink())
|
||||
with self.assertRaisesRegex(ValueError,'must not exist'):
|
||||
q.stage(base,candidate,root/'test',root/'unused-packer')
|
||||
|
||||
def test_stale_index_or_corrupt_pack_rejects_before_output(self):
|
||||
for corrupt in ('base','candidate'):
|
||||
with self.subTest(corrupt=corrupt),tempfile.TemporaryDirectory() as folder:
|
||||
root=Path(folder);base,candidate=self.setup_tree(root)
|
||||
path=base/'pack/Index' if corrupt=='base' else candidate/'quiver.epk'
|
||||
path.write_bytes(b'changed')
|
||||
with self.assertRaises(ValueError):q.stage(base,candidate,root/'test',root/'unused-packer')
|
||||
self.assertFalse((root/'test').exists())
|
||||
|
||||
|
||||
if __name__ == '__main__':unittest.main()
|
||||
Reference in New Issue
Block a user