Files
WoW-Hybrid-gateway/tests/item_on_use_link_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.2 KiB
Python

"""Explicit equipment-use admission retains distinct slots and cooldowns."""
import copy
from pathlib import Path
import sys
import unittest
ROOT=Path(__file__).resolve().parents[1];sys.path[:0]=[str(ROOT/'ops'),str(ROOT/'tests')]
import item_effect_compat as m
import item_on_hit_link_test as fixture
from item_batch_stage import source_hash
class EquipmentUse(unittest.TestCase):
def inputs(self):
args,_=fixture.OnHitLinks().inputs();item=args[1][0];p=item['source']
p.update(spelltrigger_1=0,spellcooldown_1=60000,spellcategorycooldown_1=-1,spellid_2=600778,spelltrigger_2=1)
digest=source_hash(p);item['source_record_sha256']=digest
for r in item['components']:r['source_record_sha256']=digest
args[2]={600777,600778}
proof=m.on_use_namespace(Path('/home/praxis/Servers/tortoise-wow/src/game/Objects/ItemPrototype.h'),ROOT.parent/'servers/trinity-forever/src/server/game/Entities/Item/ItemTemplate.h')
return args,dict(on_use_context=proof)
def test_mixed_use_and_equip_keep_source_ids_signed_cooldowns_and_idempotence(self):
args,opts=self.inputs();before=copy.deepcopy(args);r=m.compose_passive_link_completion(*args,**opts)
self.assertEqual(args,before);self.assertFalse(r['blocked']);self.assertEqual(len(r['added']),4)
rows=[x['record']for x in r['added']if x['table_name']=='ItemEffect']
self.assertEqual([(x['SpellID'],x['LegacySlotIndex'],x['TriggerType'],x['CoolDownMSec'],x['CategoryCoolDownMSec'])for x in rows],[(600777,0,0,60000,-1),(600778,1,1,-1,-1)])
self.assertFalse(r['on_use_review']['gameplay_verified']);args[0]=r['package'];again=m.compose_passive_link_completion(*args,**opts)
self.assertEqual(again['added'],[]);self.assertEqual(again['preserved_item_ids'],[500777])
def test_default_or_missing_spell_review_does_not_admit_use(self):
args,opts=self.inputs();r=m.compose_passive_link_completion(*args);self.assertFalse(r['added']);self.assertTrue(r['blocked'])
args[2]={600778};r=m.compose_passive_link_completion(*args,**opts);self.assertFalse(r['added']);self.assertTrue(r['blocked'])
def test_consumables_charges_categories_ppm_scripts_and_bad_cooldowns_reject(self):
for changes in(dict(**{'class':0}),dict(spellcharges_1=1),dict(spellppmrate_1=1),dict(spellcategory_1=7),dict(script_name='custom'),dict(duration=1),dict(spellcooldown_1=True),dict(spellcooldown_1=86400001),dict(inventory_type=True)):
args,opts=self.inputs();p=dict(args[1][0]['source'],**changes)
with self.assertRaises(ValueError):m.generate([p],[],[],[dict(ID=i)for i in args[2]],dict(slots={}),args[5],args[6],source_authoritative_links=True,**opts)
def test_namespace_tampering_and_existing_native_link_replacement_reject(self):
args,opts=self.inputs();opts['on_use_context']['target_trigger']=1
with self.assertRaises(ValueError):m.compose_passive_link_completion(*args,**opts)
args,opts=self.inputs();r=m.compose_passive_link_completion(*args,**opts);e=next(x['record']for x in r['added']if x['table_name']=='ItemEffect')
with self.assertRaisesRegex(ValueError,'replacement'):
m.generate([args[1][0]['source']],[dict(ID=100,**e)],[dict(ID=200,ItemID=500777,ItemEffectID=100)],[dict(ID=i)for i in args[2]],dict(slots={}),args[5],args[6],source_authoritative_links=True,**opts)
if __name__=='__main__':unittest.main()