2011-04-14 14:42:35 +00:00
|
|
|
# encoding: utf8
|
|
|
|
from nose.tools import *
|
|
|
|
import unittest
|
|
|
|
|
2011-04-14 17:08:05 +00:00
|
|
|
from pokedex.db import connect, tables, util
|
|
|
|
from pokedex.util import simple
|
2011-04-14 14:42:35 +00:00
|
|
|
|
|
|
|
session = connect()
|
|
|
|
|
|
|
|
def test_get_item_identifier():
|
2011-04-14 17:08:05 +00:00
|
|
|
item = util.get(session, tables.Item, identifier='master-ball')
|
2011-04-14 14:42:35 +00:00
|
|
|
assert item.name == 'Master Ball'
|
|
|
|
|
|
|
|
def test_get_item_name():
|
2011-04-14 17:08:05 +00:00
|
|
|
item = util.get(session, tables.Item, name='Awakening')
|
2011-04-14 14:42:35 +00:00
|
|
|
assert item.name == 'Awakening'
|
|
|
|
|
|
|
|
def test_get_english_by_identifier():
|
2011-04-14 17:08:05 +00:00
|
|
|
language = util.get(session, tables.Language, 'en')
|
2011-04-14 14:42:35 +00:00
|
|
|
assert language.name == 'English'
|
|
|
|
|
|
|
|
def test_get_pokemon_baseform_identifier():
|
|
|
|
for identifier in 'burmy shaymin unown cresselia'.split():
|
2011-04-14 17:08:05 +00:00
|
|
|
poke = util.get(session, tables.Pokemon, identifier=identifier)
|
2011-04-14 14:42:35 +00:00
|
|
|
assert poke.identifier == identifier
|
|
|
|
assert poke.is_base_form
|
|
|
|
|
|
|
|
def test_get_pokemon_baseform_name():
|
|
|
|
for name in 'Burmy Shaymin Unown Cresselia'.split():
|
2011-04-14 17:08:05 +00:00
|
|
|
poke = util.get(session, tables.Pokemon, name=name)
|
2011-04-14 14:42:35 +00:00
|
|
|
assert poke.name == name
|
|
|
|
assert poke.is_base_form
|
|
|
|
|
|
|
|
def test_get_pokemon_baseform_name_explicit_language():
|
2011-04-14 17:08:05 +00:00
|
|
|
french = util.get(session, tables.Language, 'fr')
|
2011-04-14 14:42:35 +00:00
|
|
|
for name in 'Cheniti Shaymin Zarbi Cresselia'.split():
|
2011-04-14 17:08:05 +00:00
|
|
|
poke = util.get(session, tables.Pokemon, name=name, language=french)
|
2011-04-14 14:42:35 +00:00
|
|
|
assert poke.name_map[french] == name, poke.name_map[french]
|
|
|
|
assert poke.is_base_form
|
|
|
|
|
|
|
|
def test_get_pokemon_other_form_identifier():
|
|
|
|
for ii in 'wormadam/trash shaymin/sky shaymin/land'.split():
|
|
|
|
pokemon_identifier, form_identifier = ii.split('/')
|
2011-04-14 17:08:05 +00:00
|
|
|
poke = util.get(session, tables.Pokemon, identifier=pokemon_identifier, form_identifier=form_identifier)
|
2011-04-14 14:42:35 +00:00
|
|
|
assert poke.identifier == pokemon_identifier
|
|
|
|
if poke.form.unique_pokemon_id:
|
|
|
|
assert poke.form.identifier == form_identifier
|
|
|
|
|
|
|
|
def test_types_french_order():
|
2011-04-14 17:08:05 +00:00
|
|
|
french = util.get(session, tables.Language, 'fr')
|
2011-04-14 16:24:30 +00:00
|
|
|
types = session.query(tables.Type).filter(tables.Type.id < 10000)
|
2011-04-14 17:08:05 +00:00
|
|
|
types = list(util.order_by_name(types, tables.Type, language=french))
|
2011-04-14 14:42:35 +00:00
|
|
|
assert types[0].name_map[french] == 'Acier', types[0].name_map[french]
|
|
|
|
assert types[-1].name_map[french] == 'Vol', types[-1].name_map[french]
|
|
|
|
|
2011-04-14 16:24:30 +00:00
|
|
|
def test_simple_pokemon():
|
|
|
|
pokemon = simple.pokemon(session)
|
|
|
|
assert pokemon[0].identifier == 'bulbasaur'
|
|
|
|
assert pokemon[-1].identifier == 'genesect'
|
|
|
|
|
|
|
|
def test_simple_types():
|
|
|
|
types = simple.types(session)
|
|
|
|
assert types[0].identifier == 'bug'
|
|
|
|
assert types[-1].identifier == 'water'
|
|
|
|
|
|
|
|
def test_simple_moves():
|
|
|
|
moves = simple.moves(session)
|
2011-04-14 14:42:35 +00:00
|
|
|
assert moves[0].identifier == 'absorb'
|
|
|
|
assert moves[-1].identifier == 'zen-headbutt'
|
|
|
|
|
2011-04-14 16:24:30 +00:00
|
|
|
def test_simple_items():
|
|
|
|
items = simple.items(session)
|
2011-04-14 14:42:35 +00:00
|
|
|
assert items[0].identifier == 'ability-urge'
|
|
|
|
assert items[-1].identifier == 'zoom-lens'
|
|
|
|
|