Skip to content

Commit

Permalink
Add Showdown pokedex tests
Browse files Browse the repository at this point in the history
Half are failing right now, as ShowdownReader is not yet completed. But
this is intentional - these tests should speed up development
significantly as we start covering edge cases
  • Loading branch information
mirekdlugosz committed Oct 18, 2019
1 parent 88e4b59 commit 0e218e8
Show file tree
Hide file tree
Showing 2 changed files with 237 additions and 67 deletions.
3 changes: 1 addition & 2 deletions data-manager/tests/test_eevee_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ def test_natural_gift_expansion(filled_eeveedex, game, has_fairy):
moves = filled_eeveedex['learnsets'][game]['lugia']
assert all(gift in moves for gift in natural_gifts)

if not has_fairy:
assert "natural-gift-fairy" not in moves
assert ("natural-gift-fairy" in moves) == has_fairy


def test_hidden_power_expansion(filled_eeveedex):
Expand Down
301 changes: 236 additions & 65 deletions data-manager/tests/test_showdown_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,8 @@
import pytest

from pokedexreader.storage import PokedexStorage

"""
to check:
- pokemon
- ignored ones are not present
- special ones are present (forms differing in some significant property)
- order inside pokedex
- name (Arceus, pokemon with different forms)
- presence in special game-pokemon configurations (deoxys in gen 3, mega in gen 6)
- type before it changed (e.g. Jigglypuff prior to gen 6)
- moves
- smeargle
- pokemon that can change form any time with form-exclusive move (for all form-exclusive moves, verify every form has it)
- move that can be learned by prevolution only
- mega evolution (can it learn everything that prior evolution could)
- tutor - properly recognize only last game in generation has it
- tutor - exception - first game in generation (starter moves)
- tutor - exception - two games in generation (gen III and IV only)
- natural gift expansion
- hidden power expansion
- every move that changes type depending on Pokemon type
- type before it changed (e.g. Bite in gen I?)
"""
from pokedexreader.constants import Constants
from pokedexreader.constants_pokedex import ORAS_MEGAS, XY_MEGAS


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -65,72 +44,264 @@ def filled_showdowndex(showdown):


def test_pokemon_with_many_forms(filled_showdowndex):
pass
expected = {'diamond-pearl': ["deoxys", "deoxysattack", "deoxysdefense", "deoxysspeed",
"wormadam", "wormadamsandy", "wormadamtrash", "giratina",
"shaymin", "arceus", "arceusbug", "arceusdark", "arceusdragon",
"arceuselectric", "arceusfighting", "arceusfire",
"arceusflying", "arceusghost", "arceusgrass", "arceusground",
"arceusice", "arceuspoison", "arceuspsychic", "arceusrock",
"arceussteel", "arceuswater"],
'platinum': ["giratina", "giratinaorigin", "shaymin", "shayminsky"],
'black-white': ["kyurem", "meloetta", "meloettapirouette", "genesect",
"genesectdouse", "genesectshock", "genesectburn", "genesectchill"],
'black-2-white-2': ["kyurem", "kyuremblack", "kyuremwhite"],
'x-y': ["arceusfairy", "hoopa", "meowstic", "meowsticf"],
'omega-ruby-alpha-sapphire': ["hoopa", "hoopaunbound"],
'sun-moon': ["oricorio", "oricoriopompom", "oricoriopau", "oricoriosensu",
"lycanroc", "lycanrocmidnight", "silvally", "silvallybug",
"silvallydark", "silvallydragon", "silvallyelectric", "silvallyfairy",
"silvallyfighting", "silvallyfire", "silvallyflying", "silvallyghost",
"silvallygrass", "silvallyground", "silvallyice", "silvallypoison",
"silvallypsychic", "silvallyrock", "silvallysteel", "silvallywater",
"necrozma"],
'ultra-sun-ultra-moon': ["lycanrocdusk", "necrozmaduskmane", "necrozmadawnwings",
"necrozmaultra"]
}
for game, pokemon_list in expected.items():
all_pokemon = [item['id'] for item in filled_showdowndex['pokemon'][game]]
assert all_pokemon
for pokemon in pokemon_list:
assert pokemon in all_pokemon
assert all(pokemon in all_pokemon for pokemon in pokemon_list)


