mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-14 15:57:07 +00:00
Create tests for past Pokemon types
This commit is contained in:
parent
87ce1a593a
commit
0f6881442f
1 changed files with 29 additions and 1 deletions
|
@ -1815,6 +1815,22 @@ class APIData():
|
|||
|
||||
return pokemon_type
|
||||
|
||||
@classmethod
|
||||
def setup_pokemon_past_type_data(cls, pokemon, generation, type=None, slot=1):
|
||||
|
||||
type = type or cls.setup_type_data(
|
||||
name='tp for pkmn')
|
||||
|
||||
pokemon_type_past = PokemonTypePast(
|
||||
pokemon=pokemon,
|
||||
generation=generation,
|
||||
type=type,
|
||||
slot=slot
|
||||
)
|
||||
pokemon_type_past.save()
|
||||
|
||||
return pokemon_type_past
|
||||
|
||||
@classmethod
|
||||
def setup_pokemon_item_data(cls, pokemon=None, item=None, version=None, rarity=50):
|
||||
|
||||
|
@ -4095,6 +4111,8 @@ class APITests(APIData, APITestCase):
|
|||
pokemon_ability = self.setup_pokemon_ability_data(pokemon=pokemon)
|
||||
pokemon_stat = self.setup_pokemon_stat_data(pokemon=pokemon)
|
||||
pokemon_type = self.setup_pokemon_type_data(pokemon=pokemon)
|
||||
generation = self.setup_generation_data(name='base gen')
|
||||
pokemon_past_type = self.setup_pokemon_past_type_data(pokemon=pokemon, generation=generation)
|
||||
pokemon_item = self.setup_pokemon_item_data(pokemon=pokemon)
|
||||
pokemon_sprites = self.setup_pokemon_sprites_data(pokemon=pokemon)
|
||||
pokemon_game_index = self.setup_pokemon_game_index_data(pokemon=pokemon, game_index=10)
|
||||
|
@ -4159,12 +4177,22 @@ class APITests(APIData, APITestCase):
|
|||
self.assertEqual(
|
||||
response.data['stats'][0]['stat']['url'],
|
||||
'{}{}/stat/{}/'.format(TEST_HOST, API_V2, pokemon_stat.stat.pk))
|
||||
# stat params
|
||||
# type params
|
||||
self.assertEqual(response.data['types'][0]['slot'], pokemon_type.slot)
|
||||
self.assertEqual(response.data['types'][0]['type']['name'], pokemon_type.type.name)
|
||||
self.assertEqual(
|
||||
response.data['types'][0]['type']['url'],
|
||||
'{}{}/type/{}/'.format(TEST_HOST, API_V2, pokemon_type.type.pk))
|
||||
# past type params
|
||||
self.assertEqual(response.data['past_types'][0]['generation']['name'], pokemon_past_type.generation.name)
|
||||
self.assertEqual(
|
||||
response.data['past_types'][0]['generation']['url'],
|
||||
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, pokemon_past_type.generation.pk))
|
||||
self.assertEqual(response.data['past_types'][0]['types'][0]['slot'], pokemon_past_type.slot)
|
||||
self.assertEqual(response.data['past_types'][0]['types'][0]['type']['name'], pokemon_past_type.type.name)
|
||||
self.assertEqual(
|
||||
response.data['past_types'][0]['types'][0]['type']['url'],
|
||||
'{}{}/type/{}/'.format(TEST_HOST, API_V2, pokemon_past_type.type.pk))
|
||||
# items params
|
||||
self.assertEqual(response.data['held_items'][0]['item']['name'], pokemon_item.item.name)
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in a new issue