Files
WoW-Hybrid-gateway/tests/restoration_category_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

42 lines
3.1 KiB
Python

"""Positive same-ID category corrections retain variable healing and restrictions."""
import copy,sys,unittest
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1];sys.path[:0]=[str(ROOT/'ops'),str(ROOT/'tests')]
import spell_restore_compat as m,spell_passive_compat as codec
import spell_restore_compat_test as restore
from spell_definition_common import spell_category_namespace
class RestorationCategoryTest(unittest.TestCase):
def fixture(self):
v=restore.RestorationCompatibilityTest().fixture();s=next(r for r in v[2]if r['entry']==27418)
s.update(spell_category_context=spell_category_namespace(Path.home()/'Servers/tortoise-wow/src/game/Spells/SpellDefines.h',ROOT.parent/'servers/trinity-forever/src/server/game/Miscellaneous/SharedDefines.h'),defense_type=1,prevention_type=0)
v[4]['SpellCategories']=codec.fields(ROOT.parent/'tools/WoWDBDefs/definitions/SpellCategories.dbd','SpellCategories');v[5]['SpellCategories']=1400000
return v
def test_same_id_category_is_corrected_without_changing_existing_heal_range(self):
v=self.fixture();before=copy.deepcopy(v[2:]);r=restore.RestorationCompatibilityTest().run_component(v)
self.assertEqual(v[2:],before);rows=[x for x in r['records']if x['table_name']=='SpellCategories'];self.assertEqual(len(rows),1)
old=next(x for x in v[3]['SpellCategories']if x['SpellID']==27418)
self.assertEqual(rows[0]['record'],dict(old,DefenseType=1));self.assertEqual(rows[0]['changed_fields'],['DefenseType'])
self.assertFalse(any(x['id']==703985 for x in r['records']))
def test_missing_proof_missing_row_or_other_restrictions_reject(self):
for mode in ('proof','row','mechanic','condition','schema','boolean'):
v=self.fixture();s=next(r for r in v[2]if r['entry']==27418);n=next(r for r in v[3]['SpellCategories']if r['SpellID']==27418)
if mode=='proof':del s['spell_category_context']
elif mode=='row':v[3]['SpellCategories'].remove(n)
elif mode=='mechanic':n['Mechanic']=1
elif mode=='condition':n['StartRecoveryCategory']=999
elif mode=='schema':del v[4]['SpellCategories']
else:s['defense_type']=True
with self.assertRaises(ValueError,msg=mode):restore.RestorationCompatibilityTest().run_component(v)
def test_correct_category_is_noop_and_default_context_stays_strict(self):
v=self.fixture();next(r for r in v[3]['SpellCategories']if r['SpellID']==27418)['DefenseType']=1
r=restore.RestorationCompatibilityTest().run_component(v);self.assertFalse(any(x['table_name']=='SpellCategories'for x in r['records']))
v=restore.RestorationCompatibilityTest().fixture();next(r for r in v[3]['SpellCategories']if r['SpellID']==27418)['DefenseType']=1
with self.assertRaises(ValueError):restore.RestorationCompatibilityTest().run_component(v)
def test_neutral_absent_category_is_preserved_without_fabricating_a_row(self):
v=self.fixture();s=next(r for r in v[2]if r['entry']==27418)
s['defense_type']=0;s['timing']['startRecoveryCategory']=0
v[3]['SpellCategories'][:]=[r for r in v[3]['SpellCategories']if r['SpellID']!=27418]
r=restore.RestorationCompatibilityTest().run_component(v)
self.assertFalse(any(x['table_name']=='SpellCategories'for x in r['records']))
if __name__=='__main__':unittest.main()