def test_ignored_pokemon_is_not_present(filled_showdowndex):
pass
ignored_pokemon_list = ['pichu-spiky-eared', 'pikachu-rock-star', 'marowak-totem',
'castform-sunny', 'burmy-sandy', 'mothim-plant', 'cherrim-sunshine',
'shellos-west', 'gastrodon-east', 'arceus-unknown',
'basculin-red-striped', 'darmanitan', 'deerling-summer',
'sawsbuck-autumn', 'tornadus-incarnate', 'thundurus-therian',
'keldeo-ordinary', 'keldeo-resolute', 'greninja-battle-bond',
'greninja-ash', 'scatterbug-river', 'spewpa-polar', 'vivillon-fancy'
'flabebe-red', 'floette-yellow', 'floette-eternal', 'florges-blue',
'furfrou-star', 'aegislash-shield', 'aegislash-blade',
'pumpkaboo-small', 'gourgeist-large', 'xerneas-active', 'zygarde-10',
'zygarde-complete', 'minior-indigo-meteor', 'minior-meteor',
'minior-blue', 'mimikyu-busted', 'magearna-original']

for game in filled_showdowndex['pokemon']:
pokemon_list = [item['id'] for item in filled_showdowndex['pokemon'][game]]
assert pokemon_list
for ignored in ignored_pokemon_list:
assert ignored not in pokemon_list


def test_order_in_pokedex(filled_showdowndex):
pass
game = 'ultra-sun-ultra-moon'
pokemon_list = [item['id'] for item in filled_showdowndex['pokemon'][game]]
assert pokemon_list.index('bulbasaur') == 0
assert pokemon_list.index('bulbasaur') < pokemon_list.index('abra')
assert pokemon_list.index('charmander') < pokemon_list.index('charmeleon')
assert pokemon_list.index('venusaur') < pokemon_list.index('venusaurmega')
assert pokemon_list.index('igglybuff') < pokemon_list.index('jigglypuff')
assert pokemon_list.index('rhyhorn') < pokemon_list.index('rhyperior')
assert pokemon_list.index('pikachu') < pokemon_list.index('raichualola')
assert pokemon_list.index('vulpixalola') < pokemon_list.index('ninetalesalola')


def test_arceus_name(filled_showdowndex):
pass
game = 'ultra-sun-ultra-moon'
pokemon = next(item for item in filled_showdowndex['pokemon'][game]
if item['id'] == 'arceus')
assert pokemon['name'] == 'Arceus (Normal Type)'


def test_deoxys_in_gen_3(filled_showdowndex):
pass
@pytest.mark.parametrize("game,expected", [
("ruby-sapphire", ["deoxys"]),
("emerald", ["deoxysspeed"]),
("firered-leafgreen", ["deoxysattack", "deoxysdefense"]),
("x-y", ["deoxys", "deoxysattack", "deoxysdefense", "deoxysspeed"])
])
def test_deoxys_in_gen_3(filled_showdowndex, game, expected):
pokemon_list = [item['id'] for item in filled_showdowndex['pokemon'][game]
if 'deoxys' in item['id']]
assert pokemon_list == expected


def test_mega_in_gen_6(filled_showdowndex):
pass


def test_pokemon_fairy_type_before_gen_6(filled_showdowndex):
pass
fake_mega = ['yanmega', 'meganium']
pokemon = filled_showdowndex['pokemon']
xy_mega_list = [item['id'] for item in pokemon['x-y']
if 'mega' in item['id'] and item['id'] not in fake_mega]
oras_mega_list = [item['id'] for item in pokemon['omega-ruby-alpha-sapphire']
if 'mega' in item['id'] and item['id'] not in fake_mega]
assert set(xy_mega_list) == set(XY_MEGAS)
for oras_mega in set(ORAS_MEGAS) - set(XY_MEGAS):
assert oras_mega not in xy_mega_list
assert set(oras_mega_list) == set(ORAS_MEGAS)


