"""Generic lamp slots may bind to lamp-family source categories; shades and other categories stay rejected.""" import sys import unittest from pathlib import Path BASE = Path(__file__).resolve().parents[1] sys.path.insert(0, str(BASE)) from room_program import _binding_transition_fields # noqa: E402 def _slot(**over): row = dict(entity_id='lamp', room_id='living', role='lamp', procedural_kind='bedside_lamp', category='lamp', asset_id='procedural:lamp') row.update(over) return row def _bound(category, **over): row = dict(entity_id='lamp', room_id='living', role='lamp', binding_semantic_key='lamp', category=category, asset_id='hssd:objects/a/aaaa', asset_sha256='a' * 64, runtime_sha256='b' * 64, canonical_path='/canon/x.glb', runtime_path='/run/x.glb', dimensions_m=[0.3, 0.3, 0.5], source_dimensions_m=[0.3, 0.3, 0.5], uniform_scale=1.0) row.update(over) return row MANIFEST = {'fixed_layout_real_asset_binding': {'binding_phase': 'final', 'final_binding_passed': True, 'uniform_scale_only': True, 'preserve_source_materials': True}} class LampSourceFamilyTests(unittest.TestCase): def test_generic_lamp_accepts_lamp_family_source_category(self): fields = _binding_transition_fields(_slot(), _bound('malay_lamp_base_furniture_base_d5b3'), MANIFEST) self.assertIn('category', fields) def test_generic_lamp_accepts_plain_table_lamp(self): self.assertIn('category', _binding_transition_fields(_slot(), _bound('table_lamp'), MANIFEST)) def test_lamp_shade_is_rejected(self): self.assertEqual(_binding_transition_fields(_slot(), _bound('lamp_shade'), MANIFEST), ()) def test_non_lamp_category_is_rejected(self): self.assertEqual(_binding_transition_fields(_slot(), _bound('plate'), MANIFEST), ()) def test_authored_lamp_subtype_stays_exact(self): self.assertEqual(_binding_transition_fields(_slot(category='floor_lamp'), _bound('table_lamp'), MANIFEST), ()) if __name__ == '__main__': unittest.main()