import json,sys,tempfile,unittest,shutil from pathlib import Path sys.path.insert(0,str(Path(__file__).resolve().parent)) import cooking_beta_artwork as art ROOT=Path(__file__).resolve().parents[1] class CookingArtworkTest(unittest.TestCase): def test_all99_authored_icons_have_closed_models_and_source_hashes(self): files=art.artwork(ROOT) self.assertEqual(len(files),297) self.assertEqual(sum(n.endswith('.png')for n in files),99) self.assertEqual(len({b for n,b in files.items()if n.endswith('.png')}),99) self.assertTrue(all(n.startswith('assets/dunerealms/')and'/cooking/'in n for n in files)) def test_unknown_preimage_cannot_be_overwritten(self): with tempfile.TemporaryDirectory()as tmp: base=Path(tmp)/'old';base.write_bytes(b'wrong pack');out=Path(tmp)/'new' with self.assertRaisesRegex(ValueError,'preimage'):art.assemble(ROOT,base,out,'network') self.assertEqual(base.read_bytes(),b'wrong pack');self.assertFalse(out.exists()) def test_missing_or_unreviewed_texture_is_rejected(self): with tempfile.TemporaryDirectory()as tmp: root=Path(tmp);artRoot=root/'network/resource-pack/cooking-beta';source=ROOT/'network/resource-pack/cooking-beta' shutil.copytree(source,artRoot) dst=root/'network/content-assets/cookbook';dst.mkdir(parents=True) shutil.copyfile(ROOT/'network/content-assets/cookbook/regional-cooking.json',dst/'regional-cooking.json') png=artRoot/'overlay/assets/dunerealms/textures/item/cooking/pork_mince.png' data=png.read_bytes();png.write_bytes(data+b'unreviewed') with self.assertRaisesRegex(ValueError,'hash mismatch'):art.artwork(root) png.unlink() with self.assertRaises(FileNotFoundError):art.artwork(root) if __name__=='__main__':unittest.main()