Move the rest of pokedex.util.get to pokedex.db.util

This commit is contained in:
Petr Viktorin 2011-04-14 20:08:05 +03:00 committed by Eevee
parent f271812cf7
commit 69140a88f5
3 changed files with 13 additions and 13 deletions

View file

@ -2,54 +2,54 @@
from nose.tools import * from nose.tools import *
import unittest import unittest
from pokedex.db import connect, tables from pokedex.db import connect, tables, util
from pokedex.util import get, simple from pokedex.util import simple
session = connect() session = connect()
def test_get_item_identifier(): def test_get_item_identifier():
item = get.get(session, tables.Item, identifier='master-ball') item = util.get(session, tables.Item, identifier='master-ball')
assert item.name == 'Master Ball' assert item.name == 'Master Ball'
def test_get_item_name(): def test_get_item_name():
item = get.get(session, tables.Item, name='Awakening') item = util.get(session, tables.Item, name='Awakening')
assert item.name == 'Awakening' assert item.name == 'Awakening'
def test_get_english_by_identifier(): def test_get_english_by_identifier():
language = get.get(session, tables.Language, 'en') language = util.get(session, tables.Language, 'en')
assert language.name == 'English' assert language.name == 'English'
def test_get_pokemon_baseform_identifier(): def test_get_pokemon_baseform_identifier():
for identifier in 'burmy shaymin unown cresselia'.split(): for identifier in 'burmy shaymin unown cresselia'.split():
poke = get.get(session, tables.Pokemon, identifier=identifier) poke = util.get(session, tables.Pokemon, identifier=identifier)
assert poke.identifier == identifier assert poke.identifier == identifier
assert poke.is_base_form assert poke.is_base_form
def test_get_pokemon_baseform_name(): def test_get_pokemon_baseform_name():
for name in 'Burmy Shaymin Unown Cresselia'.split(): for name in 'Burmy Shaymin Unown Cresselia'.split():
poke = get.get(session, tables.Pokemon, name=name) poke = util.get(session, tables.Pokemon, name=name)
assert poke.name == name assert poke.name == name
assert poke.is_base_form assert poke.is_base_form
def test_get_pokemon_baseform_name_explicit_language(): def test_get_pokemon_baseform_name_explicit_language():
french = get.get(session, tables.Language, 'fr') french = util.get(session, tables.Language, 'fr')
for name in 'Cheniti Shaymin Zarbi Cresselia'.split(): for name in 'Cheniti Shaymin Zarbi Cresselia'.split():
poke = get.get(session, tables.Pokemon, name=name, language=french) poke = util.get(session, tables.Pokemon, name=name, language=french)
assert poke.name_map[french] == name, poke.name_map[french] assert poke.name_map[french] == name, poke.name_map[french]
assert poke.is_base_form assert poke.is_base_form
def test_get_pokemon_other_form_identifier(): def test_get_pokemon_other_form_identifier():
for ii in 'wormadam/trash shaymin/sky shaymin/land'.split(): for ii in 'wormadam/trash shaymin/sky shaymin/land'.split():
pokemon_identifier, form_identifier = ii.split('/') pokemon_identifier, form_identifier = ii.split('/')
poke = get.get(session, tables.Pokemon, identifier=pokemon_identifier, form_identifier=form_identifier) poke = util.get(session, tables.Pokemon, identifier=pokemon_identifier, form_identifier=form_identifier)
assert poke.identifier == pokemon_identifier assert poke.identifier == pokemon_identifier
if poke.form.unique_pokemon_id: if poke.form.unique_pokemon_id:
assert poke.form.identifier == form_identifier assert poke.form.identifier == form_identifier
def test_types_french_order(): def test_types_french_order():
french = get.get(session, tables.Language, 'fr') french = util.get(session, tables.Language, 'fr')
types = session.query(tables.Type).filter(tables.Type.id < 10000) types = session.query(tables.Type).filter(tables.Type.id < 10000)
types = list(get.order_by_name(types, tables.Type, language=french)) types = list(util.order_by_name(types, tables.Type, language=french))
assert types[0].name_map[french] == 'Acier', types[0].name_map[french] assert types[0].name_map[french] == 'Acier', types[0].name_map[french]
assert types[-1].name_map[french] == 'Vol', types[-1].name_map[french] assert types[-1].name_map[french] == 'Vol', types[-1].name_map[french]

View file

@ -12,7 +12,7 @@ of what to watch out for.
""" """
from pokedex.db import tables from pokedex.db import tables
from pokedex.util.get import filter_base_forms, order_by_name from pokedex.db.util import filter_base_forms, order_by_name
def pokemon(session): def pokemon(session):
"""Get a "sane" list of pokemon """Get a "sane" list of pokemon