22 lines
1.5 KiB
Python
22 lines
1.5 KiB
Python
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_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)
|