@pytest.mark.parametrize("pokemon,last_game,type_,new_type", [
("azumarill", "black-2-white-2", ["Water"], ["Water", "Fairy"]),
("azurill", "black-2-white-2", ["Normal"], ["Normal", "Fairy"]),
("rotomheat", "heartgold-soulsilver", ["Electric", "Ghost"], ["Electric", "Fire"]),
("togekiss", "black-2-white-2", ["Normal", "Flying"], ["Fairy", "Flying"]),
("jigglypuff", "black-2-white-2", ["Normal"], ["Normal", "Fairy"])
])
def test_pokemon_type_before_change(filled_showdowndex, pokemon, last_game, type_, new_type):
versions = Constants.known_versions
for game in versions[:versions.index(last_game) + 1]:
pokemon_obj = next((item for item in filled_showdowndex['pokemon'][game]
if pokemon in item['id']), None)
if not pokemon_obj:
continue
assert pokemon_obj['type'] == type_

game = versions[versions.index(last_game) + 1]
pokemon_obj = next((item for item in filled_showdowndex['pokemon'][game]
if pokemon in item['id']), None)
assert pokemon_obj['type'] == new_type


def test_smeargle_moves(filled_showdowndex):
pass


def test_changeable_form_moves(filled_showdowndex):
pass


def test_prevolution_exclusive_moves(filled_showdowndex):
pass

for learnset in filled_showdowndex['learnsets'].values():
try:
smeargle_moves = learnset['smeargle']
except KeyError:
continue
# there were 250 moves in gen II, when Smeargle was introduced
assert len(smeargle_moves) > 250
for move in Constants.invalid_smeargle_moves:
assert move not in smeargle_moves


@pytest.mark.parametrize("pokemon_list,moves", [
(["deoxys", "deoxysattack", "deoxysdefense", "deoxysspeed"],
["superpower", "zapcannon", "amnesia", "counter", "irondefense", "mirrorcoat",
"spikes", "agility", "extremespeed", "swift"]),
(["giratina", "giratinaorigin"], ["painsplit", "magiccoat", "tailwind"]),
(["shaymin", "shayminsky"], ["aromatherapy", "healingwish", "synthesis",
"airslash", "leafstorm", "quickattack"]),
(["hoopa", "hoopaunbound"], ["hyperspacefury", "knockoff", "hyperspacehole",
"nastyplot", "phantomforce", "zenheadbutt"])
])
def test_changeable_form_moves(filled_showdowndex, pokemon_list, moves):
for game_learnset in filled_showdowndex['learnsets'].values():
if not all(pokemon in game_learnset for pokemon in pokemon_list):
continue
for move in moves:
know_list = [move in game_learnset[pokemon] for pokemon in pokemon_list]
# all Pokemon in group know the move, or none knows it
assert sum(know_list) in (0, len(pokemon_list))


@pytest.mark.parametrize("prevo,pokemon,move", [
("bulbasaur", "venusaur", "seedbomb"),
("magby", "magmortar", "uproar"),
("minccino", "cinccino", "hypervoice"),
])
def test_prevolution_exclusive_moves(filled_showdowndex, prevo, pokemon, move):
for game_learnset in filled_showdowndex['learnsets'].values():
if not all(poke in game_learnset for poke in (prevo, pokemon)):
continue
know_list = [move in game_learnset[poke] for poke in (prevo, pokemon)]
# all Pokemon in group know the move, or none knows it
assert sum(know_list) != 1


@pytest.mark.parametrize("pokemon,move", [
("venusaurmega", "petaldance"),
("charizardmegax", "fireblast"),
("charizardmegay", "fireblast"),
])
def test_mega_evolution_moves(filled_showdowndex, pokemon, move):
for game in ['x-y', 'omega-ruby-alpha-sapphire', 'sun-moon', 'ultra-sun-ultra-moon']:
assert move in filled_showdowndex['learnsets'][game][pokemon]


