Pokemon species split: Tests

This commit is contained in:
Petr Viktorin 2011-04-30 02:14:34 +03:00
parent d0c01810be
commit bc7e9128e8
3 changed files with 25 additions and 24 deletions

View file

@ -14,29 +14,29 @@ def setup():
def test_exact_lookup():
tests = [
# Simple lookups
(u'Eevee', 'pokemon', 133),
(u'Eevee', 'pokemon_species',133),
(u'Scratch', 'moves', 10),
(u'Master Ball', 'items', 1),
(u'normal', 'types', 1),
(u'Run Away', 'abilities', 50),
# Funny characters
(u'Mr. Mime', 'pokemon', 122),
(u"Farfetch'd", 'pokemon', 83),
(u'Poké Ball', 'items', 4),
(u'Mr. Mime', 'pokemon_species', 122),
(u"Farfetch'd", 'pokemon_species', 83),
(u'Poké Ball', 'items', 4),
# Forms
(u'Rotom', 'pokemon', 479),
(u'Wash Rotom', 'pokemon_forms',10059),
(u'East Shellos', 'pokemon_forms',10039),
(u'Rotom', 'pokemon_species', 479),
(u'Wash Rotom', 'pokemon_forms', 708),
(u'East Shellos', 'pokemon_forms', 688),
# Other languages
(u'イーブイ', 'pokemon', 133),
(u'Iibui', 'pokemon', 133),
(u'Eievui', 'pokemon', 133),
(u'이브이', 'pokemon', 133),
(u'伊布', 'pokemon', 133),
(u'Evoli', 'pokemon', 133),
(u'イーブイ', 'pokemon_species', 133),
(u'Iibui', 'pokemon_species', 133),
(u'Eievui', 'pokemon_species', 133),
(u'이브이', 'pokemon_species', 133),
(u'伊布', 'pokemon_species', 133),
(u'Evoli', 'pokemon_species', 133),
]
for input, table, id in tests:
@ -63,13 +63,13 @@ def test_multi_lookup():
def test_type_lookup():
results = lookup.lookup(u'pokemon:1')
assert_equal(results[0].object.__tablename__, 'pokemon',
assert_equal(results[0].object.__tablename__, 'pokemon_species',
u'Type restriction works correctly')
assert_equal(len(results), 1, u'Only one id result when type is specified')
assert_equal(results[0].object.name, u'Bulbasaur',
u'Type + id returns the right result')
results = lookup.lookup(u'1', valid_types=['pokemon'])
results = lookup.lookup(u'1', valid_types=['pokemon_species'])
assert_equal(results[0].object.name, u'Bulbasaur',
u'valid_types works as well as type: prefix')
@ -141,7 +141,7 @@ def test_random_lookup():
results = lookup.lookup(u'random')
assert_equal(len(results), 1, u'Random returns one result')
for table_name in [u'pokemon', u'moves', u'items', u'abilities', u'types']:
for table_name in [u'pokemon_species', u'moves', u'items', u'abilities', u'types']:
results = lookup.lookup(u'random', valid_types=[table_name])
assert_equal(len(results), 1, u'Constrained random returns one result')
assert_equal(results[0].object.__tablename__, table_name,

View file

@ -202,5 +202,6 @@ def test_identifiers_with_names():
"""Test that named tables have identifiers
"""
for table in sorted(tables.mapped_classes, key=lambda t: t.__name__):
if hasattr(table, 'name'):
assert hasattr(table, 'identifier'), table
for translation_class in table.translation_classes:
if hasattr(translation_class, 'name'):
assert hasattr(table, 'identifier'), table

View file

@ -13,13 +13,13 @@ class TestStrings(object):
self.connection.rollback()
def test_filter(self):
q = self.connection.query(tables.Pokemon).filter(
tables.Pokemon.name == u"Marowak")
q = self.connection.query(tables.PokemonSpecies).filter(
tables.PokemonSpecies.name == u"Marowak")
assert q.one().identifier == 'marowak'
def test_languages(self):
q = self.connection.query(tables.Pokemon).filter(
tables.Pokemon.name == u"Mightyena")
q = self.connection.query(tables.PokemonSpecies).filter(
tables.PokemonSpecies.name == u"Mightyena")
pkmn = q.one()
for lang, name in (
('en', u'Mightyena'),
@ -33,8 +33,8 @@ class TestStrings(object):
@raises(KeyError)
def test_bad_lang(self):
q = self.connection.query(tables.Pokemon).filter(
tables.Pokemon.name == u"Mightyena")
q = self.connection.query(tables.PokemonSpecies).filter(
tables.PokemonSpecies.name == u"Mightyena")
pkmn = q.one()
pkmn.names["identifier of a language that doesn't exist"]