Files
verstack/emulator/test_bundle_selection.py
Verstack Local f73167de85 Add downloadable VMs and improve catalog processing
Package Apple Silicon VM exports and cached runtime switching with local cabinet controls and conagent provisioning. Preserve experimental SPIKE 2 emulation.

Improve preparation concurrency, Ghidra checkpoints, signature importing, sound indexing and client-side spectrograms. Include regression tests and validation notes.
2026-09-14 20:03:59 -05:00

49 lines
2.4 KiB
Python

import unittest
from bundles.runtime_selection import select_runtime
def record(identity, name='Pokémon', version='0.83.0', arch='aarch64', sd=True):
return dict(id=identity, release=dict(repository=name,version=version),
architecture=arch,is_sd=sd,system_root='partition-02' if sd else None)
class RuntimeSelection(unittest.TestCase):
def test_own_sd_cannot_be_replaced_by_newer_donor(self):
game=record('own',version='0.81.0')
result=select_runtime(game,[record('new'),game])
self.assertEqual((result['runtime_id'],result['reason']),('own','own-sd'))
def test_missing_own_system_is_an_error(self):
with self.assertRaisesRegex(ValueError,'own system'):
select_runtime(record('own'),[record('other')])
def test_update_prefers_closest_title_before_other_games(self):
game=record('update',version='0.85.0',sd=False)
donors=[record('older',version='0.81.0'),record('closest'),
record('other',name='Other',version='0.85.0')]
for order in (donors,list(reversed(donors))):
self.assertEqual(select_runtime(game,order)['runtime_id'],'closest')
def test_numeric_versions_and_older_tie(self):
game=record('update',version='0.10.0',sd=False)
self.assertEqual(select_runtime(game,[record('new',version='0.11.0'),
record('old',version='0.9.0')])['runtime_id'],'old')
def test_family_fallback_excludes_wrong_arch_and_borrowed_runtime(self):
game=record('update',name='Other',sd=False)
result=select_runtime(game,[record('wrong',arch='armhf'),
record('borrowed',name='Other',sd=False),record('compatible')])
self.assertEqual((result['runtime_id'],result['reason']),('compatible','generation-sd'))
def test_shared_override_is_explicit_and_generation_scoped(self):
game=record('own')
donors=[game,record('shared',name='Other'),record('wrong',arch='armhf')]
self.assertEqual(select_runtime(game,donors,shared_runtime_id='shared')['reason'],
'experimental-shared-generation')
with self.assertRaisesRegex(ValueError,'same SPIKE generation'):
select_runtime(game,donors,shared_runtime_id='wrong')
def test_no_compatible_sd_is_an_error(self):
with self.assertRaisesRegex(ValueError,'No SD runtime'):
select_runtime(record('update',sd=False),[record('wrong',arch='armhf')])