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

60 lines
4.3 KiB
Python

"""Source/native constant Mana0 regeneration is an amount per five seconds."""
from copy import deepcopy
from pathlib import Path
import json,unittest
import spell_item_mana_regen_compat as m
import spell_item_static_compat as static
import spell_passive_compat as codec
ROOT=Path(__file__).resolve().parents[1]
class ManaRegeneration(unittest.TestCase):
def context(self):
f=json.loads((ROOT/'tests/fixtures/item-mana-regeneration.json').read_text());schemas={t:codec.fields(ROOT.parent/'tools/WoWDBDefs/definitions'/(t+'.dbd'),t)for t in ('SpellName','Spell','SpellMisc','SpellEffect','SpellLevels')}
return deepcopy(f['sources'][0]),f['native'],schemas,f['duration_reference']
def compose(self,src,native,schemas,duration):
return m.component([src],native,schemas,{t:1500000 for t in schemas},dict(schema_version=1,build=codec.BUILD,SpellEffect={}),semantics=m.contract(),duration_reference=duration)
def test_fixed_mana_per5_amount_preserved_without_scaling(self):
src,native,schemas,duration=self.context();src['effects'][0][2]+=3
c=self.compose(src,native,schemas,duration);e=next(r for r in c['records']if r['table_name']=='SpellEffect')
self.assertEqual((e['record']['EffectAura'],e['record']['EffectMiscValue']),(85,[0,0]));self.assertEqual(e['record']['EffectBasePointsF'],src['effects'][0][2]+1)
self.assertEqual(bytes.fromhex(e['wire_hex']),codec.encode(e['record'],schemas['SpellEffect']))
self.assertEqual(c['spells'][0]['effects'][0]['target_aura'],85)
def test_native_additional_attribute_flag_is_not_cleared(self):
src,native,schemas,duration=self.context()
next(r for r in native['SpellMisc']if r['SpellID']==src['entry'])['Attributes'][1]=1024
with self.assertRaisesRegex(ValueError,'attributes differ'):self.compose(src,native,schemas,duration)
def test_nonmana_or_boolean_power_is_held(self):
for power in (1,3,4,False):
with self.subTest(power=power):
src,_,_,_=self.context();src['effects'][0][7]=power
with self.assertRaises(ValueError):m.validate_source(src,m.contract())
def test_native_mismatched_power_is_held(self):
src,native,schemas,duration=self.context();next(r for r in native['SpellEffect']if r['SpellID']==src['entry'])['EffectMiscValue']=[1,0]
with self.assertRaises(ValueError):self.compose(src,native,schemas,duration)
def test_school_index_is_not_copied_as_native_mask(self):
src,native,schemas,duration=self.context();self.assertEqual(src['school'],6)
self.assertEqual(next(r for r in native['SpellMisc']if r['SpellID']==src['entry'])['SchoolMask'],64)
next(r for r in native['SpellMisc']if r['SpellID']==src['entry'])['SchoolMask']=6
with self.assertRaises(ValueError):self.compose(src,native,schemas,duration)
def test_hidden_passive_no_log_flags_are_exact(self):
src,_,_,_=self.context();self.assertEqual(src['attributes'],[448,0,0,0,0]);src['attributes'][0]=192
with self.assertRaises(ValueError):m.validate_source(src,m.contract())
def test_temporary_regeneration_is_not_this_policy(self):
src,_,_,_=self.context();src['durationIndex']=1
with self.assertRaises(ValueError):m.validate_source(src,m.contract())
def test_generic_static_policy_keeps85_held(self):
src,_,_,_=self.context()
with self.assertRaises(ValueError):static.validate_source(src)
def test_named_policies_are_mutually_exclusive(self):
src,_,_,_=self.context()
with self.assertRaises(ValueError):static.validate_source(src,mana_regen=True,spell_bonus=True)
def test_missing_positive_parent_is_not_created(self):
src,native,schemas,duration=self.context();src['entry']=900001
with self.assertRaises(ValueError):self.compose(src,native,schemas,duration)
def test_extra_aura_family_is_held(self):
src,_,_,_=self.context();src['effects'][1]=deepcopy(src['effects'][0]);src['effects'][1][1]=135
with self.assertRaises(ValueError):m.validate_source(src,m.contract())
def test_wrong_unit_contract_is_held(self):
src,_,_,_=self.context();proof=m.contract();proof['units']='mana-per-second'
with self.assertRaises(ValueError):m.validate_source(src,proof)
if __name__=='__main__':unittest.main()