883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
106 lines
5.6 KiB
Python
106 lines
5.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Genuine captured source/native sibling contracts; no installed data access."""
|
|
import copy
|
|
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 m
|
|
|
|
|
|
class ActiveWarriorRelationshipsTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.fixture = json.loads((Path(__file__).parent/'fixtures/warrior-active-relationships.json').read_text())
|
|
|
|
def case(self, sid=52315, cid=23925):
|
|
f=copy.deepcopy(self.fixture)
|
|
return [f['source'][str(sid)],f['source'][str(cid)],f['controls'][str(cid)],f['abilities'],
|
|
{t: 900000+i for i,t in enumerate(('SkillLineAbility','SpellClassOptions','SpellLevels','SpellEquippedItems','SpellXSpellVisual'))}]
|
|
|
|
def test_entire_five_rank_scope_and_production_hold(self):
|
|
counts=[]
|
|
for sid,cid in ((51600,12809),(51601,12809),(51602,12809),(52315,23925),(54023,12294)):
|
|
with self.subTest(spell=sid):
|
|
result=m.relationships(*self.case(sid,cid));counts.append(len(result['records']))
|
|
self.assertIs(result['complete_definition'],False)
|
|
self.assertIs(result['production_installable'],False)
|
|
self.assertIn('original-native-api-before-and-book-acceptance',result['held_dependencies'])
|
|
self.assertEqual(counts,[6,6,6,6,5])
|
|
|
|
def test_rank_chain_direction(self):
|
|
for sid,cid,previous in ((51600,12809,12809),(51601,12809,51600),(51602,12809,51601),(52315,23925,23925),(54023,12294,0)):
|
|
self.assertEqual(m.relationships(*self.case(sid,cid))['records']['SkillLineAbility']['SupercedesSpell'],previous)
|
|
|
|
def test_shield_exact_own_mask_and_equipment(self):
|
|
rows=m.relationships(*self.case())['records']
|
|
self.assertEqual(rows['SpellClassOptions']['SpellClassMask'],[0x02000000,1,0,0])
|
|
self.assertEqual(rows['SpellEquippedItems']['EquippedItemSubclass'],64)
|
|
self.assertEqual(rows['SpellLevels']['BaseLevel'],60)
|
|
self.assertEqual(rows['SpellXSpellVisual']['SpellVisualID'],42)
|
|
|
|
def test_master_zero_mask_and_unproven_visual_held(self):
|
|
result=m.relationships(*self.case(54023,12294))
|
|
self.assertEqual(result['records']['SpellClassOptions']['SpellClassMask'],[0]*4)
|
|
self.assertTrue(result['visual_held']);self.assertNotIn('SpellXSpellVisual',result['records'])
|
|
|
|
def test_named_flags_exchange_mainhand_and_always_hit(self):
|
|
source=self.case(54023,12294)[0]
|
|
actual=m.map_attributes(source)
|
|
self.assertEqual(actual['native_attributes'][3],0x40408)
|
|
source=dict(source,attributesEx3=0x400)
|
|
self.assertEqual(m.map_attributes(source)['native_attributes'][3],0x40000)
|
|
source['attributesEx3']=0x40000
|
|
self.assertEqual(m.map_attributes(source)['native_attributes'][3],0x400)
|
|
|
|
def test_flag_same_bit_different_meaning_stays_held(self):
|
|
con=m.map_attributes(self.case(51602,12809)[0])
|
|
self.assertEqual(con['held_source_bits'],[{'attribute_index':4,'bits':1}])
|
|
self.assertEqual(con['native_attributes'][4],0)
|
|
master=m.map_attributes(self.case(54023,12294)[0])
|
|
self.assertEqual(master['held_source_bits'],[{'attribute_index':1,'bits':0x04000000}])
|
|
self.assertFalse(master['native_attributes'][1]&0x04000000)
|
|
|
|
def test_control_class_mask_and_parent_drift_rejected(self):
|
|
for field,value in (('SpellClassMask',[1,0,0,0]),('SpellClassSet',3),('SpellID',123)):
|
|
args=self.case();args[2]['class'][field]=value
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
def test_source_sibling_mask_skill_equipment_drift_rejected(self):
|
|
for key,value in (('spellFamilyFlags',0),('equippedItemSubClassMask',0),('spellFamilyName',3)):
|
|
args=self.case();args[0][key]=value
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
args=self.case();next(r for r in args[3] if r[2]==52315)[1]=26
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
def test_extra_unknown_source_ability_fields_rejected(self):
|
|
for position in (5,6,9,10,11,12,13,14):
|
|
args=self.case();next(r for r in args[3] if r[2]==52315)[position]=1
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
def test_duplicate_ambiguous_and_cyclic_ranks_rejected(self):
|
|
args=self.case();args[3].append(copy.deepcopy(args[3][0]))
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
args=self.case();next(r for r in args[3] if r[2]==51602)[8]=51601
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
args=self.case();next(r for r in args[3] if r[2]==51602)[8]=12809
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
def test_visual_flags_conditions_and_identity_rejected(self):
|
|
for field,value in (('Probability',.5),('SpellVisualID',43),('CasterUnitConditionID',2),('Flags2',1)):
|
|
args=self.case();args[2]['visual'][field]=value
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
def test_bool_and_negative_integers_not_accepted(self):
|
|
for value in (True,-1,2**32):
|
|
args=self.case();args[4]['SpellLevels']=value
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
def test_native_extra_ability_fields_and_nonzero_constructor_rejected(self):
|
|
for field,value in (('NumSkillUps',2),('Flags',1),('Unreviewed',0)):
|
|
args=self.case();args[2]['ability'][field]=value
|
|
with self.assertRaises(ValueError):m.relationships(*args)
|
|
|
|
if __name__=='__main__':unittest.main()
|