import importlib.util from pathlib import Path import unittest from unittest.mock import patch ROOT=Path(__file__).resolve().parents[2] spec=importlib.util.spec_from_file_location('presence_package',ROOT/'scripts/package-avatar-emotion.py') pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack) class PresencePackageTests(unittest.TestCase): def test_face_diagnostics_release_preserves_startup_and_presence_and_uses_new_code(self): def stop_build(command,**kwargs): if command[0]=='python3':return self.assertIn('-PfaceDiagnosticsFix=true',command) self.assertIn('-PpresenceCandidate=true',command) self.assertIn('-PavatarStartupFix=true',command) self.assertIn('-PactionVersionCode=24',command) raise RuntimeError('build_sentinel') with patch.object(pack,'tested_source'),patch.object(pack,'packaging_tests_current'),patch.object(pack,'read_json',return_value={'edges':[{'nativeLoop':True}]}),patch.object(pack,'next_version',return_value=24),patch.object(pack.subprocess,'run',side_effect=stop_build): with self.assertRaises(ValueError):pack.publish({'manifest_sha256':pack.RUNTIME_FIX_PIN},None,24,full=True,startup_fix=True,face_diagnostics_fix=True) with self.assertRaisesRegex(RuntimeError,'build_sentinel'):pack.publish({'manifest_sha256':pack.RUNTIME_FIX_PIN},None,24,full=True,startup_fix=True,presence_candidate=True,face_diagnostics_fix=True) def test_fresh_presence_version_requires_startup_and_frozen_pack(self): report={'manifest_sha256':pack.RUNTIME_FIX_PIN} def stop_build(command,**kwargs): if command[0]=='python3': return self.assertIn('-PpresenceCandidate=true',command) self.assertIn('-PavatarStartupFix=true',command) self.assertIn('-PactionVersionCode=23',command) raise RuntimeError('build_sentinel') with patch.object(pack,'tested_source'),patch.object(pack,'packaging_tests_current'),patch.object(pack,'read_json',return_value={'edges':[{'nativeLoop':True}]}),patch.object(pack,'next_version',return_value=23),patch.object(pack.subprocess,'run',side_effect=stop_build): with self.assertRaises(ValueError):pack.publish(report,None,23,full=True,presence_candidate=True) with self.assertRaises(ValueError):pack.publish({**report,'manifest_sha256':'a'*64},None,23,full=True,startup_fix=True,presence_candidate=True) with self.assertRaisesRegex(RuntimeError,'build_sentinel'):pack.publish(report,None,23,full=True,startup_fix=True,presence_candidate=True)