From bc7e9128e8df241fffc174beda376f443b219fc3 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Sat, 30 Apr 2011 02:14:34 +0300 Subject: [PATCH] Pokemon species split: Tests --- pokedex/tests/test_lookup.py | 32 ++++++++++++++++---------------- pokedex/tests/test_schema.py | 5 +++-- pokedex/tests/test_strings.py | 12 ++++++------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/pokedex/tests/test_lookup.py b/pokedex/tests/test_lookup.py index 700610f..3da916d 100644 --- a/pokedex/tests/test_lookup.py +++ b/pokedex/tests/test_lookup.py @@ -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, diff --git a/pokedex/tests/test_schema.py b/pokedex/tests/test_schema.py index c09564a..c73182f 100644 --- a/pokedex/tests/test_schema.py +++ b/pokedex/tests/test_schema.py @@ -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 diff --git a/pokedex/tests/test_strings.py b/pokedex/tests/test_strings.py index 0b55da3..83dc94b 100644 --- a/pokedex/tests/test_strings.py +++ b/pokedex/tests/test_strings.py @@ -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"]