@pytest.mark.parametrize("pokemon,move,game", [
("charizard", "blastburn", "firered-leafgreen"),
("beedrill", "bugbite", "heartgold-soulsilver"),
("marowak", "outrage", "black-2-white-2"),
("blastoise", "focuspunch", "omega-ruby-alpha-sapphire"),
("vikavolt", "snore", "ultra-sun-ultra-moon")
])
def test_tutor_moves(filled_showdowndex, pokemon, move, game):
assert move in filled_showdowndex['learnsets'][game][pokemon]


@pytest.mark.parametrize("pokemon,move,game", [
("gengar", "icepunch", "emerald"),
("meganium", "frenzyplant", "diamond-pearl"),
("samurott", "hydrocannon", "black-white"),
("dragalge", "dracometeor", "x-y"),
("decidueye", "grasspledge", "sun-moon"),
])
def test_tutor_exceptional_moves(filled_showdowndex, pokemon, move, game):
assert move in filled_showdowndex['learnsets'][game][pokemon]


@pytest.mark.parametrize("pokemon,move", [
("pidgeot", "substitute"),
("sandslash", "seismic-toss"),
])
def test_tutor_gen_3(filled_showdowndex, pokemon, move):
for game in ['emerald', 'firered-leafgreen']:
assert move in filled_showdowndex['learnsets'][game][pokemon]


@pytest.mark.parametrize("pokemon,move", [
("jolteon", "magnet-rise"),
("gardevoir", "signal-beam")
])
def test_tutor_gen_4(filled_showdowndex, pokemon, move):
for game in ['platinum', 'heartgold-soulsilver']:
assert move in filled_showdowndex['learnsets'][game][pokemon]


@pytest.mark.parametrize("game,has_fairy", [
("black-white", False),
("sun-moon", True)
])
def test_natural_gift_expansion(filled_showdowndex, game, has_fairy):
skip = ""
if not has_fairy:
skip = "Fairy"

natural_gifts = [f"naturalgift{type_.lower()}" for type_
in Constants.types if type_ != skip]
moves = filled_showdowndex['learnsets'][game]['lugia']
assert all(gift in moves for gift in natural_gifts)

assert ("naturalgiftfairy" in moves) == has_fairy

def test_mega_evolution_moves(filled_showdowndex):
pass


def test_tutor_moves(filled_showdowndex):
pass


def test_tutor_exceptional_moves(filled_showdowndex):
pass


def test_tutor_gen_3(filled_showdowndex):
pass
def test_hidden_power_expansion(filled_showdowndex):
hidden_powers = [f"hiddenpower{type_.lower()}" for type_
in Constants.types if type_ not in ["Normal", "Fairy"]]
moves = filled_showdowndex['learnsets']['ultra-sun-ultra-moon']['araquanid']
assert all(power in moves for power in hidden_powers)


def test_natural_gift_expansion(filled_showdowndex):
pass
def test_move_type_depending_on_pokemon(filled_showdowndex):
moves = [move_obj for move_name, move_obj in filled_showdowndex['moves'].items()
if move_name in Constants.moves_inheriting_type]
assert all("uses_pokemon_type" in move for move in moves)


def test_hidden_power_expansion(filled_showdowndex):
pass
def test_move_that_doesnt_change_type(filled_showdowndex):
moves = [move_obj for move_name, move_obj in filled_showdowndex['moves'].items()
if move_name not in Constants.moves_inheriting_type]
assert all("uses_pokemon_type" not in move for move in moves)


def test_move_type_depending_on_pokemon(filled_showdowndex):
pass
def test_moves_that_changed_type(filled_showdowndex):
moves = [move_obj for move_name, move_obj in filled_showdowndex['moves'].items()
if move_name in Constants.move_type_overrides.keys()]
assert all("override" in move for move in moves)


def test_moves_with_changed_type(filled_showdowndex):
pass
def test_moves_that_didnt_change_type(filled_showdowndex):
moves = [move_obj for move_name, move_obj in filled_showdowndex['moves'].items()
if move_name not in Constants.move_type_overrides.keys()]
assert all("override" not in move for move in moves)

0 comments on commit 0e218e8

Please sign in to comment.