"""Selection metadata must not make an otherwise valid native runtime unloadable.""" import copy import unittest from search_bridge import compile_search_runtime class NativeRuntimeBoundaryTests(unittest.TestCase): def test_strips_only_selection_layer_paths_without_mutating_original(self): template=dict(python='/usr/bin/python3',prepared_asset_pool='/pool.sqlite3', attribute_release='/attributes.json',annotation_index='/native.sqlite3', retrieval_index='/full.sqlite3',appearance_index='/appearance.sqlite3', material_artifact_index='/accepted_materials.json') before=copy.deepcopy(template) native=compile_search_runtime(template,{}) self.assertEqual(native,{k:v for k,v in template.items() if k not in {'retrieval_index','appearance_index','material_artifact_index'}}) self.assertEqual(template,before) def test_preserves_unknown_keys_for_native_validation_to_reject(self): self.assertEqual(compile_search_runtime({'typo_native_key':123},{}), {'typo_native_key':123}) if __name__=='__main__':unittest.main() class NativeExecutableTests(unittest.TestCase): def test_native_driver_and_blender_use_the_case_runtime_executables(self): import json import tempfile from pathlib import Path from real_test.run_server_house import native_commands with tempfile.TemporaryDirectory() as directory: runtime=Path(directory)/'runtime.json' runtime.write_text(json.dumps(dict(python='/qualified/venv/bin/python',blender='/qualified/blender'))) commands=native_commands(Path(directory)/'source',runtime,'/request','/output') self.assertEqual(commands[0][0],'/qualified/venv/bin/python') self.assertTrue(all(c[0]=='/qualified/blender' for c in commands[1:]))