2 from nose
.tools
import *
5 from pokedex
.db
import connect
, tables
, util
6 from pokedex
.util
import simple
10 def test_get_item_identifier():
11 item
= util
.get(session
, tables
.Item
, identifier
='master-ball')
12 assert item
.name
== 'Master Ball'
14 def test_get_item_name():
15 item
= util
.get(session
, tables
.Item
, name
='Awakening')
16 assert item
.name
== 'Awakening'
18 def test_get_english_by_identifier():
19 language
= util
.get(session
, tables
.Language
, 'en')
20 assert language
.name
== 'English'
22 def test_get_pokemon_baseform_identifier():
23 for identifier
in 'burmy shaymin unown cresselia'.split():
24 poke
= util
.get(session
, tables
.Pokemon
, identifier
=identifier
)
25 assert poke
.identifier
== identifier
26 assert poke
.is_base_form
28 def test_get_pokemon_baseform_name():
29 for name
in 'Burmy Shaymin Unown Cresselia'.split():
30 poke
= util
.get(session
, tables
.Pokemon
, name
=name
)
31 assert poke
.name
== name
32 assert poke
.is_base_form
34 def test_get_pokemon_baseform_name_explicit_language():
35 french
= util
.get(session
, tables
.Language
, 'fr')
36 for name
in 'Cheniti Shaymin Zarbi Cresselia'.split():
37 poke
= util
.get(session
, tables
.Pokemon
, name
=name
, language
=french
)
38 assert poke
.name_map
[french
] == name
, poke
.name_map
[french
]
39 assert poke
.is_base_form
41 def test_get_pokemon_other_form_identifier():
42 for ii
in 'wormadam/trash shaymin/sky shaymin/land'.split():
43 pokemon_identifier
, form_identifier
= ii
.split('/')
44 poke
= util
.get(session
, tables
.Pokemon
, identifier
=pokemon_identifier
, form_identifier
=form_identifier
)
45 assert poke
.identifier
== pokemon_identifier
46 if poke
.form
.unique_pokemon_id
:
47 assert poke
.form
.identifier
== form_identifier
49 def test_types_french_order():
50 french
= util
.get(session
, tables
.Language
, 'fr')
51 types
= session
.query(tables
.Type
).filter(tables
.Type
.id < 10000)
52 types
= list(util
.order_by_name(types
, tables
.Type
, language
=french
))
53 assert types
[0].name_map
[french
] == 'Acier', types
[0].name_map
[french
]
54 assert types
[-1].name_map
[french
] == 'Vol', types
[-1].name_map
[french
]
56 def test_simple_pokemon():
57 pokemon
= simple
.pokemon(session
)
58 assert pokemon
[0].identifier
== 'bulbasaur'
59 assert pokemon
[-1].identifier
== 'genesect'
61 def test_simple_types():
62 types
= simple
.types(session
)
63 assert types
[0].identifier
== 'bug'
64 assert types
[-1].identifier
== 'water'
66 def test_simple_moves():
67 moves
= simple
.moves(session
)
68 assert moves
[0].identifier
== 'absorb'
69 assert moves
[-1].identifier
== 'zen-headbutt'
71 def test_simple_items():
72 items
= simple
.items(session
)
73 assert items
[0].identifier
== 'ability-urge'
74 assert items
[-1].identifier
== 'zoom-lens'