|
5 | 5 |
|
6 | 6 | API_BASE = f"http://localhost:8000" |
7 | 7 |
|
| 8 | + |
| 9 | +class TestSpellCastingOptions: |
| 10 | + """Tests to validate spell casting options data integrity.""" |
| 11 | + |
| 12 | + def test_all_spells_with_higher_level_have_casting_options(self): |
| 13 | + """Every spell with higher_level text should have at least one casting option.""" |
| 14 | + response = requests.get( |
| 15 | + f"{API_BASE}/v2/spells/?limit=1000", |
| 16 | + headers={'Accept': 'application/json'} |
| 17 | + ).json() |
| 18 | + |
| 19 | + spells_missing_options = [] |
| 20 | + for spell in response['results']: |
| 21 | + if spell.get('higher_level') and not spell.get('casting_options'): |
| 22 | + spells_missing_options.append(spell['key']) |
| 23 | + |
| 24 | + assert not spells_missing_options, \ |
| 25 | + f"Spells with higher_level but no casting_options: {spells_missing_options}" |
| 26 | + |
| 27 | + def test_no_duplicate_casting_option_types(self): |
| 28 | + """No spell should have duplicate casting option types.""" |
| 29 | + response = requests.get( |
| 30 | + f"{API_BASE}/v2/spells/?limit=1000", |
| 31 | + headers={'Accept': 'application/json'} |
| 32 | + ).json() |
| 33 | + |
| 34 | + spells_with_duplicates = [] |
| 35 | + for spell in response['results']: |
| 36 | + casting_options = spell.get('casting_options', []) |
| 37 | + types = [opt['type'] for opt in casting_options] |
| 38 | + if len(types) != len(set(types)): |
| 39 | + duplicates = [t for t in types if types.count(t) > 1] |
| 40 | + spells_with_duplicates.append(f"{spell['name']}: {set(duplicates)}") |
| 41 | + |
| 42 | + assert not spells_with_duplicates, \ |
| 43 | + f"Spells with duplicate casting option types: {spells_with_duplicates}" |
| 44 | + |
| 45 | + |
8 | 46 | class TestObjects: |
9 | 47 |
|
10 | 48 | def _verify(self, endpoint: str, transformer: Callable[[dict], None] = None): |
|
0 commit comments