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

46 lines
3.9 KiB
Python

"""Synthetic joined family test; no native installation or simulated proc roll."""
import copy,hashlib,sys,unittest
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1];sys.path[:0]=[str(ROOT/'ops'),str(ROOT/'tests')]
import spell_item_proc_compat as m,spell_passive_compat as codec
from spell_definition_common import proc_namespace
import spell_defensive_buff_test as defensive
import spell_category_context_test as category
import spell_item_proc_compat_test as proc
class IncomingDefensiveProcTest(unittest.TestCase):
def fixture(self):
child=defensive.DefensiveBuffTest().fixture();converted=defensive.DefensiveBuffTest().convert(child)
base=proc.ItemProcCompatibilityTest().fixture();src=category.SpellCategoryContextTest().source(52837)
src.update(entry=600143,name='Synthetic Incoming Defensive Proc',description='Chance to gain a defensive shield.',spellIconId=1)
src['effects'][0][10]=child[0][0]['entry']
child[2]['SpellAuraOptions']=base[2]['SpellAuraOptions'];child[3]['SpellAuraOptions']=1500000
for row in base[1]['SpellDuration']:
if not any(r['ID']==row['ID']for r in child[1]['SpellDuration']):child[1]['SpellDuration'].append(copy.deepcopy(row))
child[5]['source_tables']['SpellDuration'].by_id.update(base[5]['source_tables']['SpellDuration'].by_id)
options=dict(child[5]);options.update(proc_proof=proc_namespace(category.SpellCategoryContextTest().paths()[0],ROOT.parent/'servers/trinity-forever/src/server/game/Spells/SpellMgr.h',incoming_harmful=True),
trigger_sources={child[0][0]['entry']:child[0][0]},trigger_records=converted['records'],
proc_overrides=dict(kind='local-source-proc-override-snapshot',table='tw_world.spell_proc_event',source_spell_ids=[src['entry'],child[0][0]['entry']],two_reads_equal=True,database_modified=False,rows=[]),new_icon_ids={str(src['entry']):136235},incoming_harmful=True)
return [src],child[1],child[2],child[3],converted['child_id_registry'],options
def convert(self,v):return m.new_component(*v[:5],**v[5])
def test_joined_family_keeps_event_chance_trigger_and_both_category_children(self):
v=self.fixture();r=self.convert(v);self.assertFalse(r['installable']);self.assertFalse(r['gameplay_verified'])
option=next(x['record']for x in r['records']if x['table_name']=='SpellAuraOptions')
self.assertEqual((option['ProcChance'],option['ProcTypeMask']),(20,[139944,0]))
effect=next(x['record']for x in r['records']if x['table_name']=='SpellEffect');self.assertEqual(effect['EffectTriggerSpell'],600142)
self.assertEqual(r['spells'][0]['trigger_dependencies'][0]['definition_family'],'finite-self-physical-reduction-defense')
both=v[5]['trigger_records']+r['records'];self.assertEqual(len({(x['table_name'],x['id'])for x in both}),len(both))
categories=[x['record']for x in both if x['table_name']=='SpellCategories'];self.assertEqual(len(categories),2)
self.assertTrue(all(x['DefenseType']==1 and x['PreventionType']==0 for x in categories))
def test_missing_reencoded_category_and_default_event_policy_cannot_pass(self):
for mode in ('missing-category','wrong-category','missing-proof','default-policy'):
v=list(self.fixture())
if mode=='missing-category':v[5]['trigger_records']=[r for r in v[5]['trigger_records']if r['table_name']!='SpellCategories']
elif mode=='wrong-category':
r=next(x for x in v[5]['trigger_records']if x['table_name']=='SpellCategories');r['record']['DefenseType']=0;raw=codec.encode(r['record'],v[2]['SpellCategories']);r.update(wire_hex=raw.hex(),sha256=hashlib.sha256(raw).hexdigest())
elif mode=='missing-proof':del v[0][0]['spell_category_context']
else:v[5]['incoming_harmful']=False
with self.assertRaises(ValueError,msg=mode):self.convert(v)
if __name__=='__main__':unittest.main()