883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
40 lines
2.7 KiB
Python
40 lines
2.7 KiB
Python
"""Batch relationship curation preserves source spells and unrelated professions."""
|
|
import copy,json,struct,sys,tempfile,unittest
|
|
from pathlib import Path
|
|
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'ops'))
|
|
from turtle_data import DBC
|
|
from spell_passive_compat import fields,source_profession_link_removals
|
|
from item_sparse_compat import package_payloads
|
|
DBD=ROOT.parent/'tools/WoWDBDefs/definitions';SCHEMA=fields(DBD/'SkillLineAbility.dbd','SkillLineAbility')
|
|
SPELLS=DBC(ROOT/'tests/fixtures/item-text-source.dbc',173)
|
|
class Tests(unittest.TestCase):
|
|
def fixture(self,path):
|
|
rows=[]
|
|
for ident,spell in [(1,7518),(2,22725)]:
|
|
r=[0]*15;r[:3]=[ident,164,spell];rows.append(r)
|
|
path.write_bytes(struct.pack('<4s4I',b'WDBC',2,15,60,1)+struct.pack('<30I',*(rows[0]+rows[1]))+b'\0')
|
|
base={name:([0]*n if n>1 else ''if kind in('string','locstring')else 0)for name,kind,bits,unsigned,n in SCHEMA}
|
|
native=[dict(base,ID=100,SkillLine=164,Spell=7518),dict(base,ID=101,SkillLine=164,Spell=999777),dict(base,ID=102,SkillLine=165,Spell=999777),dict(base,ID=103,SkillLine=164,Spell=15494)]
|
|
return DBC(path,15),native
|
|
def test_only_source_absent_relationship_removed(self):
|
|
with tempfile.TemporaryDirectory()as d:
|
|
abilities,native=self.fixture(Path(d)/'SkillLineAbility.dbc');before=copy.deepcopy(native)
|
|
r=source_profession_link_removals(abilities,SPELLS,native,[],[164],SCHEMA)
|
|
self.assertEqual(native,before);self.assertEqual([v['id']for v in r['rows']],[101]);self.assertEqual([v['spell']for v in r['deferred']],[22725]);self.assertFalse(r['gameplay_verified'])
|
|
package_payloads(r['rows'])
|
|
again=source_profession_link_removals(abilities,SPELLS,native,r['rows'],[164],SCHEMA)
|
|
self.assertFalse(again['rows'])
|
|
wrong=copy.deepcopy(r['rows']);wrong[0]['baseline_record']['SkillLine']=165
|
|
with self.assertRaises(ValueError):package_payloads(wrong)
|
|
def test_missing_source_profession_coverage_rejected(self):
|
|
with tempfile.TemporaryDirectory()as d:
|
|
abilities,native=self.fixture(Path(d)/'SkillLineAbility.dbc')
|
|
with self.assertRaises(ValueError):source_profession_link_removals(abilities,SPELLS,native,[],[333],SCHEMA)
|
|
def test_effective_source_positive_overlay_is_preserved(self):
|
|
with tempfile.TemporaryDirectory()as d:
|
|
abilities,native=self.fixture(Path(d)/'SkillLineAbility.dbc');overlay=dict(table_name='SkillLineAbility',id=101,record=dict(native[1],Spell=7518))
|
|
self.assertFalse(source_profession_link_removals(abilities,SPELLS,native,[overlay],[164],SCHEMA)['rows'])
|
|
overlay['record']['Spell']=999777
|
|
self.assertFalse(source_profession_link_removals(abilities,SPELLS,native,[overlay],[164],SCHEMA)['rows'])
|
|
if __name__=='__main__':unittest.main()
|