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

135 lines
9.2 KiB
Python

#!/usr/bin/env python3
"""Actual Concussion rank-family composition and refusal boundary; no client use."""
import copy
import hashlib
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
import spell_active_warrior_compat as active
import spell_shield_slam_compat as shield
import spell_passive_compat as typed
import active_warrior_package_stage as stage
import content_package_stage as generic
JOB=Path('runtime/continuation-20261025/concussion-rank-family')
class ConcussionDefinitionTest(unittest.TestCase):
def test_actual_three_rank_package_and_refusals(self):
inputs=JOB/'actual-rank-family-inputs.json'
if not inputs.exists():
self.skipTest('Owning frozen actual83982 input package is not available')
fixture=json.loads(inputs.read_text())
package=json.loads(Path(fixture['base_package']).read_text())
candidates=fixture['components'];schemas=fixture['schemas']
metadata=typed.TABLES|typed.SUPPLEMENTAL_TABLES|shield.EXTRA_TABLES
for component in candidates:
source=component['source_definition'];contract=component['contract']
rebuilt=active.concussion_records(source,contract)
rows=[]
for table,record in list(rebuilt['records'].items())+[
('SpellEffect',rebuilt['effects'][i])for i in (0,1,2)]:
wire=typed.encode(record,schemas[table])
rows.append(dict(table_name=table,table_hash=f'0x{metadata[table][0]:08x}',
id=record['ID'],record=record,wire_hex=wire.hex(),
sha256=hashlib.sha256(wire).hexdigest()))
component['rows']=rows
result=generic.compose_definition_candidates(package,candidates,schemas,{})
self.assertEqual(result['added_count'],43)
self.assertEqual(len(result['rows']),84025)
self.assertEqual(result['rows'][:len(package['rows'])],package['rows'])
self.assertEqual(result['pending_original_api_absence'],[51600,51601,51602])
self.assertTrue(result['original_base_12809_unchanged'])
for key in ('installed','installable','engine_accepted','gameplay_verified','native_tooltip_accepted'):
self.assertIs(result[key],False)
self.assertEqual(result['pushes'],generic.package_pages(result['rows']))
identity=[(r['table_hash'],r['id'])for r in result['rows']]
self.assertEqual(len(identity),len(set(identity)))
addition=result['rows'][len(package['rows']):]
category=[r['record']for r in addition if r['table_name']=='SpellCategory']
self.assertEqual(len(category),1)
self.assertEqual(category[0]['ID'],2596)
for sid,damage,previous in ((51600,150,12809),(51601,190,51600),(51602,235,51601)):
selected=[r for r in addition if r['table_name']!='SpellCategory' and
r['record'].get('SpellID',r['record'].get('Spell',r['record']['ID']))==sid]
self.assertEqual(len(selected),14)
by={r['table_name']:r['record']for r in selected if r['table_name']!='SpellEffect'}
effects={r['record']['EffectIndex']:r['record']for r in selected if r['table_name']=='SpellEffect'}
self.assertEqual(by['SkillLineAbility']['SupercedesSpell'],previous)
self.assertEqual(by['SpellCategories']['Category'],2596)
self.assertEqual(by['SpellCategories']['StartRecoveryCategory'],133)
self.assertEqual(by['SpellCooldowns']['CategoryRecoveryTime'],20000)
self.assertEqual(by['SpellCooldowns']['StartRecoveryTime'],1500)
self.assertEqual((by['SpellPower']['PowerType'],by['SpellPower']['ManaCost']),(0,0))
self.assertEqual(by['SpellMisc']['Attributes'][3],0x40000)
self.assertEqual(by['SpellMisc']['Attributes'][4],0)
self.assertEqual(by['SpellMisc']['DurationIndex'],27)
self.assertEqual((effects[0]['Effect'],effects[0]['EffectAura'],effects[0]['EffectMechanic'],effects[0]['ImplicitTarget']),(6,12,12,[6,0]))
self.assertEqual((effects[1]['Effect'],effects[1]['ImplicitTarget'],effects[1]['EffectBasePointsF']),(2,[6,0],damage))
self.assertEqual(effects[1]['EffectBonusCoefficient'],1353/3500)
self.assertEqual(effects[1]['BonusCoefficientFromAP'],0)
self.assertEqual((effects[2]['Effect'],effects[2]['EffectMiscValue'],effects[2]['ImplicitTarget'],effects[2]['EffectBasePointsF']),(30,[1,0],[1,0],100))
refusals=[]
def refuse(label,call):
with self.subTest(label=label):
with self.assertRaises((ValueError,TypeError)):
call()
refusals.append(label)
original=candidates[0]
for key,value,label in (
('attributesEx4',2,'unreviewed Source resistance bit'),
('customFlags',0x800000,'unreviewed total AP substitution'),
('effectBonusCoefficient2',0.2,'explicit AP coefficient replaces default sentinel'),
('effectImplicitTargetA3',6,'Rage incorrectly targets enemy'),
('effectMechanic1',0,'stun mechanic lost'),
('effectTriggerSpell2',123,'unreviewed trigger edge'),
('durationIndex',28,'original five-second stun cloned'),
('entry',12809,'existing original parent must remain unchanged'),
('manaCost',100,'original cost cloned'),
('effectBasePoints2',100,'unreviewed source rank operand')):
bad=copy.deepcopy(original);bad['source_definition'][key]=value
refuse(label,lambda b=bad:active.concussion_records(b['source_definition'],b['contract']))
for key,value,label in (
('ID',1167,'foreign numeric category copied'),
('ID',38,'original category namespace collision'),
('MaxCharges',1,'unreviewed charge feature'),
('TypeMask',1,'unreviewed category type feature')):
bad=copy.deepcopy(original['contract']['shared_category']);bad['record'][key]=value
refuse(label,lambda b=bad:active.concussion_category(b))
bad=copy.deepcopy(original['contract']['shared_category']);bad['native_max_id']=1
refuse('false original category namespace',lambda:active.concussion_category(bad))
for key,label in (('stun_effect','changed original stun default'),('rage_effect','changed original Rage default')):
bad=copy.deepcopy(original);bad['contract']['controls'][key]['EffectAttributes']=1
refuse(label,lambda b=bad:active.concussion_records(b['source_definition'],b['contract']))
bad=copy.deepcopy(original);bad['contract']['controls']['misc']['Attributes'][3]=0x40000
refuse('unreviewed original native flag/default',lambda:active.concussion_records(bad['source_definition'],bad['contract']))
bad=copy.deepcopy(candidates);bad[1]['contract']['shared_category']['record']['ID']=2597
refuse('rank category split',lambda:generic.compose_definition_candidates(package,bad,schemas,{}))
refuse('incomplete three-rank family',lambda:generic.compose_definition_candidates(package,candidates[:2],schemas,{}))
bad=copy.deepcopy(candidates);bad[0]['native_reference']['SpellName']['parent_rows']=[{'ID':51600}]
refuse('existing original parent cannot be overwritten',lambda:generic.compose_definition_candidates(package,bad,schemas,{}))
badschemas=copy.deepcopy(schemas);badschemas['SpellCategory'][1][2]=16
refuse('wrong category schema',lambda:generic.compose_definition_candidates(package,candidates,badschemas,{}))
bad=copy.deepcopy(original);row=next(r for r in bad['rows']if r['table_name']=='SpellMisc');row['record']['Attributes'][3]=0x400
refuse('main-hand alias in native candidate',lambda:active.review_concussion_record(bad['source_definition'],bad['contract'],row))
refuse('positive original API may not be called absent',lambda:generic.compose_definition_candidates(package,candidates,schemas,{'51600':{'infoStatus':'ok','nameStatus':'ok','descriptionStatus':'ok'}}))
output=JOB/'stage';output.mkdir(exist_ok=True)
staged=dict(package);staged.update(rows=result['rows'],push_id=result['push_id'],pushes=result['pushes'])
staged.update(kind='source-concussion-definition-only-private-package',engine_accepted=False,installed=False,gameplay_verified=False,
source_rank_ids=[51600,51601,51602],original_12809_unchanged=True)
(output/'package-compact.json').write_text(json.dumps(staged,separators=(',',':'))+'\n')
(output/'item_sparse_compat.hpp').write_text(result['header'])
(output/'components.json').write_text(json.dumps(candidates,indent=2)+'\n')
proof=dict(status='PASS_ACTUAL83982_PREFIX_THREE_CONCUSSION_RANKS_PLUS_OWNED_CATEGORY',base_count=len(package['rows']),
final_count=len(result['rows']),added_rows=43,new_ranks=3,enabled_effect_slots=9,
whole_Source_family_reviewed=4,original12809_unchanged=True,shared_category_id=2596,
refusal_count=len(refusals),refusals=refusals,old_prefix_exact=True,unique_native_identities=True,
pages_exact=True,native_combat_parity_claimed=False,actual_native_acceptance=False)
(JOB/'focused-validation.json').write_text(json.dumps(proof,indent=2)+'\n')
if __name__=='__main__':
unittest.main()