883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
121 lines
5.1 KiB
Python
121 lines
5.1 KiB
Python
from copy import deepcopy
|
|
import json
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
import spell_item_food_regen_compat as subject
|
|
from content_package_stage import compose_existing_proc_corrections
|
|
from item_sparse_compat import package_payloads
|
|
|
|
class FoodRegeneration(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.fixture = json.loads((Path(__file__).parent / 'fixtures/item-food-regeneration.json').read_text())
|
|
|
|
def setUp(self):
|
|
self.inputs = deepcopy(self.fixture)
|
|
self.source = self.inputs['sources'][0]
|
|
|
|
def component(self):
|
|
return subject.component(**self.inputs)
|
|
|
|
def row(self, table):
|
|
return next(r for r in self.inputs['native'][table]
|
|
if (r['ID'] if table in ('Spell', 'SpellName') else r['SpellID']) == self.source['entry'])
|
|
|
|
def test_whole14_positive_family_exact_source_corrections(self):
|
|
result = self.component()
|
|
self.assertEqual(len(result['spells']), 14)
|
|
self.assertEqual(len(result['records']), 25)
|
|
for r in result['records']:
|
|
source = next(s for s in self.inputs['sources'] if s['entry'] == r['source_spell_id'])
|
|
key, raw = {'SpellCooldowns': ('CategoryRecoveryTime', 'categoryRecoveryTime'),
|
|
'SpellCategories': ('Category', 'category'),
|
|
'SpellLevels': ('BaseLevel', 'baseLevel')}[r['table_name']]
|
|
self.assertEqual(r['record'][key], source[raw])
|
|
self.assertEqual(r['changed_fields'], [key])
|
|
self.assertEqual(r['baseline_record']['ID'], r['id'])
|
|
|
|
def test_extra_effect_after_good_first_is_not_ignored(self):
|
|
self.inputs['native']['SpellEffect'].append(dict(self.row('SpellEffect'), ID=2147483000, EffectIndex=1, EffectAura=42))
|
|
with self.assertRaisesRegex(ValueError, 'duplicate'):
|
|
self.component()
|
|
|
|
def test_native_nonexact_amount_cannot_be_corrected(self):
|
|
self.row('SpellEffect')['EffectBasePointsF'] += 1
|
|
with self.assertRaisesRegex(ValueError, 'native effect'):
|
|
self.component()
|
|
|
|
def test_source_zero_multiplier_held(self):
|
|
self.source['effectMultipleValue1'] = 0
|
|
with self.assertRaisesRegex(ValueError, 'multiplier'):
|
|
self.component()
|
|
|
|
def test_source_script_is_held(self):
|
|
self.source['script_name'] = 'special_food'
|
|
with self.assertRaises(ValueError):
|
|
self.component()
|
|
|
|
def test_source_added_second_effect_held(self):
|
|
self.source['effect2'] = 6
|
|
with self.assertRaises(ValueError):
|
|
self.component()
|
|
|
|
def test_native_cooldown_outside_reviewed_before_shapes_held(self):
|
|
self.row('SpellCooldowns')['CategoryRecoveryTime'] = 59999
|
|
with self.assertRaisesRegex(ValueError, 'cooldown'):
|
|
self.component()
|
|
|
|
def test_native_category_difference_is_held_not_corrected(self):
|
|
self.row('SpellCategories')['Category'] = 12
|
|
with self.assertRaisesRegex(ValueError, 'context differs'):
|
|
self.component()
|
|
|
|
def test_native_casting_recovery_not_erased(self):
|
|
self.row('SpellCooldowns')['RecoveryTime'] = 1000
|
|
with self.assertRaisesRegex(ValueError, 'context differs'):
|
|
self.component()
|
|
|
|
def test_native_conditional_visual_held(self):
|
|
self.row('SpellXSpellVisual')['ViewerUnitConditionID'] = 1
|
|
with self.assertRaisesRegex(ValueError, 'context differs'):
|
|
self.component()
|
|
|
|
def test_native_water_stand_flags_not_relaxed(self):
|
|
self.row('SpellInterrupts')['AuraInterruptFlags'][0] = 0
|
|
with self.assertRaisesRegex(ValueError, 'context differs'):
|
|
self.component()
|
|
|
|
def test_missing_parent_not_synthesized(self):
|
|
self.inputs['native']['SpellName'].remove(self.row('SpellName'))
|
|
with self.assertRaisesRegex(ValueError, 'Missing'):
|
|
self.component()
|
|
|
|
def test_permanent_or_scaled_duration_held(self):
|
|
key = str(self.source['durationIndex'])
|
|
self.inputs['durations'][key]['source_duration_per_level'] = 1
|
|
with self.assertRaisesRegex(ValueError, 'duration'):
|
|
self.component()
|
|
|
|
def test_source_nonfinite_metadata_is_held(self):
|
|
self.source['descriptionFlags'] = float('nan')
|
|
with self.assertRaisesRegex(ValueError, 'scalar'):
|
|
self.component()
|
|
|
|
def test_generic_composer_rebuilds_and_preserves_parent(self):
|
|
component = self.component()
|
|
rows = [deepcopy(component['records'][0])]
|
|
push, _ = package_payloads(rows)
|
|
base = dict(build=subject.codec.BUILD, schema=subject.codec.SCHEMA, id_remapping=False, rows=rows, push_id=push)
|
|
result = compose_existing_proc_corrections(base, component, self.inputs['schemas'])
|
|
self.assertEqual(result['added_count'], 24)
|
|
self.assertEqual(result['rows'][0], base['rows'][0])
|
|
self.assertEqual(len(base['rows']), 1)
|
|
forged = deepcopy(component)
|
|
forged['records'][0]['record']['CategoryRecoveryTime'] = 123
|
|
with self.assertRaisesRegex(ValueError, 'derivation'):
|
|
compose_existing_proc_corrections(base, forged, self.inputs['schemas'])
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|