883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
40 lines
2.9 KiB
Python
40 lines
2.9 KiB
Python
"""Permanent enchant family semantics; source fixture is public game data only."""
|
|
import copy,json,sys,unittest
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'ops'))
|
|
from item_enchantment_visual_profile import constant_enchantment_rows
|
|
from spell_passive_compat import fields
|
|
from turtle_data import spell_layout
|
|
FIXTURE=json.loads((ROOT/'tests/fixtures/scalar-enchantment-source.json').read_text())
|
|
SCHEMA=fields(ROOT.parent/'tools/WoWDBDefs/definitions/SpellItemEnchantment.dbd','SpellItemEnchantment')
|
|
class EnchantBatchTest(unittest.TestCase):
|
|
def inputs(self):
|
|
f=copy.deepcopy(FIXTURE)
|
|
en=SimpleNamespace(fields=24,by_id={int(i):r for i,r in f['enchants'].items()},string=lambda i:f['strings'][str(i)])
|
|
sp=SimpleNamespace(fields=173,by_id={int(i):r for i,r in f['spells'].items()})
|
|
return en,sp,f['native'],f['proof']
|
|
def run_batch(self,parts):return constant_enchantment_rows(*parts[:3],SCHEMA,parts[3])
|
|
def test_source_health_and_compound_armor_stamina(self):
|
|
parts=self.inputs();original=copy.deepcopy(parts[2]);out=self.run_batch(parts);rows={r['id']:r['record']for r in out['rows']}
|
|
self.assertEqual(rows[1892]['Name_lang'],'Health +100');self.assertEqual(rows[1892]['Effect'],[5,0,0]);self.assertEqual(rows[1892]['EffectArg'],[1,0,0]);self.assertEqual(rows[1892]['EffectPointsMin'],[100,0,0])
|
|
self.assertEqual(rows[1843]['Effect'],[4,5,0]);self.assertEqual(rows[1843]['EffectArg'],[0,7,0]);self.assertEqual(rows[1843]['EffectPointsMin'],[40,5,0])
|
|
for before in original:
|
|
after=rows[before['ID']]
|
|
for k in set(before)-{'Name_lang','HordeName_lang','Effect','EffectArg','EffectPointsMin'}:self.assertEqual(before[k],after[k],k)
|
|
self.assertEqual(parts[2],original);self.assertEqual(out,self.run_batch(parts));self.assertFalse(out['engine_loaded'])
|
|
def test_unrelated_groups_continue_on_unreviewed_source(self):
|
|
o=spell_layout()
|
|
for mutate in (lambda en,sp,n:en.by_id[1843].__setitem__(23,1),lambda en,sp,n:sp.by_id.pop(7503),lambda en,sp,n:sp.by_id[7503].__setitem__(o['Effect']+1,6),lambda en,sp,n:sp.by_id[7503].__setitem__(o['EffectDieSides'],2),lambda en,sp,n:n[0].__setitem__('Duration',600)):
|
|
parts=self.inputs();mutate(*parts[:3]);out=self.run_batch(parts)
|
|
self.assertEqual([r['id']for r in out['rows']],[1892]);self.assertEqual(out['blocked'][0]['enchantment'],1843)
|
|
def test_requires_verified_schema_and_namespace(self):
|
|
parts=self.inputs()
|
|
with self.assertRaises(ValueError):constant_enchantment_rows(*parts[:3],SCHEMA,{})
|
|
with self.assertRaises(ValueError):constant_enchantment_rows(*parts[:3],[],parts[3])
|
|
def test_source_effect_amount_and_unused_slot_not_guessed(self):
|
|
for slot,value in ((7,41),(12,3)):
|
|
parts=self.inputs();parts[0].by_id[1843][slot]=value;out=self.run_batch(parts)
|
|
self.assertEqual([r['id']for r in out['rows']],[1892]);self.assertTrue(out['blocked'])
|
|
if __name__=='__main__':unittest.main()
|