Files
WoW-Hybrid-gateway/tests/item_body_native_context_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

39 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Exact original-native identity context for source body relationships only."""
from pathlib import Path
import copy,json,sys,unittest
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
from item_model_resources import compose_resource_package
class NativeBodyContextTest(unittest.TestCase):
@classmethod
def setUpClass(cls):cls.fixture=json.loads((Path(__file__).parent/'fixtures/source-body-native-existing-context.json').read_text())
def inputs(self):return copy.deepcopy(self.fixture)
def compose(self,f):return compose_resource_package(f['package'],f['resources'],f['displays'],f['native'],f['basics'],f['registry'],native_sparse=f['native_sparse'])
def target(self,f,table):return next(r for r in f[table]if r['ID']==f['source_item'])
def test_native_identity_supplies_context_without_redundant_metadata(self):
f=self.inputs();out,review=self.compose(f);self.assertFalse(review['blocked']);self.assertEqual(len(review['bindings']),1)
self.assertFalse(any(r['table_name']in('Item','ItemSparse')for r in out['rows']))
self.assertEqual(out['rows'][:len(f['package']['rows'])],f['package']['rows'])
def test_changed_native_name_rejected(self):
f=self.inputs();self.target(f,'native_sparse')['Display_lang']='Unrelated native identity'
with self.assertRaises(ValueError):self.compose(f)
def test_changed_native_class_rejected(self):
f=self.inputs();self.target(f,'basics')['ClassID']=2
with self.assertRaises(ValueError):self.compose(f)
def test_changed_native_subclass_rejected(self):
f=self.inputs();self.target(f,'basics')['SubclassID']+=1
with self.assertRaises(ValueError):self.compose(f)
def test_changed_native_basic_inventory_rejected(self):
f=self.inputs();self.target(f,'basics')['InventoryType']=1
with self.assertRaises(ValueError):self.compose(f)
def test_changed_native_sparse_inventory_rejected(self):
f=self.inputs();self.target(f,'native_sparse')['InventoryType']=1
with self.assertRaises(ValueError):self.compose(f)
def test_missing_native_sparse_remains_blocked(self):
f=self.inputs();f['native_sparse']=[r for r in f['native_sparse']if r['ID']!=f['source_item']];_,review=self.compose(f)
self.assertEqual([r['item_id']for r in review['blocked']],[f['source_item']])
def test_generic_binding_cannot_use_native_only_fallback(self):
f=self.inputs();del f['displays']['bindings'][0]['native_body_witness'];_,review=self.compose(f)
self.assertEqual([r['item_id']for r in review['blocked']],[f['source_item']])
if __name__=='__main__':unittest.main()