Skip to content

Commit 9f72ca1

Browse files
committed
test: add validation for CSV Encounter data for LGPE
1 parent 9f9c746 commit 9f72ca1

3 files changed

Lines changed: 61 additions & 62 deletions

File tree

tests/csv_validation/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_encounters_for_version_group(
7777
@pytest.fixture(
7878
scope="session",
7979
params=list(GAME_CONFIGS.values()),
80-
ids=list(GAME_CONFIGS.keys()),
80+
ids=[c.name for c in GAME_CONFIGS.values()],
8181
)
8282
def game_config(request) -> GameConfig:
8383
"""Parametrized fixture that yields each game config once per session."""

tests/csv_validation/game_config.py

Lines changed: 60 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,82 +19,97 @@
1919
class GameConfig:
2020
"""Configuration for validating a specific game's encounter data."""
2121

22-
game_id: str
22+
version_group_id: int
2323
name: str
24-
version_ids: list[int] # PokeAPI version IDs
25-
version_group_id: int # PokeAPI version group ID
24+
version_ids: list[int]
2625
valid_pokemon: set[int]
2726
valid_method_ids: set[int]
2827
version_exclusives: dict[int, int] = field(
2928
default_factory=dict
3029
) # pokemon_id -> version_id
31-
level_bounds: tuple[int, int] = (1, 100)
3230

3331

3432
# =============================================================================
3533
# LGPE Configuration
3634
# =============================================================================
3735

38-
LGPE_POKEMON = set(range(1, 152)) | {808, 809}
39-
36+
# PokeAPI IDs
4037
LGPE_VERSION_PIKACHU = 31
4138
LGPE_VERSION_EEVEE = 32
4239
LGPE_VERSION_GROUP = 19
4340

44-
LGPE_METHOD_IDS = {38, 39, 40, 41}
41+
# Pokemon available in LGPE (Kanto dex + Meltan/Melmetal)
42+
LGPE_POKEMON = set(range(1, 152)) | {808, 809}
43+
44+
# Encounter method IDs
45+
LGPE_METHOD_OVERWORLD = 38
46+
LGPE_METHOD_OVERWORLD_WATER = 39
47+
LGPE_METHOD_OVERWORLD_FLYING = 40
48+
LGPE_METHOD_RARE_SPAWN = 41
49+
50+
LGPE_METHOD_IDS = {
51+
LGPE_METHOD_OVERWORLD,
52+
LGPE_METHOD_OVERWORLD_WATER,
53+
LGPE_METHOD_OVERWORLD_FLYING,
54+
LGPE_METHOD_RARE_SPAWN,
55+
}
4556

4657
LGPE_VERSION_EXCLUSIVES = {
47-
# Pikachu exclusives (version_id = 31)
48-
27: 31,
49-
28: 31, # Sandshrew, Sandslash
50-
43: 31,
51-
44: 31,
52-
45: 31, # Oddish line
53-
56: 31,
54-
57: 31, # Mankey, Primeape
55-
58: 31,
56-
59: 31, # Growlithe, Arcanine
57-
88: 31,
58-
89: 31, # Grimer, Muk
59-
123: 31, # Scyther
60-
# Eevee exclusives (version_id = 32)
61-
23: 32,
62-
24: 32, # Ekans, Arbok
63-
37: 32,
64-
38: 32, # Vulpix, Ninetales
65-
52: 32,
66-
53: 32, # Meowth, Persian
67-
69: 32,
68-
70: 32,
69-
71: 32, # Bellsprout line
70-
109: 32,
71-
110: 32, # Koffing, Weezing
72-
127: 32, # Pinsir
58+
# Pikachu exclusives
59+
# Sandshrew, Sandslash
60+
27: LGPE_VERSION_PIKACHU,
61+
28: LGPE_VERSION_PIKACHU,
62+
# Oddish, Gloom, Vileplume
63+
43: LGPE_VERSION_PIKACHU,
64+
44: LGPE_VERSION_PIKACHU,
65+
45: LGPE_VERSION_PIKACHU,
66+
# Mankey, Primeape
67+
56: LGPE_VERSION_PIKACHU,
68+
57: LGPE_VERSION_PIKACHU,
69+
# Growlithe, Arcanine
70+
58: LGPE_VERSION_PIKACHU,
71+
59: LGPE_VERSION_PIKACHU,
72+
# Grimer, Muk
73+
88: LGPE_VERSION_PIKACHU,
74+
89: LGPE_VERSION_PIKACHU,
75+
# Scyther
76+
123: LGPE_VERSION_PIKACHU,
77+
78+
# Eevee exclusives
79+
# Ekans, Arbok
80+
23: LGPE_VERSION_EEVEE,
81+
24: LGPE_VERSION_EEVEE,
82+
# Vulpix, Ninetales
83+
37: LGPE_VERSION_EEVEE,
84+
38: LGPE_VERSION_EEVEE,
85+
# Meowth, Persian
86+
52: LGPE_VERSION_EEVEE,
87+
53: LGPE_VERSION_EEVEE,
88+
# Bellsprout, Weepinbell, Victreebel
89+
69: LGPE_VERSION_EEVEE,
90+
70: LGPE_VERSION_EEVEE,
91+
71: LGPE_VERSION_EEVEE,
92+
# Koffing, Weezing
93+
109: LGPE_VERSION_EEVEE,
94+
110: LGPE_VERSION_EEVEE,
95+
# Pinsir
96+
127: LGPE_VERSION_EEVEE,
7397
}
7498

7599
LGPE_CONFIG = GameConfig(
76-
game_id="lgpe",
100+
version_group_id=LGPE_VERSION_GROUP,
77101
name="Let's Go Pikachu/Eevee",
78102
version_ids=[LGPE_VERSION_PIKACHU, LGPE_VERSION_EEVEE],
79-
version_group_id=LGPE_VERSION_GROUP,
80103
valid_pokemon=LGPE_POKEMON,
81104
valid_method_ids=LGPE_METHOD_IDS,
82105
version_exclusives=LGPE_VERSION_EXCLUSIVES,
83-
level_bounds=(1, 100),
84106
)
85107

86108

87109
# =============================================================================
88110
# Game Registry
89111
# =============================================================================
90112

91-
GAME_CONFIGS: dict[str, GameConfig] = {
92-
"lgpe": LGPE_CONFIG,
113+
GAME_CONFIGS: dict[int, GameConfig] = {
114+
LGPE_VERSION_GROUP: LGPE_CONFIG,
93115
}
94-
95-
96-
def get_game_config(game_id: str) -> GameConfig:
97-
if game_id not in GAME_CONFIGS:
98-
available = ", ".join(GAME_CONFIGS.keys())
99-
raise ValueError(f"Unknown game '{game_id}'. Available: {available}")
100-
return GAME_CONFIGS[game_id]

tests/csv_validation/test_csv_encounters.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
Validation criteria (from encounter-collection README):
88
- All Pokemon IDs are valid for the game
99
- Encounter method IDs are valid for the game's version group
10-
- Level ranges are within valid bounds
1110
- Version exclusives only appear with correct version_id
1211
- No duplicate encounter entries
1312
- Foreign key references are valid (slots, location_areas exist)
@@ -125,21 +124,6 @@ def test_method_ids_valid_for_game(
125124
f"Valid: {game_config.valid_method_ids}"
126125
)
127126

128-
def test_levels_within_bounds(
129-
self, game_config: GameConfig, game_encounters
130-
):
131-
lo, hi = game_config.level_bounds
132-
invalid = []
133-
for e in game_encounters:
134-
min_l, max_l = parse_int(e["min_level"]), parse_int(e["max_level"])
135-
if not (lo <= min_l <= hi):
136-
invalid.append(f"id={e['id']} min_level={min_l}")
137-
if not (lo <= max_l <= hi):
138-
invalid.append(f"id={e['id']} max_level={max_l}")
139-
assert not invalid, (
140-
f"Levels outside [{lo}, {hi}]:\n" + "\n".join(invalid[:10])
141-
)
142-
143127
def test_min_level_not_greater_than_max(
144128
self, game_config: GameConfig, game_encounters
145129
):

0 commit comments

Comments
 (0)