pokeapi/pokemon_v2/tests.py

4554 lines
182 KiB
Python
Raw Normal View History

import json
from rest_framework import status
2015-10-18 23:01:33 +00:00
from rest_framework.test import APITestCase
from pokemon_v2.models import *
2015-10-23 04:56:01 +00:00
# pylint: disable=redefined-builtin
TEST_HOST = 'http://testserver'
MEDIA_HOST = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/'
API_V2 = '/api/v2'
2016-03-05 11:40:41 +00:00
class APIData():
""" Data Initializers"""
# Gender Data
@classmethod
def setup_gender_data(cls, name='gndr'):
2016-03-05 11:40:41 +00:00
gender = Gender.objects.create(
name=name,
)
gender.save()
return gender
2016-03-05 11:40:41 +00:00
# Language Data
2015-10-18 23:01:33 +00:00
@classmethod
def setup_language_data(cls, name='lang'):
2016-03-05 11:40:41 +00:00
language = Language.objects.create(
iso639='ts',
iso3166='tt',
name=name,
official=True,
order=1,
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
language.save()
return language
2014-12-15 10:13:52 +00:00
2015-10-23 04:56:01 +00:00
@classmethod
def setup_language_name_data(cls, language, name='lang nm'):
2015-10-23 04:56:01 +00:00
local_language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
language_name = LanguageName.objects.create(
language=language,
local_language=local_language,
name=name
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
language_name.save()
2014-12-07 16:38:15 +00:00
2015-10-23 04:56:01 +00:00
return language_name
2016-03-05 11:40:41 +00:00
# Region Data
2015-10-23 04:56:01 +00:00
@classmethod
def setup_region_data(cls, name='reg'):
2016-03-05 11:40:41 +00:00
region = Region.objects.create(
name=name
)
2015-10-23 04:56:01 +00:00
region.save()
return region
@classmethod
def setup_region_name_data(cls, region, name='reg nm'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
region_name = RegionName.objects.create(
region=region,
language=language,
name=name
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
region_name.save()
return region_name
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
# Generation Data
2015-10-18 23:01:33 +00:00
@classmethod
def setup_generation_data(cls, region=None, name='gen'):
2015-10-18 23:01:33 +00:00
region = region or cls.setup_region_data(
name='reg for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
generation = Generation.objects.create(
region=region,
name=name
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
generation.save()
return generation
@classmethod
def setup_generation_name_data(cls, generation, name='gen nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
generation_name = GenerationName.objects.create(
generation=generation,
language=language,
name=name
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
generation_name.save()
2015-10-18 23:01:33 +00:00
2015-10-23 04:56:01 +00:00
return generation_name
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
# Version Data
2015-10-18 23:01:33 +00:00
@classmethod
def setup_version_group_data(cls, name='ver grp', generation=None):
2015-10-18 23:01:33 +00:00
generation = generation or cls.setup_generation_data(
name='gen for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
version_group = VersionGroup.objects.create(
name=name,
generation=generation,
order=1
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
version_group.save()
return version_group
2015-10-18 23:01:33 +00:00
@classmethod
def setup_version_group_region_data(cls, version_group=None, region=None):
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
version_group_region = VersionGroupRegion.objects.create(
version_group=version_group,
region=region
)
version_group_region.save()
return version_group_region
@classmethod
def setup_version_data(cls, version_group=None, name='ver'):
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
version = Version.objects.create(
name=name,
version_group=version_group,
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
version.save()
2015-10-18 23:01:33 +00:00
2015-10-23 04:56:01 +00:00
return version
@classmethod
def setup_version_name_data(cls, version, name='ver nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
version_name = VersionName.objects.create(
version=version,
language=language,
name=name
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
version_name.save()
2015-10-23 04:56:01 +00:00
return version_name
2016-03-05 11:40:41 +00:00
# Ability Data
2015-10-18 23:01:33 +00:00
@classmethod
def setup_ability_data(cls, name='ablty', generation=None):
2015-10-18 23:01:33 +00:00
generation = generation or cls.setup_generation_data(
name='gen for ' + name)
2016-03-05 11:40:41 +00:00
ability = Ability.objects.create(
name=name,
generation=generation,
is_main_series=False
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
ability.save()
return ability
@classmethod
def setup_ability_name_data(cls, ability, name='ablty nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
ability_name = AbilityName.objects.create(
ability=ability,
language=language,
name=name
2015-10-23 04:56:01 +00:00
)
ability_name.save()
return ability_name
@classmethod
def setup_ability_effect_text_data(cls, ability,
2016-03-05 11:40:41 +00:00
short_effect='ablty shrt efct', effect='ablty efct'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + effect)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
ability_effect_text = AbilityEffectText.objects.create(
ability=ability,
language=language,
short_effect=short_effect,
effect=effect
2015-10-23 04:56:01 +00:00
)
ability_effect_text.save()
2015-10-23 04:56:01 +00:00
return ability_effect_text
2015-10-23 04:56:01 +00:00
@classmethod
def setup_ability_change_data(cls, ability):
version_group = cls.setup_version_group_data(
name='ver grp for ablty chng')
2016-03-05 11:40:41 +00:00
ability_change = AbilityChange.objects.create(
ability=ability,
version_group=version_group
)
ability_change.save()
return ability_change
@classmethod
def setup_ability_change_effect_text_data(cls, ability_change, effect='ablty change efct'):
language = cls.setup_language_data(
name='lang for ' + effect)
2016-03-05 11:40:41 +00:00
ability_change_effect_text = AbilityChangeEffectText.objects.create(
ability_change=ability_change,
language=language,
effect=effect
)
ability_change_effect_text.save()
return ability_change_effect_text
2015-10-23 04:56:01 +00:00
@classmethod
def setup_ability_flavor_text_data(cls, ability, flavor_text='ablty flvr txt'):
2015-10-23 04:56:01 +00:00
version_group = cls.setup_version_group_data(
name='ver grp for ' + flavor_text)
language = cls.setup_language_data(
name='lang for ' + flavor_text)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
ability_flavor_text = AbilityFlavorText.objects.create(
ability=ability,
version_group=version_group,
language=language,
flavor_text=flavor_text
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
ability_flavor_text.save()
return ability_flavor_text
2016-03-05 11:40:41 +00:00
# Item Data
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_attribute_data(cls, name="itm attr"):
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_attribute = ItemAttribute.objects.create(
name=name,
2015-10-18 23:01:33 +00:00
)
2015-10-23 04:56:01 +00:00
item_attribute.save()
return item_attribute
@classmethod
def setup_item_attribute_name_data(cls, item_attribute, name='itm attr nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_attribute_name = ItemAttributeName.objects.create(
item_attribute=item_attribute,
name=name,
language=language
2015-10-18 23:01:33 +00:00
)
item_attribute_name.save()
return item_attribute_name
@classmethod
def setup_item_attribute_description_data(cls, item_attribute, description='itm attr desc'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + description)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_attribute_description = ItemAttributeDescription.objects.create(
item_attribute=item_attribute,
description=description,
language=language
)
item_attribute_description.save()
2015-10-23 04:56:01 +00:00
return item_attribute_description
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_attribute_map_data(cls, item, item_attribute):
2016-03-05 11:40:41 +00:00
item_attribute_map = ItemAttributeMap(
item=item,
item_attribute=item_attribute
)
item_attribute_map.save()
return item_attribute_map
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_fling_effect_data(cls, name="itm flng efct"):
2016-03-05 11:40:41 +00:00
item_fling_effect = ItemFlingEffect.objects.create(
name=name,
)
2015-10-23 04:56:01 +00:00
item_fling_effect.save()
2015-10-18 23:01:33 +00:00
2015-10-23 04:56:01 +00:00
return item_fling_effect
2015-10-18 23:01:33 +00:00
@classmethod
def setup_item_fling_effect_effect_text_data(cls, item_fling_effect,
2016-03-05 11:40:41 +00:00
effect='itm flng efct efct txt'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + effect)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_fling_effect_effect_text = ItemFlingEffectEffectText.objects.create(
item_fling_effect=item_fling_effect,
effect=effect,
language=language
2015-10-23 04:56:01 +00:00
)
item_fling_effect_effect_text.save()
2015-10-23 04:56:01 +00:00
return item_fling_effect_effect_text
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_pocket_data(cls, name='itm pkt'):
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_pocket = ItemPocket.objects.create(
name=name,
2015-10-23 04:56:01 +00:00
)
item_pocket.save()
return item_pocket
@classmethod
def setup_item_pocket_name_data(cls, item_pocket, name='itm pkt nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_pocket_name = ItemPocketName.objects.create(
item_pocket=item_pocket,
name=name,
language=language
2015-10-23 04:56:01 +00:00
)
item_pocket_name.save()
return item_pocket_name
@classmethod
def setup_item_category_data(cls, name="itm ctgry", item_pocket=None):
item_pocket = item_pocket or cls.setup_item_pocket_data(
name='itm pkt for ' + name)
2016-03-05 11:40:41 +00:00
item_category = ItemCategory.objects.create(
name=name,
item_pocket=item_pocket
)
item_category.save()
return item_category
@classmethod
def setup_item_category_name_data(cls, item_category, name='itm ctgry nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_category_name = ItemCategoryName.objects.create(
item_category=item_category,
name=name,
language=language
)
item_category_name.save()
2015-10-23 04:56:01 +00:00
return item_category_name
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_sprites_data(cls, item, default=True):
sprite_path = '/media/sprites/items/%s.png'
sprites = {
'default': sprite_path % item.id if default else None,
}
2016-03-05 11:40:41 +00:00
item_sprites = ItemSprites.objects.create(
item=item,
sprites=json.dumps(sprites)
)
item_sprites.save()
return item_sprites
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_data(cls, item_category=None, item_fling_effect=None,
2016-03-05 11:40:41 +00:00
name='itm', cost=100, fling_power=100):
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item = Item.objects.create(
name=name,
item_category=item_category,
cost=cost,
fling_power=fling_power,
2016-03-05 11:40:41 +00:00
item_fling_effect=item_fling_effect
2015-10-23 04:56:01 +00:00
)
item.save()
return item
@classmethod
def setup_item_name_data(cls, item, name='itm nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_name = ItemName.objects.create(
item=item,
name=name,
language=language
2015-10-23 04:56:01 +00:00
)
item_name.save()
return item_name
@classmethod
def setup_item_effect_text_data(cls, item,
2016-03-05 11:40:41 +00:00
short_effect='ablty shrt efct', effect='ablty efct'):
language = cls.setup_language_data(
name='lang for ' + effect)
2016-03-05 11:40:41 +00:00
item_effect_text = ItemEffectText.objects.create(
item=item,
language=language,
short_effect=short_effect,
effect=effect
)
item_effect_text.save()
return item_effect_text
2015-10-23 04:56:01 +00:00
@classmethod
def setup_item_flavor_text_data(cls, item, flavor_text='itm flvr txt'):
2015-10-23 04:56:01 +00:00
version_group = cls.setup_version_group_data(
name='ver grp for ' + flavor_text)
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + flavor_text)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
item_flavor_text = ItemFlavorText.objects.create(
item=item,
version_group=version_group,
language=language,
flavor_text=flavor_text
2015-10-23 04:56:01 +00:00
)
item_flavor_text.save()
return item_flavor_text
@classmethod
def setup_item_game_index_data(cls, item, game_index=0):
2015-10-23 04:56:01 +00:00
generation = cls.setup_generation_data(
name='gen for itm gm indx')
2016-03-05 11:40:41 +00:00
item_game_index = ItemGameIndex.objects.create(
item=item,
game_index=game_index,
generation=generation
)
item_game_index.save()
return item_game_index
2016-03-05 11:40:41 +00:00
# Contest Data
@classmethod
def setup_contest_type_data(cls, name='cntst tp'):
2016-03-05 11:40:41 +00:00
contest_type = ContestType.objects.create(
name=name,
)
contest_type.save()
return contest_type
@classmethod
def setup_contest_type_name_data(cls, contest_type, name='cntst tp nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
contest_type_name = ContestTypeName.objects.create(
language=language,
name=name,
contest_type=contest_type
)
contest_type_name.save()
return contest_type_name
@classmethod
def setup_contest_effect_data(cls, appeal=2, jam=0):
2016-03-05 11:40:41 +00:00
contest_effect = ContestEffect.objects.create(
appeal=appeal,
jam=jam
)
contest_effect.save()
return contest_effect
@classmethod
def setup_contest_effect_flavor_text_data(cls,
2016-03-05 11:40:41 +00:00
contest_effect, flavor_text='cntst efct flvr txt'):
language = cls.setup_language_data(
name='lang for ' + flavor_text)
2016-03-05 11:40:41 +00:00
contest_effect_flavor_text = ContestEffectFlavorText.objects.create(
language=language,
flavor_text=flavor_text,
contest_effect=contest_effect
)
contest_effect_flavor_text.save()
return contest_effect_flavor_text
@classmethod
def setup_contest_effect_effect_text_data(cls, contest_effect, effect='cntst efct efct txt'):
language = cls.setup_language_data(
name='lang for ' + effect)
2016-03-05 11:40:41 +00:00
contest_effect_effect_text = ContestEffectEffectText.objects.create(
language=language,
effect=effect,
contest_effect=contest_effect
)
contest_effect_effect_text.save()
return contest_effect_effect_text
@classmethod
def setup_super_contest_effect_data(cls, appeal=2):
2016-03-05 11:40:41 +00:00
super_contest_effect = SuperContestEffect.objects.create(
appeal=appeal,
)
super_contest_effect.save()
return super_contest_effect
@classmethod
def setup_super_contest_effect_flavor_text_data(cls, super_contest_effect,
2016-03-05 11:40:41 +00:00
flavor_text='spr cntst efct flvr txt'):
language = cls.setup_language_data(
name='lang for ' + flavor_text)
2016-03-05 11:40:41 +00:00
super_contest_effect_flavor_text = SuperContestEffectFlavorText.objects.create(
language=language,
flavor_text=flavor_text,
super_contest_effect=super_contest_effect
)
super_contest_effect_flavor_text.save()
return super_contest_effect_flavor_text
2016-03-05 11:40:41 +00:00
# Berry Data
@classmethod
def setup_berry_flavor_data(cls, contest_type=None, name="bry flvr"):
contest_type = contest_type or cls.setup_contest_type_data(
name='cntst tp for bry flvr')
2016-03-05 11:40:41 +00:00
berry_flavor = BerryFlavor.objects.create(
name=name,
contest_type=contest_type
)
berry_flavor.save()
return berry_flavor
@classmethod
def setup_berry_flavor_name_data(cls, berry_flavor, name='bry flvr nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
berry_flavor_name = BerryFlavorName.objects.create(
language=language,
name=name,
berry_flavor=berry_flavor
)
berry_flavor_name.save()
return berry_flavor_name
2015-10-23 04:56:01 +00:00
@classmethod
def setup_berry_firmness_data(cls, name='bry frmns'):
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
berry_firmness = BerryFirmness.objects.create(
name=name,
2015-10-23 04:56:01 +00:00
)
berry_firmness.save()
return berry_firmness
@classmethod
def setup_berry_firmness_name_data(cls, berry_firmness, name='bry frmns nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
berry_firmness_name = BerryFirmnessName.objects.create(
language=language,
name=name,
berry_firmness=berry_firmness
2015-10-23 04:56:01 +00:00
)
berry_firmness_name.save()
return berry_firmness_name
@classmethod
def setup_berry_flavor_map_data(cls, berry, berry_flavor, potency=20):
2016-03-05 11:40:41 +00:00
berry_flavor_map = BerryFlavorMap(
berry=berry,
berry_flavor=berry_flavor,
potency=potency
)
berry_flavor_map.save()
return berry_flavor_map
@classmethod
def setup_berry_data(cls, berry_firmness=None, item=None, natural_gift_type=None,
2016-03-05 11:40:41 +00:00
name='bry', natural_gift_power=50, size=20, max_harvest=5,
growth_time=2, soil_dryness=15, smoothness=25):
2015-10-23 04:56:01 +00:00
item = item or cls.setup_item_data(
name='itm for ' + name)
2015-10-23 04:56:01 +00:00
berry_firmness = berry_firmness or cls.setup_berry_firmness_data(
name='bry frmns for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
berry = Berry.objects.create(
name=name,
item=item,
berry_firmness=berry_firmness,
natural_gift_power=natural_gift_power,
natural_gift_type=natural_gift_type,
size=size,
max_harvest=max_harvest,
growth_time=growth_time,
soil_dryness=soil_dryness,
smoothness=smoothness
2015-10-23 04:56:01 +00:00
)
berry.save()
return berry
2016-03-05 11:40:41 +00:00
# Egg Group Data
@classmethod
def setup_egg_group_data(cls, name='egg grp'):
2016-03-05 11:40:41 +00:00
egg_group = EggGroup.objects.create(
name=name,
)
egg_group.save()
return egg_group
@classmethod
def setup_egg_group_name_data(cls, egg_group, name='ntr nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
egg_group_name = EggGroupName.objects.create(
egg_group=egg_group,
language=language,
name=name
)
egg_group_name.save()
return egg_group_name
2016-03-05 11:40:41 +00:00
# Growth Rate Data
2015-10-23 04:56:01 +00:00
@classmethod
def setup_growth_rate_data(cls, name='grth rt', formula="pie*1000"):
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
growth_rate = GrowthRate(
name=name,
formula=formula
2015-10-23 04:56:01 +00:00
)
growth_rate.save()
return growth_rate
@classmethod
def setup_growth_rate_description_data(cls, growth_rate, description='grth rt desc'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + description)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
growth_rate_description = GrowthRateDescription.objects.create(
growth_rate=growth_rate,
description=description,
language=language
2015-10-23 04:56:01 +00:00
)
growth_rate_description.save()
return growth_rate_description
2016-03-05 11:40:41 +00:00
# Location Data
2015-10-23 04:56:01 +00:00
@classmethod
def setup_location_data(cls, region=None, name='lctn'):
2015-10-23 04:56:01 +00:00
region = region or cls.setup_region_data(
name='rgn for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
location = Location(
name=name,
region=region
2015-10-23 04:56:01 +00:00
)
location.save()
return location
@classmethod
def setup_location_game_index_data(cls, location, game_index=0):
generation = cls.setup_generation_data(
name='gen for itm gm indx')
2016-03-05 11:40:41 +00:00
location_game_index = LocationGameIndex.objects.create(
location=location,
game_index=game_index,
generation=generation
)
location_game_index.save()
return location_game_index
2015-10-23 04:56:01 +00:00
@classmethod
def setup_location_name_data(cls, location, name='lctn nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
location_name = LocationName.objects.create(
language=language,
name=name,
location=location
2015-10-23 04:56:01 +00:00
)
location_name.save()
return location_name
@classmethod
def setup_location_area_data(cls, location=None, name='lctn area', game_index=0):
location = location or cls.setup_location_data(
name='lctn for ' + name)
2016-03-05 11:40:41 +00:00
location_area = LocationArea(
location=location,
name=name,
game_index=game_index
)
location_area.save()
return location_area
@classmethod
def setup_location_area_name_data(cls, location_area, name='lctn area nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
location_area_name = LocationAreaName.objects.create(
language=language,
name=name,
location_area=location_area
)
location_area_name.save()
return location_area_name
2016-03-05 11:40:41 +00:00
# Type Data
2015-10-23 04:56:01 +00:00
@classmethod
def setup_type_data(cls, name='tp', move_damage_class=None, generation=None):
2015-10-23 04:56:01 +00:00
move_damage_class = move_damage_class or cls.setup_move_damage_class_data(
name="mv dmg cls for " + name)
2015-10-23 04:56:01 +00:00
generation = generation or cls.setup_generation_data(
name='rgn for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
type = Type(
name=name,
generation=generation,
move_damage_class=move_damage_class
2015-10-23 04:56:01 +00:00
)
type.save()
return type
@classmethod
def setup_type_name_data(cls, type, name='tp nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
type_name = TypeName.objects.create(
language=language,
name=name,
type=type
2015-10-23 04:56:01 +00:00
)
type_name.save()
return type_name
2015-10-18 23:01:33 +00:00
@classmethod
def setup_type_game_index_data(cls, type, game_index=0):
generation = cls.setup_generation_data(
name='gen for tp gm indx')
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
type_game_index = TypeGameIndex.objects.create(
type=type,
game_index=game_index,
generation=generation
)
type_game_index.save()
return type_game_index
2016-03-05 11:40:41 +00:00
# Move Data
@classmethod
def setup_move_ailment_data(cls, name='mv almnt'):
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_ailment = MoveMetaAilment.objects.create(
name=name
)
move_ailment.save()
2015-10-18 23:01:33 +00:00
return move_ailment
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_ailment_name_data(cls, move_ailment, name='mv almnt nm'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_ailment_name = MoveMetaAilmentName.objects.create(
move_meta_ailment=move_ailment,
language=language,
name=name
)
move_ailment_name.save()
return move_ailment_name
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_battle_style_data(cls, name='mv btl stl'):
2016-03-05 11:40:41 +00:00
move_battle_style = MoveBattleStyle.objects.create(
name=name
)
move_battle_style.save()
return move_battle_style
@classmethod
def setup_move_battle_style_name_data(cls, move_battle_style, name='mv almnt nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
move_battle_style_name = MoveBattleStyleName.objects.create(
move_battle_style=move_battle_style,
language=language,
name=name
)
move_battle_style_name.save()
return move_battle_style_name
@classmethod
def setup_move_category_data(cls, name='mv ctgry'):
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_category = MoveMetaCategory.objects.create(
name=name
)
move_category.save()
2015-10-18 23:01:33 +00:00
return move_category
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_category_description_data(cls, move_category, description='mv ctgry desc'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + description)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_category_description = MoveMetaCategoryDescription.objects.create(
move_meta_category=move_category,
language=language,
description=description
)
move_category_description.save()
2015-10-18 23:01:33 +00:00
return move_category_description
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_effect_data(cls):
2016-03-05 11:40:41 +00:00
move_effect = MoveEffect.objects.create()
move_effect.save()
return move_effect
@classmethod
def setup_move_effect_effect_text_data(cls, move_effect, effect='mv efct efct txt',
2016-03-05 11:40:41 +00:00
short_effect='mv efct shrt efct txt'):
language = cls.setup_language_data(
name='lang for ' + effect)
2016-03-05 11:40:41 +00:00
effect_effect_text = MoveEffectEffectText.objects.create(
effect=effect,
short_effect=short_effect,
move_effect=move_effect,
language=language
)
effect_effect_text.save()
return effect_effect_text
@classmethod
def setup_move_damage_class_data(cls, name='mv dmg cls'):
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_damage_class = MoveDamageClass.objects.create(
name=name
)
move_damage_class.save()
2015-10-18 23:01:33 +00:00
return move_damage_class
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_damage_class_name_data(cls, move_damage_class, name='mv dmg cls nm'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_damage_class_name = MoveDamageClassName.objects.create(
move_damage_class=move_damage_class,
language=language,
name=name
)
move_damage_class_name.save()
2015-10-18 23:01:33 +00:00
return move_damage_class_name
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_damage_class_description_data(cls, move_damage_class,
2016-03-05 11:40:41 +00:00
description='mv dmg cls desc'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + description)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_damage_class_description = MoveDamageClassDescription.objects.create(
move_damage_class=move_damage_class,
language=language,
description=description
)
move_damage_class_description.save()
2015-10-18 23:01:33 +00:00
return move_damage_class_description
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_learn_method_data(cls, name='mv lrn mthd'):
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_learn_method = MoveLearnMethod.objects.create(
name=name
)
move_learn_method.save()
2015-10-18 23:01:33 +00:00
return move_learn_method
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_learn_method_name_data(cls, move_learn_method, name='mv lrn mthd nm'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_learn_method_name = MoveLearnMethodName.objects.create(
move_learn_method=move_learn_method,
language=language,
name=name
)
move_learn_method_name.save()
2015-10-18 23:01:33 +00:00
return move_learn_method_name
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_learn_method_description_data(cls, move_learn_method,
2016-03-05 11:40:41 +00:00
description='mv lrn mthd desc'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + description)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_learn_method_description = MoveLearnMethodDescription.objects.create(
move_learn_method=move_learn_method,
language=language,
description=description
)
move_learn_method_description.save()
2015-10-18 23:01:33 +00:00
return move_learn_method_description
2015-10-23 04:56:01 +00:00
@classmethod
def setup_move_target_data(cls, name='mv trgt'):
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
move_target = MoveTarget.objects.create(
name=name
)
move_target.save()
2015-10-23 04:56:01 +00:00
return move_target
2015-10-18 23:01:33 +00:00
@classmethod
def setup_move_target_name_data(cls, move_target, name='mv trgt nm'):
2015-10-18 23:01:33 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
move_target_name = MoveTargetName.objects.create(
move_target=move_target,
language=language,
name=name
)
move_target_name.save()
2015-10-23 04:56:01 +00:00
return move_target_name
2015-10-23 04:56:01 +00:00
@classmethod
def setup_move_target_description_data(cls, move_target, description='mv trgt desc'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + description)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
move_target_description = MoveTargetDescription.objects.create(
move_target=move_target,
language=language,
description=description
)
move_target_description.save()
2015-10-23 04:56:01 +00:00
return move_target_description
2015-10-23 04:56:01 +00:00
@classmethod
def setup_contest_combo_data(cls, first_move, second_move):
2016-03-05 11:40:41 +00:00
contest_combo = ContestCombo.objects.create(
first_move=first_move,
second_move=second_move
)
contest_combo.save()
return contest_combo
@classmethod
def setup_version_group_move_learn_method_data(cls, version_group=None,
2016-03-05 11:40:41 +00:00
move_learn_method=None):
2016-03-05 11:40:41 +00:00
version_group_move_learn_method = VersionGroupMoveLearnMethod.objects.create(
version_group=version_group,
move_learn_method=move_learn_method
)
version_group_move_learn_method.save()
return version_group_move_learn_method
@classmethod
def setup_super_contest_combo_data(cls, first_move, second_move):
2016-03-05 11:40:41 +00:00
super_contest_combo = SuperContestCombo.objects.create(
first_move=first_move,
second_move=second_move
)
super_contest_combo.save()
return super_contest_combo
@classmethod
def setup_move_flavor_text_data(cls, move, flavor_text='move flvr txt'):
version_group = cls.setup_version_group_data(
name='ver grp for ' + flavor_text)
language = cls.setup_language_data(
name='lang for ' + flavor_text)
move_flavor_text = MoveFlavorText.objects.create(
move=move,
version_group=version_group,
language=language,
flavor_text=flavor_text
)
move_flavor_text.save()
return move_flavor_text
@classmethod
def setup_move_data(cls, contest_type=None, contest_effect=None, super_contest_effect=None,
2016-03-05 11:40:41 +00:00
generation=None, move_damage_class=None, move_effect=None,
move_target=None, type=None, name='mv', power=20, pp=20,
accuracy=80, priority=0, effect_chance=50):
2015-10-23 04:56:01 +00:00
contest_type = contest_type or cls.setup_contest_type_data(
name='cntst tp for ' + name)
2015-10-23 04:56:01 +00:00
contest_effect = contest_effect or cls.setup_contest_effect_data()
super_contest_effect = super_contest_effect or cls.setup_super_contest_effect_data()
generation = generation or cls.setup_generation_data(
name='gen for ' + name)
2015-10-23 04:56:01 +00:00
type = type or cls.setup_type_data(
name='tp for ' + name)
2015-10-23 04:56:01 +00:00
move_target = move_target or cls.setup_move_target_data(
name='mv trgt for ' + name)
2015-10-23 04:56:01 +00:00
move_damage_class = move_damage_class or cls.setup_move_damage_class_data(
name='mv dmg cls for ' + name)
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
move = Move.objects.create(
name=name,
generation=generation,
type=type,
power=power,
pp=pp,
accuracy=accuracy,
priority=priority,
move_target=move_target,
move_damage_class=move_damage_class,
move_effect=move_effect,
move_effect_chance=effect_chance,
contest_type=contest_type,
contest_effect=contest_effect,
super_contest_effect=super_contest_effect
)
move.save()
2015-10-23 04:56:01 +00:00
return move
2015-10-23 04:56:01 +00:00
@classmethod
def setup_move_name_data(cls, move, name='mv nm'):
2015-10-23 04:56:01 +00:00
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
move_name = MoveName.objects.create(
move=move,
language=language,
name=name
)
move_name.save()
return move_name
@classmethod
def setup_move_meta_data(cls, move, move_ailment=None, move_category=None,
2016-03-05 11:40:41 +00:00
min_hits=1, max_hits=1, min_turns=1, max_turns=1,
drain=0, healing=0, crit_rate=0, ailment_chance=0,
flinch_chance=0, stat_chance=0):
move_ailment = move_ailment or cls.setup_move_ailment_data()
move_category = move_category or cls.setup_move_category_data()
2016-03-05 11:40:41 +00:00
move_meta = MoveMeta(
move=move,
move_meta_category=move_category,
move_meta_ailment=move_ailment,
min_hits=min_hits,
max_hits=max_hits,
min_turns=min_turns,
max_turns=max_turns,
drain=drain,
healing=healing,
crit_rate=crit_rate,
ailment_chance=ailment_chance,
flinch_chance=flinch_chance,
stat_chance=stat_chance
)
move_meta.save()
return move_meta
@classmethod
def setup_move_change_data(cls, move=None, type=None, move_effect=None,
2016-03-05 11:40:41 +00:00
version_group=None, power=20, pp=20, accuracy=80,
effect_chance=50):
version_group = version_group or cls.setup_version_group_data(
name='ver grp for mv chng')
2016-03-05 11:40:41 +00:00
move_change = MoveChange.objects.create(
move=move,
version_group=version_group,
type=type,
power=power,
pp=pp,
accuracy=accuracy,
move_effect=move_effect,
move_effect_chance=effect_chance
)
move_change.save()
return move_change
@classmethod
def setup_move_effect_change_data(cls, move_effect=None):
version_group = cls.setup_version_group_data(
name='ver grp for mv chng')
2016-03-05 11:40:41 +00:00
move_effect_change = MoveEffectChange.objects.create(
move_effect=move_effect,
version_group=version_group
)
move_effect_change.save()
return move_effect_change
@classmethod
def setup_move_effect_change_effect_text_data(cls, move_effect_change=None,
2016-03-05 11:40:41 +00:00
effect='mv efct chng efct txt'):
language = cls.setup_language_data(
name='lang for ' + effect)
2016-03-05 11:40:41 +00:00
move_effect_change_effect_text = MoveEffectChangeEffectText.objects.create(
move_effect_change=move_effect_change,
language=language,
effect=effect
)
move_effect_change_effect_text.save()
return move_effect_change_effect_text
2016-03-05 11:40:41 +00:00
# Stat Data
@classmethod
def setup_stat_data(cls, name='stt', is_battle_only=True, game_index=1):
move_damage_class = cls.setup_move_damage_class_data(
name='mv dmg cls for ' + name)
2016-03-05 11:40:41 +00:00
stat = Stat.objects.create(
name=name,
is_battle_only=is_battle_only,
move_damage_class=move_damage_class,
game_index=game_index
)
stat.save()
return stat
@classmethod
def setup_stat_name_data(cls, stat, name='stt nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
stat_name = StatName.objects.create(
stat=stat,
language=language,
name=name
)
stat_name.save()
return stat_name
@classmethod
def setup_move_stat_change_data(cls, move, stat=None, change=1):
stat = stat or cls.setup_stat_data(
name='stt for mv')
2016-03-05 11:40:41 +00:00
move_stat_change = MoveMetaStatChange.objects.create(
move=move,
stat=stat,
change=change
)
move_stat_change.save()
return move_stat_change
@classmethod
def setup_pokeathlon_stat_data(cls, name='pkathln stt'):
2016-03-05 11:40:41 +00:00
pokeathlon_stat = PokeathlonStat.objects.create(
name=name
)
pokeathlon_stat.save()
return pokeathlon_stat
@classmethod
def setup_pokeathlon_stat_name_data(cls, pokeathlon_stat, name='pkathln stt nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pokeathlon_stat_name = PokeathlonStatName.objects.create(
pokeathlon_stat=pokeathlon_stat,
language=language,
name=name
)
pokeathlon_stat_name.save()
return pokeathlon_stat_name
2016-03-05 11:40:41 +00:00
# Characteristic Data
@classmethod
def setup_characteristic_data(cls, gene_mod_5=0, stat=None):
stat = stat or cls.setup_stat_data(
name='stt for char')
2016-03-05 11:40:41 +00:00
characteristic = Characteristic.objects.create(
stat=stat,
gene_mod_5=gene_mod_5
)
characteristic.save()
return characteristic
@classmethod
def setup_characteristic_description_data(cls, characteristic, description='char desc'):
language = cls.setup_language_data(
name='lang for ' + description)
2016-03-05 11:40:41 +00:00
characteristic_description = CharacteristicDescription.objects.create(
characteristic=characteristic,
language=language,
description=description
)
characteristic_description.save()
return characteristic_description
2016-03-05 11:40:41 +00:00
# Nature Data
@classmethod
def setup_nature_data(cls, decreased_stat=None, increased_stat=None,
2016-03-05 11:40:41 +00:00
likes_flavor=None, hates_flavor=None, name='ntr', game_index=1):
2016-03-05 08:26:51 +00:00
2016-03-05 11:40:41 +00:00
nature = Nature.objects.create(
name=name,
decreased_stat=decreased_stat,
increased_stat=increased_stat,
hates_flavor=hates_flavor,
likes_flavor=likes_flavor,
game_index=game_index
)
nature.save()
return nature
@classmethod
def setup_nature_name_data(cls, nature, name='ntr nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
nature_name = NatureName.objects.create(
nature=nature,
language=language,
name=name
)
nature_name.save()
return nature_name
@classmethod
def setup_nature_pokeathlon_stat_data(cls, nature=None, pokeathlon_stat=None, max_change=1):
2016-03-05 08:26:51 +00:00
2016-03-05 11:40:41 +00:00
nature_pokeathlon_stat = NaturePokeathlonStat.objects.create(
nature=nature,
pokeathlon_stat=pokeathlon_stat,
max_change=max_change,
)
nature_pokeathlon_stat.save()
return nature_pokeathlon_stat
@classmethod
def setup_nature_battle_style_preference_data(cls, nature=None, move_battle_style=None,
2016-03-05 11:40:41 +00:00
low_hp_preference=10, high_hp_preference=20):
2016-03-05 08:26:51 +00:00
2016-03-05 11:40:41 +00:00
nature_battle_style_preference = NatureBattleStylePreference.objects.create(
nature=nature,
move_battle_style=move_battle_style,
low_hp_preference=low_hp_preference,
high_hp_preference=high_hp_preference
)
nature_battle_style_preference.save()
return nature_battle_style_preference
2016-03-05 11:40:41 +00:00
# Pokedex Data
@classmethod
def setup_pokedex_data(cls, region=None, name='pkdx'):
region = region or cls.setup_region_data(
name='rgn for ' + name)
2016-03-05 11:40:41 +00:00
pokedex = Pokedex.objects.create(
name=name,
region=region,
)
pokedex.save()
return pokedex
@classmethod
def setup_pokedex_name_data(cls, pokedex, name='pkdx nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pokedex_name = PokedexName.objects.create(
pokedex=pokedex,
language=language,
name=name
)
pokedex_name.save()
return pokedex_name
@classmethod
def setup_pokedex_description_data(cls, pokedex, description='pkdx desc'):
language = cls.setup_language_data(
name='lang for ' + description)
2016-03-05 11:40:41 +00:00
pokedex_description = PokedexDescription.objects.create(
pokedex=pokedex,
language=language,
description=description
)
pokedex_description.save()
return pokedex_description
@classmethod
def setup_pokedex_version_group_data(cls, pokedex, version_group=None):
version_group = version_group or cls.setup_language_data(
name='ver grp for pkdx')
2016-03-05 11:40:41 +00:00
pokedex_version_group = PokedexVersionGroup.objects.create(
pokedex=pokedex,
version_group=version_group
)
pokedex_version_group.save()
return pokedex_version_group
2016-03-05 11:40:41 +00:00
# Pokemon Data
@classmethod
def setup_pokemon_habitat_data(cls, name='pkm hbtt'):
2016-03-05 11:40:41 +00:00
pokemon_habitat = PokemonHabitat.objects.create(
name=name,
)
pokemon_habitat.save()
return pokemon_habitat
@classmethod
def setup_pokemon_habitat_name_data(cls, pokemon_habitat, name='pkm hbtt nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pokemon_habitat_name = PokemonHabitatName.objects.create(
pokemon_habitat=pokemon_habitat,
language=language,
name=name
)
pokemon_habitat_name.save()
return pokemon_habitat_name
@classmethod
def setup_pokemon_color_data(cls, name='pkm clr'):
2016-03-05 11:40:41 +00:00
pokemon_color = PokemonColor.objects.create(
name=name,
)
pokemon_color.save()
return pokemon_color
@classmethod
def setup_pokemon_color_name_data(cls, pokemon_color, name='pkm clr nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pokemon_color_name = PokemonColorName.objects.create(
pokemon_color=pokemon_color,
language=language,
name=name
)
pokemon_color_name.save()
return pokemon_color_name
@classmethod
def setup_pokemon_shape_data(cls, name='pkm shp'):
2016-03-05 11:40:41 +00:00
pokemon_shape = PokemonShape.objects.create(
name=name,
)
pokemon_shape.save()
return pokemon_shape
@classmethod
def setup_pokemon_shape_name_data(cls, pokemon_shape, name='pkm shp nm',
2016-03-05 11:40:41 +00:00
awesome_name='pkm shp awsm nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pokemon_shape_name = PokemonShapeName.objects.create(
pokemon_shape=pokemon_shape,
language=language,
name=name,
awesome_name=awesome_name
)
pokemon_shape_name.save()
return pokemon_shape_name
@classmethod
def setup_pokemon_species_form_description_data(cls, pokemon_species=None,
2016-03-05 11:40:41 +00:00
description='pkm spcs frm dscr'):
language = cls.setup_language_data(
name='lang for ' + description)
2016-03-05 11:40:41 +00:00
pokemon_species_form_description = PokemonSpeciesDescription.objects.create(
pokemon_species=pokemon_species,
language=language,
description=description
)
pokemon_species_form_description.save()
return pokemon_species_form_description
2016-02-25 04:55:59 +00:00
@classmethod
def setup_pokemon_species_flavor_text_data(cls, pokemon_species,
2016-03-05 11:40:41 +00:00
flavor_text='pkmn spcs flvr txt'):
2016-02-25 04:55:59 +00:00
version = cls.setup_version_data(
name='ver for ' + flavor_text)
2016-02-25 04:55:59 +00:00
language = cls.setup_language_data(
name='lang for ' + flavor_text)
2016-02-25 04:55:59 +00:00
2016-03-05 11:40:41 +00:00
pokemon_species_flavor_text = PokemonSpeciesFlavorText.objects.create(
pokemon_species=pokemon_species,
version=version,
language=language,
flavor_text=flavor_text
2016-02-25 04:55:59 +00:00
)
pokemon_species_flavor_text.save()
return pokemon_species_flavor_text
@classmethod
def setup_pokemon_species_data(cls, generation=None, evolves_from_species=None,
2016-03-05 11:40:41 +00:00
evolution_chain=None, growth_rate=None, pokemon_color=None,
pokemon_habitat=None, pokemon_shape=None, name='pkm spcs',
gender_rate=50, capture_rate=20, base_happiness=20,
is_baby=False, hatch_counter=10, has_gender_differences=True,
forms_switchable=False, order=1):
generation = generation or cls.setup_generation_data(
name='gen for ' + name)
growth_rate = growth_rate or cls.setup_growth_rate_data(
name='grth rt for ' + name)
pokemon_shape = pokemon_shape or cls.setup_pokemon_shape_data(
name='pkmn shp for ' + name)
pokemon_color = pokemon_color or cls.setup_pokemon_color_data(
name='pkmn clr for ' + name)
pokemon_habitat = pokemon_habitat or cls.setup_pokemon_habitat_data(
name='pkm hbtt for ' + name)
2016-03-05 11:40:41 +00:00
pokemon_species = PokemonSpecies.objects.create(
name=name,
generation=generation,
evolves_from_species=evolves_from_species,
evolution_chain=evolution_chain,
pokemon_color=pokemon_color,
pokemon_shape=pokemon_shape,
pokemon_habitat=pokemon_habitat,
gender_rate=gender_rate,
capture_rate=capture_rate,
base_happiness=base_happiness,
is_baby=is_baby,
hatch_counter=hatch_counter,
has_gender_differences=has_gender_differences,
growth_rate=growth_rate,
forms_switchable=forms_switchable,
order=order
)
pokemon_species.save()
return pokemon_species
@classmethod
def setup_pokemon_species_name_data(cls, pokemon_species, name='pkmn spcs nm',
2016-03-05 11:40:41 +00:00
genus='pkmn spcs gns'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pokemon_species_name = PokemonSpeciesName.objects.create(
pokemon_species=pokemon_species,
language=language,
name=name,
genus=genus
)
pokemon_species_name.save()
return pokemon_species_name
@classmethod
def setup_pokemon_dex_entry_data(cls, pokemon_species, pokedex, entry_number=100):
2016-03-05 11:40:41 +00:00
dex_number = PokemonDexNumber(
pokemon_species=pokemon_species,
pokedex=pokedex,
pokedex_number=entry_number
)
dex_number.save()
return dex_number
@classmethod
def setup_pokemon_egg_group_data(cls, pokemon_species, egg_group):
2016-03-05 11:40:41 +00:00
pokemon_egg_group = PokemonEggGroup(
pokemon_species=pokemon_species,
egg_group=egg_group
)
pokemon_egg_group.save()
return pokemon_egg_group
2016-03-05 08:26:51 +00:00
@classmethod
def setup_pokemon_data(cls, pokemon_species=None, name='pkmn',
2016-03-05 11:40:41 +00:00
height=100, weight=100, base_experience=0, order=1, is_default=False):
pokemon_species = pokemon_species or cls.setup_pokemon_species_data(
name='pkmn spcs for ' + name)
2016-03-05 11:40:41 +00:00
pokemon = Pokemon.objects.create(
name=name,
pokemon_species=pokemon_species,
height=height,
weight=weight,
base_experience=base_experience,
order=order,
is_default=is_default
)
pokemon.save()
return pokemon
@classmethod
def setup_pokemon_game_index_data(cls, pokemon, game_index=0):
version = cls.setup_version_data(
name='ver for pkmn gm indx')
2016-03-05 11:40:41 +00:00
pokemon_game_index = PokemonGameIndex.objects.create(
pokemon=pokemon,
game_index=game_index,
version=version
)
pokemon_game_index.save()
return pokemon_game_index
@classmethod
def setup_pokemon_form_sprites_data(
cls, pokemon_form,
front_default=True, front_shiny=False,
back_default=False, back_shiny=False):
sprite_path = '/media/sprites/pokemon/%s.png'
sprites = {
2016-03-05 11:40:41 +00:00
'front_default': sprite_path % pokemon_form.id if front_default else None,
'front_shiny': sprite_path % pokemon_form.id if front_shiny else None,
'back_default': sprite_path % pokemon_form.id if back_default else None,
'back_shiny': sprite_path % pokemon_form.id if back_shiny else None,
}
2016-03-05 11:40:41 +00:00
pokemon_form_sprites = PokemonFormSprites.objects.create(
pokemon_form=pokemon_form,
sprites=json.dumps(sprites)
)
pokemon_form_sprites.save()
return pokemon_form_sprites
@classmethod
def setup_pokemon_form_data(cls, pokemon, name='pkmn nrml frm',
2016-03-05 11:40:41 +00:00
form_name='nrml', order=1, is_default=True,
is_battle_only=True, form_order=1, is_mega=False):
version_group = cls.setup_version_group_data(
name='ver grp for ' + name)
2016-03-05 11:40:41 +00:00
pokemon_form = PokemonForm(
name=name,
form_name=form_name,
pokemon=pokemon,
version_group=version_group,
is_default=is_default,
is_battle_only=is_battle_only,
is_mega=is_mega,
form_order=form_order,
order=order
)
pokemon_form.save()
return pokemon_form
@classmethod
def setup_pokemon_ability_data(cls, pokemon, ability=None, is_hidden=False, slot=1):
ability = ability or cls.setup_ability_data(name='ablty for pkmn')
2016-03-05 11:40:41 +00:00
pokemon_ability = PokemonAbility(
pokemon=pokemon,
ability=ability,
is_hidden=is_hidden,
slot=slot
)
pokemon_ability.save()
return pokemon_ability
@classmethod
def setup_pokemon_stat_data(cls, pokemon, base_stat=10, effort=10):
stat = cls.setup_stat_data(
name='stt for pkmn')
2016-03-05 11:40:41 +00:00
pokemon_stat = PokemonStat(
pokemon=pokemon,
stat=stat,
base_stat=base_stat,
effort=effort
)
pokemon_stat.save()
return pokemon_stat
@classmethod
def setup_pokemon_type_data(cls, pokemon, type=None, slot=1):
type = type or cls.setup_type_data(
name='tp for pkmn')
2016-03-05 11:40:41 +00:00
pokemon_type = PokemonType(
pokemon=pokemon,
type=type,
slot=slot
)
pokemon_type.save()
return pokemon_type
@classmethod
def setup_pokemon_item_data(cls, pokemon=None, item=None, version=None, rarity=50):
item = item or cls.setup_item_data(
name='itm for pkmn')
pokemon = pokemon or cls.setup_pokemon_data(
name='pkmn for pkmn')
version = version or cls.setup_version_data(
name='ver grp for pkmn itm')
2016-03-05 11:40:41 +00:00
pokemon_item = PokemonItem(
pokemon=pokemon,
version=version,
item=item,
rarity=rarity
)
pokemon_item.save()
return pokemon_item
@classmethod
def setup_pokemon_move_data(cls, pokemon, move, version_group, level=0, order=1):
move_learn_method = cls.setup_move_learn_method_data(
name='mv lrn mthd for pkmn')
2016-03-05 11:40:41 +00:00
pokemon_move = PokemonMove.objects.create(
pokemon=pokemon,
version_group=version_group,
move=move,
move_learn_method=move_learn_method,
level=level,
order=order
)
pokemon_move.save()
return pokemon_move
@classmethod
def setup_pokemon_sprites_data(
cls, pokemon, front_default=True,
front_female=False, front_shiny=False,
front_shiny_female=False, back_default=False,
back_female=False, back_shiny=False,
back_shiny_female=False):
sprite_path = '/media/sprites/pokemon/%s.png'
sprites = {
2016-03-05 11:40:41 +00:00
'front_default': sprite_path % pokemon.id if front_default else None,
'front_female': sprite_path % pokemon.id if front_female else None,
'front_shiny': sprite_path % pokemon.id if front_shiny else None,
'front_shiny_female': sprite_path % pokemon.id if front_shiny_female else None,
'back_default': sprite_path % pokemon.id if back_default else None,
'back_female': sprite_path % pokemon.id if back_female else None,
'back_shiny': sprite_path % pokemon.id if back_shiny else None,
'back_shiny_female': sprite_path % pokemon.id if back_shiny_female else None,
}
2016-03-05 11:40:41 +00:00
pokemon_sprites = PokemonSprites.objects.create(
pokemon=pokemon,
sprites=json.dumps(sprites)
)
pokemon_sprites.save()
return pokemon_sprites
2016-03-05 11:40:41 +00:00
# Evolution Data
@classmethod
def setup_evolution_trigger_data(cls, name='evltn trgr'):
2016-03-05 11:40:41 +00:00
evolution_trigger = EvolutionTrigger.objects.create(
name=name,
)
evolution_trigger.save()
return evolution_trigger
@classmethod
def setup_evolution_trigger_name_data(cls, evolution_trigger, name='evltn trgr nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
evolution_trigger_name = EvolutionTriggerName.objects.create(
evolution_trigger=evolution_trigger,
language=language,
name=name
)
evolution_trigger_name.save()
return evolution_trigger_name
@classmethod
def setup_evolution_chain_data(cls, baby_trigger_item=None):
2016-03-05 11:40:41 +00:00
evolution_chain = EvolutionChain.objects.create(
baby_trigger_item=baby_trigger_item,
)
evolution_chain.save()
return evolution_chain
@classmethod
def setup_pokemon_evolution_data(cls, evolved_species=None, evolution_trigger=None,
2016-03-05 11:40:41 +00:00
party_species=None, trade_species=None, evolution_item=None,
party_type=None, min_level=0, gender=None, location=None,
held_item=None, time_of_day='', known_move=None,
known_move_type=None, min_happiness=0, min_beauty=0,
min_affection=0, relative_physical_stats=0,
needs_overworld_rain=False, turn_upside_down=False):
evolved_species = evolved_species or cls.setup_pokemon_species_data(
name='pkmn spcs for pkmn evltn')
evolution_trigger = evolution_trigger or cls.setup_evolution_trigger_data(
name='evltn trgr for pkmn evltn')
2016-03-05 11:40:41 +00:00
pokemon_evolution = PokemonEvolution.objects.create(
evolved_species=evolved_species,
evolution_trigger=evolution_trigger,
evolution_item=evolution_item,
min_level=min_level,
gender=gender,
location=location,
held_item=held_item,
time_of_day=time_of_day,
known_move=known_move,
known_move_type=known_move_type,
min_happiness=min_happiness,
min_beauty=min_beauty,
min_affection=min_affection,
relative_physical_stats=relative_physical_stats,
party_species=party_species,
party_type=party_type,
trade_species=trade_species,
needs_overworld_rain=needs_overworld_rain,
turn_upside_down=turn_upside_down
)
pokemon_evolution.save()
return pokemon_evolution
2016-03-05 11:40:41 +00:00
# Encounter Data
@classmethod
def setup_encounter_method_data(cls, name='encntr mthd', order=0):
2016-03-05 11:40:41 +00:00
encounter_method = EncounterMethod.objects.create(
name=name,
order=order
)
encounter_method.save()
return encounter_method
2016-03-05 11:40:41 +00:00
@classmethod
def setup_encounter_method_name_data(cls, encounter_method, name='encntr mthd nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
encounter_method_name = EncounterMethodName.objects.create(
encounter_method=encounter_method,
language=language,
name=name
)
encounter_method_name.save()
return encounter_method_name
@classmethod
def setup_encounter_condition_data(cls, name='encntr cndtn'):
2016-03-05 11:40:41 +00:00
encounter_condition = EncounterCondition.objects.create(
name=name
)
encounter_condition.save()
return encounter_condition
@classmethod
def setup_encounter_condition_name_data(cls, encounter_condition, name='encntr cndtn nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
encounter_condition_name = EncounterConditionName.objects.create(
encounter_condition=encounter_condition,
language=language,
name=name
)
encounter_condition_name.save()
return encounter_condition_name
@classmethod
def setup_encounter_condition_value_data(cls, encounter_condition,
2016-03-05 11:40:41 +00:00
name='encntr cndtn vlu', is_default=False):
2016-03-05 11:40:41 +00:00
encounter_condition_value = EncounterConditionValue.objects.create(
encounter_condition=encounter_condition,
name=name,
is_default=is_default
)
encounter_condition_value.save()
return encounter_condition_value
@classmethod
def setup_encounter_condition_value_name_data(cls, encounter_condition_value,
2016-03-05 11:40:41 +00:00
name='encntr cndtn vlu nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
encounter_condition_value_name = EncounterConditionValueName.objects.create(
encounter_condition_value=encounter_condition_value,
language=language,
name=name
)
encounter_condition_value_name.save()
return encounter_condition_value_name
@classmethod
def setup_encounter_condition_value_map_data(cls, encounter, encounter_condition_value):
2016-03-05 11:40:41 +00:00
encounter_condition_value_map = EncounterConditionValue.objects.create(
encounter=encounter,
encounter_condition_value=encounter_condition_value
)
encounter_condition_value_map.save()
return encounter_condition_value_map
@classmethod
def setup_encounter_slot_data(cls, encounter_method=None, slot=0, rarity=0):
encounter_method = encounter_method or cls.setup_encounter_method_data(
name='encntr mthd for encntr slt')
version_group = cls.setup_version_group_data(
name='ver grp for encntr slt')
2016-03-05 11:40:41 +00:00
encounter_slot = EncounterSlot.objects.create(
encounter_method=encounter_method,
version_group=version_group,
slot=slot,
rarity=rarity
)
encounter_slot.save()
return encounter_slot
@classmethod
def setup_location_area_encounter_rate_data(cls, location_area, encounter_method, rate=0):
version = cls.setup_version_data(
name='ver for lctn area')
2016-03-05 11:40:41 +00:00
location_area_encounter_rate = LocationAreaEncounterRate.objects.create(
encounter_method=encounter_method,
version=version,
location_area=location_area,
rate=rate
)
location_area_encounter_rate.save()
return location_area_encounter_rate
@classmethod
def setup_encounter_data(cls, location_area=None, encounter_slot=None,
2016-03-05 11:40:41 +00:00
pokemon=None, version=None, min_level=10, max_level=15):
location_area = location_area or cls.setup_location_area_data(
name='ver for encntr')
encounter_slot = encounter_slot or cls.setup_encounter_slot_data()
pokemon = pokemon or cls.setup_pokemon_data(
name='pkmn for encntr')
version = version or cls.setup_version_data(
name='ver for encntr')
2016-03-05 11:40:41 +00:00
encounter = Encounter.objects.create(
version=version,
location_area=location_area,
encounter_slot=encounter_slot,
pokemon=pokemon,
min_level=min_level,
max_level=max_level
)
encounter.save()
return encounter
2016-03-05 11:40:41 +00:00
# Pal Park Data
@classmethod
def setup_pal_park_area_data(cls, name='pl prk area'):
2016-03-05 11:40:41 +00:00
pal_park_area = PalParkArea.objects.create(
name=name
)
pal_park_area.save()
return pal_park_area
2016-03-05 11:40:41 +00:00
@classmethod
def setup_pal_park_area_name_data(cls, pal_park_area, name='pl prk area nm'):
language = cls.setup_language_data(
name='lang for ' + name)
2016-03-05 11:40:41 +00:00
pal_park_area_name = PalParkAreaName.objects.create(
pal_park_area=pal_park_area,
language=language,
name=name
)
pal_park_area_name.save()
return pal_park_area_name
@classmethod
def setup_pal_park_data(cls, pokemon_species=None, pal_park_area=None, base_score=10, rate=10):
pal_park_area = pal_park_area or cls.setup_pal_park_area_data(
name='pl prk area')
2016-03-05 11:40:41 +00:00
pal_park = PalPark.objects.create(
base_score=base_score,
pokemon_species=pokemon_species,
pal_park_area=pal_park_area,
rate=rate
)
pal_park.save()
return pal_park
2016-03-05 11:40:41 +00:00
# Tests
class APITests(APIData, APITestCase):
# Gender Tests
def test_gender_api(self):
gender = self.setup_gender_data(name='female')
pokemon_species = self.setup_pokemon_species_data(name='pkmn spcs for gndr', gender_rate=8)
evolved_species = self.setup_pokemon_species_data(name='evlvd pkmn spcs for gndr')
self.setup_pokemon_evolution_data(evolved_species=evolved_species, gender=gender)
response = self.client.get('{}/gender/{}/'.format(API_V2, gender.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], gender.pk)
self.assertEqual(response.data['name'], gender.name)
# species params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species_details'][0]['rate'], pokemon_species.gender_rate)
self.assertEqual(
response.data['pokemon_species_details'][0]['pokemon_species']['name'],
pokemon_species.name)
self.assertEqual(
response.data['pokemon_species_details'][0]['pokemon_species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['required_for_evolution'][0]['name'], evolved_species.name)
self.assertEqual(
response.data['required_for_evolution'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, evolved_species.pk))
2016-03-05 11:40:41 +00:00
# Language Tests
def test_language_api(self):
language = self.setup_language_data(name='base lang')
language_name = self.setup_language_name_data(language, name='base lang name')
response = self.client.get('{}/language/{}/'.format(API_V2, language.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], language.pk)
self.assertEqual(response.data['iso639'], language.iso639)
self.assertEqual(response.data['iso3166'], language.iso3166)
self.assertEqual(response.data['name'], language.name)
self.assertEqual(response.data['official'], language.official)
2016-03-05 11:40:41 +00:00
# name params
self.assertEqual(response.data['names'][0]['name'], language_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], language_name.local_language.name)
self.assertEqual(
response.data['names'][0]['language']['url'], '{}{}/language/{}/'.format(
TEST_HOST, API_V2, language_name.local_language.pk))
2016-03-05 11:40:41 +00:00
# Region Tests
def test_region_api(self):
region = self.setup_region_data(name='base reg')
region_name = self.setup_region_name_data(region, name='base reg name')
location = self.setup_location_data(region=region, name="lctn for base rgn")
generation = self.setup_generation_data(region=region, name="gnrtn for base rgn")
pokedex = self.setup_pokedex_data(region=region, name="pkdx for base rgn")
version_group = self.setup_version_group_data(name="ver grp for base rgn")
2016-03-05 11:40:41 +00:00
self.setup_version_group_region_data(region=region, version_group=version_group)
response = self.client.get('{}/region/{}/'.format(API_V2, region.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], region.pk)
self.assertEqual(response.data['name'], region.name)
# name params
self.assertEqual(response.data['names'][0]['name'], region_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], region_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, region_name.language.pk))
# location params
self.assertEqual(response.data['locations'][0]['name'], location.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['locations'][0]['url'],
'{}{}/location/{}/'.format(TEST_HOST, API_V2, location.pk))
# generation params
self.assertEqual(response.data['main_generation']['name'], generation.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['main_generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, generation.pk))
# pokedex params
self.assertEqual(response.data['pokedexes'][0]['name'], pokedex.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokedexes'][0]['url'],
'{}{}/pokedex/{}/'.format(TEST_HOST, API_V2, pokedex.pk))
# version group params
self.assertEqual(response.data['version_groups'][0]['name'], version_group.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['version_groups'][0]['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version_group.pk))
2016-03-05 11:40:41 +00:00
# Generation Tests
def test_generation_api(self):
generation = self.setup_generation_data(name='base gen')
generation_name = self.setup_generation_name_data(generation, name='base reg name')
ability = self.setup_ability_data(name='ablty for base gen', generation=generation)
move = self.setup_move_data(name='mv for base gen', generation=generation)
2016-03-05 11:40:41 +00:00
pokemon_species = self.setup_pokemon_species_data(
name='pkmn spcs for base gen', generation=generation)
type = self.setup_type_data(name='tp for base gen', generation=generation)
2016-03-05 11:40:41 +00:00
version_group = self.setup_version_group_data(
name='ver grp for base gen', generation=generation)
response = self.client.get('{}/generation/{}/'.format(API_V2, generation.pk))
# base params
self.assertEqual(response.data['id'], generation.pk)
self.assertEqual(response.data['name'], generation.name)
# name params
self.assertEqual(response.data['names'][0]['name'], generation_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], generation_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, generation_name.language.pk))
# region params
self.assertEqual(response.data['main_region']['name'], generation.region.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['main_region']['url'],
'{}{}/region/{}/'.format(TEST_HOST, API_V2, generation.region.pk))
2016-03-05 11:40:41 +00:00
# ability params
self.assertEqual(response.data['abilities'][0]['name'], ability.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['abilities'][0]['url'],
'{}{}/ability/{}/'.format(TEST_HOST, API_V2, ability.pk))
2016-03-05 11:40:41 +00:00
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
2016-03-05 11:40:41 +00:00
# type params
self.assertEqual(response.data['types'][0]['name'], type.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['types'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, type.pk))
2016-03-05 11:40:41 +00:00
# species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
2016-03-05 11:40:41 +00:00
# version group params
self.assertEqual(response.data['version_groups'][0]['name'], version_group.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['version_groups'][0]['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version_group.pk))
2016-03-05 11:40:41 +00:00
# Version Tests
def test_version_api(self):
version_group = self.setup_version_group_data(name='ver grp for ver')
version = self.setup_version_data(name='base ver', version_group=version_group)
version_name = self.setup_version_name_data(version, name='base ver name')
response = self.client.get('{}/version/{}/'.format(API_V2, version.pk))
# base params
self.assertEqual(response.data['id'], version.pk)
self.assertEqual(response.data['name'], version.name)
# name params
self.assertEqual(response.data['names'][0]['name'], version_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], version_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, version_name.language.pk))
# version group params
self.assertEqual(response.data['version_group']['name'], version.version_group.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version.version_group.pk))
def test_version_group_api(self):
version_group = self.setup_version_group_data(name='base ver grp')
move_learn_method = self.setup_move_learn_method_data(name='mv lrn mthd for ')
2016-03-05 11:40:41 +00:00
self.setup_version_group_move_learn_method_data(
version_group=version_group, move_learn_method=move_learn_method)
region = self.setup_region_data(name='rgn for ver grp')
version = self.setup_version_data(name='ver for base ver grp', version_group=version_group)
2016-03-05 11:40:41 +00:00
self.setup_version_group_region_data(version_group=version_group, region=region)
pokedex = self.setup_pokedex_data(name='pkdx for base ver group')
2016-03-05 11:40:41 +00:00
self.setup_pokedex_version_group_data(pokedex=pokedex, version_group=version_group)
response = self.client.get('{}/version-group/{}/'.format(API_V2, version_group.pk))
# base params
self.assertEqual(response.data['id'], version_group.pk)
self.assertEqual(response.data['name'], version_group.name)
self.assertEqual(response.data['order'], version_group.order)
# version params
self.assertEqual(response.data['versions'][0]['name'], version.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['versions'][0]['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, version.pk))
# generation params
self.assertEqual(response.data['generation']['name'], version_group.generation.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, version_group.generation.pk))
# region params
self.assertEqual(response.data['regions'][0]['name'], region.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['regions'][0]['url'],
'{}{}/region/{}/'.format(TEST_HOST, API_V2, region.pk))
# move learn method params
self.assertEqual(response.data['move_learn_methods'][0]['name'], move_learn_method.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['move_learn_methods'][0]['url'],
'{}{}/move-learn-method/{}/'.format(TEST_HOST, API_V2, move_learn_method.pk))
# pokedex group
self.assertEqual(response.data['pokedexes'][0]['name'], pokedex.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokedexes'][0]['url'],
'{}{}/pokedex/{}/'.format(TEST_HOST, API_V2, pokedex.pk))
2016-03-05 11:40:41 +00:00
# Egg Group Tests
def test_egg_group_api(self):
egg_group = self.setup_egg_group_data(name='base egg grp')
egg_group_name = self.setup_egg_group_name_data(egg_group, name='base egg grp name')
pokemon_species = self.setup_pokemon_species_data()
self.setup_pokemon_egg_group_data(pokemon_species=pokemon_species, egg_group=egg_group)
response = self.client.get('{}/egg-group/{}/'.format(API_V2, egg_group.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], egg_group.pk)
self.assertEqual(response.data['name'], egg_group.name)
# name params
self.assertEqual(response.data['names'][0]['name'], egg_group_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], egg_group_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, egg_group_name.language.pk))
# species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
2016-03-05 11:40:41 +00:00
# Ability Tests
def test_ability_api(self):
ability = self.setup_ability_data(name='base ablty')
ability_name = self.setup_ability_name_data(ability, name='base ablty name')
ability_effect_text = self.setup_ability_effect_text_data(ability, effect='base ablty efct')
2016-03-05 11:40:41 +00:00
ability_flavor_text = self.setup_ability_flavor_text_data(
ability, flavor_text='base flvr txt')
ability_change = self.setup_ability_change_data(ability)
2016-03-05 11:40:41 +00:00
ability_change_effect_text = self.setup_ability_change_effect_text_data(
ability_change, effect='base ablty chng efct')
pokemon = self.setup_pokemon_data(name='pkmn for ablty')
pokemon_ability = self.setup_pokemon_ability_data(ability=ability, pokemon=pokemon)
response = self.client.get('{}/ability/{}/'.format(API_V2, ability.pk))
2016-03-05 08:26:51 +00:00
# base params
self.assertEqual(response.data['id'], ability.pk)
self.assertEqual(response.data['name'], ability.name)
self.assertEqual(response.data['is_main_series'], ability.is_main_series)
# name params
self.assertEqual(response.data['names'][0]['name'], ability_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], ability_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_name.language.pk))
2015-10-23 04:56:01 +00:00
# description params
self.assertEqual(response.data['effect_entries'][0]['effect'], ability_effect_text.effect)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_entries'][0]['short_effect'], ability_effect_text.short_effect)
self.assertEqual(
response.data['effect_entries'][0]['language']['name'],
ability_effect_text.language.name)
self.assertEqual(
response.data['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_effect_text.language.pk))
# flavor text params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['flavor_text'], ability_flavor_text.flavor_text)
self.assertEqual(
response.data['flavor_text_entries'][0]['version_group']['name'],
ability_flavor_text.version_group.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['name'],
ability_flavor_text.language.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_flavor_text.language.pk))
# generation params
self.assertEqual(response.data['generation']['name'], ability.generation.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['generation']['url'], '{}{}/generation/{}/'.format(
TEST_HOST, API_V2, ability.generation.pk))
# change params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_changes'][0]['version_group']['name'],
ability_change.version_group.name)
self.assertEqual(
response.data['effect_changes'][0]['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, ability_change.version_group.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_changes'][0]['effect_entries'][0]['effect'],
ability_change_effect_text.effect)
self.assertEqual(
response.data['effect_changes'][0]['effect_entries'][0]['language']['name'],
ability_change_effect_text.language.name)
self.assertEqual(
response.data['effect_changes'][0]['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_change_effect_text.language.pk))
# pokemon params
self.assertEqual(response.data['pokemon'][0]['is_hidden'], pokemon_ability.is_hidden)
self.assertEqual(response.data['pokemon'][0]['slot'], pokemon_ability.slot)
self.assertEqual(response.data['pokemon'][0]['pokemon']['name'], pokemon.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon'][0]['pokemon']['url'],
'{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk))
2016-03-05 11:40:41 +00:00
# Item Tests
def test_item_attribute_api(self):
# item attribute data
item_attribute = self.setup_item_attribute_data(name='base itm attr')
2016-03-05 11:40:41 +00:00
item_attribute_name = self.setup_item_attribute_name_data(
item_attribute, name='base itm attr nm')
item_attribute_description = self.setup_item_attribute_description_data(
item_attribute, description='base itm attr desc')
item = self.setup_item_data(name='itm fr base itm attr')
self.setup_item_attribute_map_data(item_attribute=item_attribute, item=item)
response = self.client.get('{}/item-attribute/{}/'.format(API_V2, item_attribute.pk))
2015-10-23 04:56:01 +00:00
# base params
self.assertEqual(response.data['id'], item_attribute.pk)
self.assertEqual(response.data['name'], item_attribute.name)
# name params
self.assertEqual(response.data['names'][0]['name'], item_attribute_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], item_attribute_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_attribute_name.language.pk))
# description params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'], item_attribute_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
item_attribute_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_attribute_description.language.pk))
# item params
self.assertEqual(response.data['items'][0]['name'], item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['items'][0]['url'], '{}{}/item/{}/'.format(TEST_HOST, API_V2, item.pk))
def test_item_category_api(self):
# item category data
item_category = self.setup_item_category_data(name='base itm ctgry')
2016-03-05 11:40:41 +00:00
item_category_name = self.setup_item_category_name_data(
item_category, name='base itm ctgry nm')
item = self.setup_item_data(item_category=item_category, name='itm fr base itm ctgry')
response = self.client.get('{}/item-category/{}/'.format(API_V2, item_category.pk))
# base params
self.assertEqual(response.data['id'], item_category.pk)
self.assertEqual(response.data['name'], item_category.name)
# name params
self.assertEqual(response.data['names'][0]['name'], item_category_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], item_category_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_category_name.language.pk))
# pocket params
self.assertEqual(response.data['pocket']['name'], item_category.item_pocket.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pocket']['url'],
'{}{}/item-pocket/{}/'.format(TEST_HOST, API_V2, item_category.item_pocket.pk))
# item params
self.assertEqual(response.data['items'][0]['name'], item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['items'][0]['url'], '{}{}/item/{}/'.format(TEST_HOST, API_V2, item.pk))
def test_item_fling_effect_api(self):
# item category data
item_fling_effect = self.setup_item_fling_effect_data(name='base itm flng efct')
2016-03-05 11:40:41 +00:00
item_fling_effect_effect_text = self.setup_item_fling_effect_effect_text_data(
item_fling_effect, effect='base itm flng efct nm')
item = self.setup_item_data(
item_fling_effect=item_fling_effect, name='itm fr base itm attr')
2015-10-23 04:56:01 +00:00
response = self.client.get('{}/item-fling-effect/{}/'.format(API_V2, item_fling_effect.pk))
2015-10-23 04:56:01 +00:00
# base params
self.assertEqual(response.data['id'], item_fling_effect.pk)
self.assertEqual(response.data['name'], item_fling_effect.name)
# description params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_entries'][0]['effect'], item_fling_effect_effect_text.effect)
self.assertEqual(
response.data['effect_entries'][0]['language']['name'],
item_fling_effect_effect_text.language.name)
self.assertEqual(
response.data['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_fling_effect_effect_text.language.pk)
2016-03-05 11:40:41 +00:00
)
# item params
self.assertEqual(response.data['items'][0]['name'], item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['items'][0]['url'], '{}{}/item/{}/'.format(TEST_HOST, API_V2, item.pk))
2015-10-18 23:01:33 +00:00
def test_item_pocket_api(self):
2015-10-23 04:56:01 +00:00
# item pocket data
item_pocket = self.setup_item_pocket_data(name='base itm pkt')
item_pocket_name = self.setup_item_pocket_name_data(item_pocket, name='base itm pkt nm')
response = self.client.get('{}/item-pocket/{}/'.format(API_V2, item_pocket.pk))
2015-10-23 04:56:01 +00:00
# base params
self.assertEqual(response.data['id'], item_pocket.pk)
self.assertEqual(response.data['name'], item_pocket.name)
# name params
self.assertEqual(response.data['names'][0]['name'], item_pocket_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], item_pocket_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_pocket_name.language.pk))
2015-10-18 23:01:33 +00:00
2015-10-23 04:56:01 +00:00
def test_item_api(self):
2015-10-18 23:01:33 +00:00
2015-10-23 04:56:01 +00:00
item_category = self.setup_item_category_data(name='itm ctgry for base itm')
item_fling_effect = self.setup_item_fling_effect_data(name='itm flng efct for base itm')
item = self.setup_item_data(item_category, item_fling_effect, name='base itm')
item_name = self.setup_item_name_data(item, name='base itm name')
item_flavor_text = self.setup_item_flavor_text_data(item, flavor_text='base itm flvr txt')
2016-03-05 11:40:41 +00:00
item_effect_text = self.setup_item_effect_text_data(
item, effect='base nrml efct', short_effect='base shrt efct')
2015-10-23 04:56:01 +00:00
item_attribute = self.setup_item_attribute_data()
item_game_index = self.setup_item_game_index_data(item, game_index=10)
item_sprites = self.setup_item_sprites_data(item)
pokemon = self.setup_pokemon_data(name='pkmn for base itm')
pokemon_item = self.setup_pokemon_item_data(pokemon=pokemon, item=item)
evolution_chain = self.setup_evolution_chain_data(baby_trigger_item=item)
2015-10-23 04:56:01 +00:00
# map item attribute to item
2016-03-05 11:40:41 +00:00
item_attribute_map = ItemAttributeMap(
item=item,
item_attribute=item_attribute
)
2015-10-23 04:56:01 +00:00
item_attribute_map.save()
sprites_data = json.loads(item_sprites.sprites)
response = self.client.get('{}/item/{}/'.format(API_V2, item.pk), HTTP_HOST='testserver')
2016-03-05 08:26:51 +00:00
2015-10-18 23:01:33 +00:00
# base params
2015-10-23 04:56:01 +00:00
self.assertEqual(response.data['id'], item.pk)
self.assertEqual(response.data['name'], item.name)
self.assertEqual(response.data['cost'], item.cost)
self.assertEqual(response.data['fling_power'], item.fling_power)
2015-10-18 23:01:33 +00:00
# name params
2015-10-23 04:56:01 +00:00
self.assertEqual(response.data['names'][0]['name'], item_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], item_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_name.language.pk))
2015-10-23 04:56:01 +00:00
# flavor text params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['text'], item_flavor_text.flavor_text)
self.assertEqual(
response.data['flavor_text_entries'][0]['version_group']['name'],
item_flavor_text.version_group.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, item_flavor_text.version_group.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['name'],
item_flavor_text.language.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_flavor_text.language.pk))
# effect text params
self.assertEqual(response.data['effect_entries'][0]['effect'], item_effect_text.effect)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_entries'][0]['short_effect'], item_effect_text.short_effect)
self.assertEqual(
response.data['effect_entries'][0]['language']['name'], item_effect_text.language.name)
self.assertEqual(
response.data['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, item_effect_text.language.pk))
2015-10-23 04:56:01 +00:00
# category params
self.assertEqual(response.data['category']['name'], item_category.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['category']['url'],
'{}{}/item-category/{}/'.format(TEST_HOST, API_V2, item_category.pk))
2015-10-23 04:56:01 +00:00
# fling effect params
self.assertEqual(response.data['fling_effect']['name'], item_fling_effect.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['fling_effect']['url'],
'{}{}/item-fling-effect/{}/'.format(TEST_HOST, API_V2, item_fling_effect.pk))
2015-10-23 04:56:01 +00:00
# attribute params
self.assertEqual(response.data['attributes'][0]['name'], item_attribute.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['attributes'][0]['url'],
'{}{}/item-attribute/{}/'.format(TEST_HOST, API_V2, item_attribute.pk))
# game indices params
self.assertEqual(response.data['game_indices'][0]['game_index'], item_game_index.game_index)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['game_indices'][0]['generation']['name'], item_game_index.generation.name)
self.assertEqual(
response.data['game_indices'][0]['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, item_game_index.generation.pk))
# held by params
self.assertEqual(response.data['held_by_pokemon'][0]['pokemon']['name'], pokemon.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['held_by_pokemon'][0]['pokemon']['url'],
'{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['held_by_pokemon'][0]['version_details'][0]['rarity'],
pokemon_item.rarity)
self.assertEqual(
response.data['held_by_pokemon'][0]['version_details'][0]['version']['name'],
pokemon_item.version.name)
self.assertEqual(
response.data['held_by_pokemon'][0]['version_details'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_item.version.pk))
# baby trigger params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['baby_trigger_for']['url'],
'{}{}/evolution-chain/{}/'.format(TEST_HOST, API_V2, evolution_chain.pk))
# sprites
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['sprites']['default'],
'{}{}'.format(MEDIA_HOST, sprites_data['default'].replace('/media/', '')))
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
# Berry Tests
2015-10-23 04:56:01 +00:00
def test_berry_firmness_api(self):
berry_firmness = self.setup_berry_firmness_data(name='base bry frmns')
2016-03-05 11:40:41 +00:00
berry_firmness_name = self.setup_berry_firmness_name_data(
berry_firmness, name='base bry frmns nm')
berry = self.setup_berry_data(berry_firmness=berry_firmness, name='bry for base frmns')
2015-10-23 04:56:01 +00:00
response = self.client.get('{}/berry-firmness/{}/'.format(API_V2, berry_firmness.pk))
2015-10-23 04:56:01 +00:00
# base params
self.assertEqual(response.data['id'], berry_firmness.pk)
self.assertEqual(response.data['name'], berry_firmness.name)
# name params
self.assertEqual(response.data['names'][0]['name'], berry_firmness_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], berry_firmness_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, berry_firmness_name.language.pk))
# berry params
self.assertEqual(response.data['berries'][0]['name'], berry.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['berries'][0]['url'],
'{}{}/berry/{}/'.format(TEST_HOST, API_V2, berry.pk))
2015-10-23 04:56:01 +00:00
def test_berry_flavor_api(self):
berry_flavor = self.setup_berry_flavor_data(name='base bry flvr')
berry_flavor_name = self.setup_berry_flavor_name_data(berry_flavor, name='base bry flvr nm')
berry = self.setup_berry_data(name='bry for base bry flvr')
2016-03-05 11:40:41 +00:00
berry_flavor_map = self.setup_berry_flavor_map_data(
berry=berry, berry_flavor=berry_flavor, potency=50)
response = self.client.get('{}/berry-flavor/{}/'.format(API_V2, berry_flavor.pk))
# base params
self.assertEqual(response.data['id'], berry_flavor.pk)
self.assertEqual(response.data['name'], berry_flavor.name)
# name params
self.assertEqual(response.data['names'][0]['name'], berry_flavor_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], berry_flavor_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, berry_flavor_name.language.pk))
# contest type params
self.assertEqual(response.data['contest_type']['name'], berry_flavor.contest_type.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_type']['url'],
'{}{}/contest-type/{}/'.format(TEST_HOST, API_V2, berry_flavor.contest_type.pk))
# berry params
self.assertEqual(response.data['berries'][0]['potency'], berry_flavor_map.potency)
self.assertEqual(response.data['berries'][0]['berry']['name'], berry.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['berries'][0]['berry']['url'],
'{}{}/berry/{}/'.format(TEST_HOST, API_V2, berry.pk))
2015-10-23 04:56:01 +00:00
def test_berry_api(self):
type = self.setup_type_data(name="tp fr base bry")
berry = self.setup_berry_data(name='base bry', natural_gift_type=type)
berry_flavor = self.setup_berry_flavor_data(name='bry flvr for base bry')
berry_flavor_map = self.setup_berry_flavor_map_data(berry=berry, berry_flavor=berry_flavor)
2016-03-05 08:26:51 +00:00
response = self.client.get('{}/berry/{}/'.format(API_V2, berry.pk))
2015-10-23 04:56:01 +00:00
# base params
self.assertEqual(response.data['id'], berry.pk)
self.assertEqual(response.data['name'], berry.name)
self.assertEqual(response.data['growth_time'], berry.growth_time)
self.assertEqual(response.data['max_harvest'], berry.max_harvest)
self.assertEqual(response.data['natural_gift_power'], berry.natural_gift_power)
2015-10-23 04:56:01 +00:00
self.assertEqual(response.data['size'], berry.size)
self.assertEqual(response.data['smoothness'], berry.smoothness)
self.assertEqual(response.data['soil_dryness'], berry.soil_dryness)
# firmness params
self.assertEqual(response.data['firmness']['name'], berry.berry_firmness.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['firmness']['url'],
'{}{}/berry-firmness/{}/'.format(TEST_HOST, API_V2, berry.berry_firmness.pk))
2015-10-23 04:56:01 +00:00
# item params
self.assertEqual(response.data['item']['name'], berry.item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['item']['url'],
'{}{}/item/{}/'.format(TEST_HOST, API_V2, berry.item.pk))
# flavor params
self.assertEqual(response.data['flavors'][0]['potency'], berry_flavor_map.potency)
self.assertEqual(response.data['flavors'][0]['flavor']['name'], berry_flavor.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavors'][0]['flavor']['url'],
'{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, berry_flavor.pk))
# natural gift type
self.assertEqual(response.data['natural_gift_type']['name'], type.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['natural_gift_type']['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, type.pk))
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
# Growth Rate Tests
2015-10-23 04:56:01 +00:00
def test_growth_rate_api(self):
# item pocket data
growth_rate = self.setup_growth_rate_data(name='base grth rt')
2016-03-05 11:40:41 +00:00
growth_rate_description = self.setup_growth_rate_description_data(
growth_rate, description='base grth rt desc')
pokemon_species = self.setup_pokemon_species_data(
name='pkmn spcs for grth rt', growth_rate=growth_rate)
2015-10-23 04:56:01 +00:00
# map item attribute to item
2016-03-05 11:40:41 +00:00
experience = Experience(
growth_rate=growth_rate,
level=10,
experience=3000
2015-10-23 04:56:01 +00:00
)
experience.save()
response = self.client.get('{}/growth-rate/{}/'.format(API_V2, growth_rate.pk))
2015-10-23 04:56:01 +00:00
# base params
self.assertEqual(response.data['id'], growth_rate.pk)
self.assertEqual(response.data['name'], growth_rate.name)
self.assertEqual(response.data['formula'], growth_rate.formula)
2015-10-23 04:56:01 +00:00
# description params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'], growth_rate_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
growth_rate_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, growth_rate_description.language.pk))
2015-10-23 04:56:01 +00:00
# experience params
self.assertEqual(response.data['levels'][0]['level'], experience.level)
self.assertEqual(response.data['levels'][0]['experience'], experience.experience)
# species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
# Location Tests
2015-10-23 04:56:01 +00:00
def test_location_api(self):
location = self.setup_location_data(name='base lctn')
location_name = self.setup_location_name_data(location, name='base lctn name')
location_game_index = self.setup_location_game_index_data(location, game_index=10)
2015-10-23 04:56:01 +00:00
response = self.client.get('{}/location/{}/'.format(API_V2, location.pk))
2015-10-23 04:56:01 +00:00
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], location.pk)
self.assertEqual(response.data['name'], location.name)
# name params
self.assertEqual(response.data['names'][0]['name'], location_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], location_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, location_name.language.pk))
2015-10-23 04:56:01 +00:00
# region params
self.assertEqual(response.data['region']['name'], location.region.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['region']['url'],
'{}{}/region/{}/'.format(TEST_HOST, API_V2, location.region.pk))
# game indices params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['game_indices'][0]['game_index'], location_game_index.game_index)
self.assertEqual(
response.data['game_indices'][0]['generation']['name'],
location_game_index.generation.name)
self.assertEqual(
response.data['game_indices'][0]['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, location_game_index.generation.pk))
def test_location_area_api(self):
location = self.setup_location_data(name='lctn for base lctn area')
location_area = self.setup_location_area_data(location, name="base lctn area")
2016-03-05 11:40:41 +00:00
location_area_name = self.setup_location_area_name_data(
location_area, name='base lctn area name')
encounter_method = self.setup_encounter_method_data(name='encntr mthd for lctn area')
2016-03-05 11:40:41 +00:00
location_area_encounter_rate = self.setup_location_area_encounter_rate_data(
location_area, encounter_method, rate=20)
pokemon_species1 = self.setup_pokemon_species_data(name='spcs for pkmn1')
2016-03-05 11:40:41 +00:00
pokemon1 = self.setup_pokemon_data(
name='pkmn1 for base encntr', pokemon_species=pokemon_species1)
encounter_slot1 = self.setup_encounter_slot_data(encounter_method, slot=1, rarity=30)
2016-03-05 11:40:41 +00:00
encounter1 = self.setup_encounter_data(
pokemon=pokemon1, location_area=location_area,
encounter_slot=encounter_slot1, min_level=30, max_level=35)
pokemon_species2 = self.setup_pokemon_species_data(name='spcs for pkmn2')
2016-03-05 11:40:41 +00:00
pokemon2 = self.setup_pokemon_data(
name='pkmn2 for base encntr', pokemon_species=pokemon_species2)
encounter_slot2 = self.setup_encounter_slot_data(encounter_method, slot=2, rarity=40)
2016-03-05 11:40:41 +00:00
encounter2 = self.setup_encounter_data(
pokemon=pokemon2, location_area=location_area,
encounter_slot=encounter_slot2, min_level=32, max_level=36)
response = self.client.get('{}/location-area/{}/'.format(API_V2, location_area.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], location_area.pk)
self.assertEqual(response.data['name'], location_area.name)
self.assertEqual(response.data['game_index'], location_area.game_index)
# name params
self.assertEqual(response.data['names'][0]['name'], location_area_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], location_area_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, location_area_name.language.pk))
# location params
self.assertEqual(response.data['location']['name'], location.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['location']['url'],
'{}{}/location/{}/'.format(TEST_HOST, API_V2, location.pk))
# encounter method params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['encounter_method_rates'][0]['encounter_method']['name'],
encounter_method.name)
self.assertEqual(
response.data['encounter_method_rates'][0]['encounter_method']['url'],
'{}{}/encounter-method/{}/'.format(TEST_HOST, API_V2, encounter_method.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['encounter_method_rates'][0]['version_details'][0]['rate'],
location_area_encounter_rate.rate)
self.assertEqual(
response.data['encounter_method_rates'][0]['version_details'][0]['version']['name'],
location_area_encounter_rate.version.name)
self.assertEqual(
response.data['encounter_method_rates'][0]['version_details'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, location_area_encounter_rate.version.pk))
# encounter params
self.assertEqual(response.data['pokemon_encounters'][0]['pokemon']['name'], pokemon1.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][0]['pokemon']['url'],
'{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon1.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][0]['version_details'][0]['max_chance'],
encounter_slot1.rarity)
self.assertEqual(
response.data['pokemon_encounters'][0]['version_details'][0]['version']['name'],
encounter1.version.name)
self.assertEqual(
response.data['pokemon_encounters'][0]['version_details'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, encounter1.version.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][0].get(
'version_details')[0]['encounter_details'][0]['chance'],
encounter_slot1.rarity)
self.assertEqual(
response.data['pokemon_encounters'][0].get(
'version_details')[0]['encounter_details'][0]['method']['name'],
encounter_slot1.encounter_method.name)
self.assertEqual(
response.data['pokemon_encounters'][0]['version_details'][0].get(
'encounter_details')[0]['method']['url'],
'{}{}/encounter-method/{}/'.format(
TEST_HOST, API_V2, encounter_slot1.encounter_method.pk))
self.assertEqual(response.data['pokemon_encounters'][1]['pokemon']['name'], pokemon2.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][1]['pokemon']['url'],
'{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon2.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][1]['version_details'][0]['max_chance'],
encounter_slot2.rarity)
self.assertEqual(
response.data['pokemon_encounters'][1]['version_details'][0]['version']['name'],
encounter2.version.name)
self.assertEqual(
response.data['pokemon_encounters'][1]['version_details'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, encounter2.version.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][1].get(
'version_details')[0]['encounter_details'][0]['chance'],
encounter_slot2.rarity)
self.assertEqual(
response.data['pokemon_encounters'][1]['version_details'][0].get(
'encounter_details')[0]['method']['name'],
encounter_slot2.encounter_method.name)
self.assertEqual(
response.data['pokemon_encounters'][1]['version_details'][0].get(
'encounter_details')[0]['method']['url'],
'{}{}/encounter-method/{}/'.format(
TEST_HOST, API_V2, encounter_slot2.encounter_method.pk))
2016-03-05 11:40:41 +00:00
# Contest Tests
def test_contest_type_api(self):
contest_type = self.setup_contest_type_data(name='base cntst tp')
2016-03-05 11:40:41 +00:00
contest_type_name = self.setup_contest_type_name_data(
contest_type, name='base cntst tp name')
berry_flavor = self.setup_berry_flavor_data(
name="bry for base cntst tp", contest_type=contest_type)
response = self.client.get('{}/contest-type/{}/'.format(API_V2, contest_type.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], contest_type.pk)
self.assertEqual(response.data['name'], contest_type.name)
# name params
self.assertEqual(response.data['names'][0]['name'], contest_type_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], contest_type_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, contest_type_name.language.pk))
# berry params
self.assertEqual(response.data['berry_flavor']['name'], berry_flavor.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['berry_flavor']['url'],
'{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, berry_flavor.pk))
def test_contest_effect_api(self):
contest_effect = self.setup_contest_effect_data(appeal=10, jam=20)
2016-03-05 11:40:41 +00:00
contest_effect_flavor_text = self.setup_contest_effect_flavor_text_data(
contest_effect, flavor_text='base cntst efct flvr txt')
contest_effect_effect_text = self.setup_contest_effect_effect_text_data(
contest_effect, effect='base cntst efct eftc txt')
response = self.client.get('{}/contest-effect/{}/'.format(API_V2, contest_effect.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], contest_effect.pk)
self.assertEqual(response.data['appeal'], contest_effect.appeal)
self.assertEqual(response.data['jam'], contest_effect.jam)
# effect text params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_entries'][0]['effect'], contest_effect_effect_text.effect)
self.assertEqual(
response.data['effect_entries'][0]['language']['name'],
contest_effect_effect_text.language.name)
self.assertEqual(
response.data['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, contest_effect_effect_text.language.pk))
# flavor text params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['flavor_text'],
contest_effect_flavor_text.flavor_text)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['name'],
contest_effect_flavor_text.language.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, contest_effect_flavor_text.language.pk))
def test_super_contest_effect_api(self):
super_contest_effect = self.setup_super_contest_effect_data(appeal=10)
2016-03-05 11:40:41 +00:00
super_contest_effect_flavor_text = self.setup_super_contest_effect_flavor_text_data(
super_contest_effect, flavor_text='base spr cntst efct flvr txt')
move = self.setup_move_data(
name="mv for base spr cntst efct", super_contest_effect=super_contest_effect)
2016-03-05 11:40:41 +00:00
response = self.client.get(
'{}/super-contest-effect/{}/'.format(API_V2, super_contest_effect.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], super_contest_effect.pk)
self.assertEqual(response.data['appeal'], super_contest_effect.appeal)
# flavor text params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['flavor_text'],
super_contest_effect_flavor_text.flavor_text)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['name'],
super_contest_effect_flavor_text.language.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(
TEST_HOST, API_V2, super_contest_effect_flavor_text.language.pk))
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
2015-10-23 04:56:01 +00:00
2016-03-05 11:40:41 +00:00
# Type Tests
2015-10-23 04:56:01 +00:00
def test_type_api(self):
type = self.setup_type_data(name='base tp')
type_name = self.setup_type_name_data(type, name='base tp nm')
type_game_index = self.setup_type_game_index_data(type, game_index=10)
move = self.setup_move_data(name="mv for base tp", type=type)
pokemon = self.setup_pokemon_data(name="pkmn for base tp")
pokemon_type = self.setup_pokemon_type_data(pokemon=pokemon, type=type)
2015-10-23 04:56:01 +00:00
no_damage_to = self.setup_type_data(name='no damage to tp')
half_damage_to = self.setup_type_data(name='half damage to tp')
double_damage_to = self.setup_type_data(name='double damage to tp')
no_damage_from = self.setup_type_data(name='no damage from tp')
half_damage_from = self.setup_type_data(name='half damage from tp')
double_damage_from = self.setup_type_data(name='double damage from tp')
# type relations
2016-03-05 11:40:41 +00:00
no_damage_to_relation = TypeEfficacy(
damage_type=type,
target_type=no_damage_to,
damage_factor=0
2015-10-23 04:56:01 +00:00
)
no_damage_to_relation.save()
2016-03-05 11:40:41 +00:00
half_damage_to_type_relation = TypeEfficacy(
damage_type=type,
target_type=half_damage_to,
damage_factor=50
2015-10-23 04:56:01 +00:00
)
half_damage_to_type_relation.save()
2016-03-05 11:40:41 +00:00
double_damage_to_type_relation = TypeEfficacy(
damage_type=type,
target_type=double_damage_to,
damage_factor=200
2015-10-23 04:56:01 +00:00
)
double_damage_to_type_relation.save()
2016-03-05 11:40:41 +00:00
no_damage_from_relation = TypeEfficacy(
damage_type=no_damage_from,
target_type=type,
damage_factor=0
2015-10-23 04:56:01 +00:00
)
no_damage_from_relation.save()
2016-03-05 11:40:41 +00:00
half_damage_from_type_relation = TypeEfficacy(
damage_type=half_damage_from,
target_type=type,
damage_factor=50
2015-10-23 04:56:01 +00:00
)
half_damage_from_type_relation.save()
2016-03-05 11:40:41 +00:00
double_damage_from_type_relation = TypeEfficacy(
damage_type=double_damage_from,
target_type=type,
damage_factor=200
2015-10-23 04:56:01 +00:00
)
double_damage_from_type_relation.save()
response = self.client.get('{}/type/{}/'.format(API_V2, type.pk))
2015-10-23 04:56:01 +00:00
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], type.pk)
self.assertEqual(response.data['name'], type.name)
# name params
self.assertEqual(response.data['names'][0]['name'], type_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], type_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, type_name.language.pk))
2015-10-23 04:56:01 +00:00
# generation params
self.assertEqual(response.data['generation']['name'], type.generation.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, type.generation.pk))
# damage class params
self.assertEqual(response.data['move_damage_class']['name'], type.move_damage_class.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['move_damage_class']['url'],
'{}{}/move-damage-class/{}/'.format(TEST_HOST, API_V2, type.move_damage_class.pk))
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
# pokemon params
self.assertEqual(response.data['pokemon'][0]['slot'], pokemon_type.slot)
self.assertEqual(response.data['pokemon'][0]['pokemon']['name'], pokemon.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon'][0]['pokemon']['url'],
'{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk))
2015-10-23 04:56:01 +00:00
# damage relations params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_relations']['no_damage_to'][0]['name'], no_damage_to.name)
self.assertEqual(
response.data['damage_relations']['no_damage_to'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, no_damage_to.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_relations']['half_damage_to'][0]['name'], half_damage_to.name)
self.assertEqual(
response.data['damage_relations']['half_damage_to'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, half_damage_to.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_relations']['double_damage_to'][0]['name'], double_damage_to.name)
self.assertEqual(
response.data['damage_relations']['double_damage_to'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, double_damage_to.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_relations']['no_damage_from'][0]['name'], no_damage_from.name)
self.assertEqual(
response.data['damage_relations']['no_damage_from'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, no_damage_from.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_relations']['half_damage_from'][0]['name'], half_damage_from.name)
self.assertEqual(
response.data['damage_relations']['half_damage_from'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, half_damage_from.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_relations']['double_damage_from'][0]['name'],
double_damage_from.name)
self.assertEqual(
response.data['damage_relations']['double_damage_from'][0]['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, double_damage_from.pk))
# game indices params
self.assertEqual(response.data['game_indices'][0]['game_index'], type_game_index.game_index)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['game_indices'][0]['generation']['name'], type_game_index.generation.name)
self.assertEqual(
response.data['game_indices'][0]['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, type_game_index.generation.pk))
2016-03-05 11:40:41 +00:00
# Pokedex Tests
def test_pokedex_api(self):
pokedex = self.setup_pokedex_data(name='base pkdx')
pokedex_name = self.setup_pokedex_name_data(pokedex, name='base pkdx name')
2016-03-05 11:40:41 +00:00
pokedex_description = self.setup_pokedex_description_data(
pokedex, description='base pkdx desc')
pokemon_species = self.setup_pokemon_species_data(name='pkmn spcs for base pkdx')
2016-03-05 11:40:41 +00:00
dex_entry = self.setup_pokemon_dex_entry_data(
pokedex=pokedex, pokemon_species=pokemon_species)
response = self.client.get('{}/pokedex/{}/'.format(API_V2, pokedex.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokedex.pk)
self.assertEqual(response.data['name'], pokedex.name)
self.assertEqual(response.data['is_main_series'], pokedex.is_main_series)
# name params
self.assertEqual(response.data['names'][0]['name'], pokedex_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], pokedex_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokedex_name.language.pk))
# descriptions params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'], pokedex_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'], pokedex_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokedex_description.language.pk))
# region params
self.assertEqual(response.data['region']['name'], pokedex.region.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['region']['url'],
'{}{}/region/{}/'.format(TEST_HOST, API_V2, pokedex.region.pk))
# species params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_entries'][0]['entry_number'], dex_entry.pokedex_number)
self.assertEqual(
response.data['pokemon_entries'][0]['pokemon_species']['name'], pokemon_species.name)
self.assertEqual(
response.data['pokemon_entries'][0]['pokemon_species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
2016-03-05 11:40:41 +00:00
# Move Tests
def test_move_ailment_api(self):
move_ailment = self.setup_move_ailment_data(name='base mv almnt')
2016-03-05 11:40:41 +00:00
move_ailment_name = self.setup_move_ailment_name_data(
move_ailment, name='base mv almnt name')
move = self.setup_move_data(name='mv for base mv almnt')
2016-03-05 11:40:41 +00:00
self.setup_move_meta_data(move=move, move_ailment=move_ailment)
response = self.client.get('{}/move-ailment/{}/'.format(API_V2, move_ailment.pk))
2015-10-18 23:01:33 +00:00
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move_ailment.pk)
self.assertEqual(response.data['name'], move_ailment.name)
# name params
self.assertEqual(response.data['names'][0]['name'], move_ailment_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], move_ailment_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_ailment_name.language.pk))
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
def test_move_battle_style_api(self):
move_battle_style = self.setup_move_battle_style_data(name='base mv btl stl')
2016-03-05 11:40:41 +00:00
move_battle_style_name = self.setup_move_battle_style_name_data(
move_battle_style, name='base mv btl stl name')
response = self.client.get('{}/move-battle-style/{}/'.format(API_V2, move_battle_style.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move_battle_style.pk)
self.assertEqual(response.data['name'], move_battle_style.name)
# name params
self.assertEqual(response.data['names'][0]['name'], move_battle_style_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], move_battle_style_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_battle_style_name.language.pk))
def test_move_category_api(self):
move_category = self.setup_move_category_data(name='base mv ctgry')
2016-03-05 11:40:41 +00:00
move_category_description = self.setup_move_category_description_data(
move_category, description='base mv ctgry description')
move = self.setup_move_data(name='mv for base mv ctgry')
2016-03-05 11:40:41 +00:00
self.setup_move_meta_data(move=move, move_category=move_category)
response = self.client.get('{}/move-category/{}/'.format(API_V2, move_category.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move_category.pk)
self.assertEqual(response.data['name'], move_category.name)
# name params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'], move_category_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
move_category_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_category_description.language.pk))
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
def test_move_damage_class_api(self):
move_damage_class = self.setup_move_damage_class_data(name='base mv dmg cls')
2016-03-05 11:40:41 +00:00
move_damage_class_name = self.setup_move_damage_class_name_data(
move_damage_class, name='base mv dmg cls nm')
move_damage_class_description = self.setup_move_damage_class_description_data(
move_damage_class, description='base mv dmg cls desc')
move = self.setup_move_data(
name='mv for base mv dmg cls', move_damage_class=move_damage_class)
response = self.client.get('{}/move-damage-class/{}/'.format(API_V2, move_damage_class.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move_damage_class.pk)
self.assertEqual(response.data['name'], move_damage_class.name)
# name params
self.assertEqual(response.data['names'][0]['name'], move_damage_class_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], move_damage_class_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_damage_class_name.language.pk))
# description params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'],
move_damage_class_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
move_damage_class_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(
TEST_HOST, API_V2, move_damage_class_description.language.pk))
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
def test_move_learn_method_api(self):
move_learn_method = self.setup_move_learn_method_data(name='base mv lrn mthd')
2016-03-05 11:40:41 +00:00
move_learn_method_name = self.setup_move_learn_method_name_data(
move_learn_method, name='base mv lrn mthd nm')
move_learn_method_description = self.setup_move_learn_method_description_data(
move_learn_method, description='base mv lrn mthd desc')
version_group = self.setup_version_group_data(name='ver grp for base mv lrn mthd')
2016-03-05 11:40:41 +00:00
self.setup_version_group_move_learn_method_data(
version_group=version_group, move_learn_method=move_learn_method)
response = self.client.get('{}/move-learn-method/{}/'.format(API_V2, move_learn_method.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move_learn_method.pk)
self.assertEqual(response.data['name'], move_learn_method.name)
# name params
self.assertEqual(response.data['names'][0]['name'], move_learn_method_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], move_learn_method_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_learn_method_name.language.pk))
# description params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'],
move_learn_method_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
move_learn_method_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(
TEST_HOST, API_V2, move_learn_method_description.language.pk))
# version group params
self.assertEqual(response.data['version_groups'][0]['name'], version_group.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['version_groups'][0]['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version_group.pk))
def test_move_target_api(self):
move_target = self.setup_move_target_data(name='base mv trgt')
move_target_name = self.setup_move_target_name_data(move_target, name='base mv trgt nm')
2016-03-05 11:40:41 +00:00
move_target_description = self.setup_move_target_description_data(
move_target, description='base mv trgt desc')
move = self.setup_move_data(name='mv for base mv trgt', move_target=move_target)
response = self.client.get('{}/move-target/{}/'.format(API_V2, move_target.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move_target.pk)
self.assertEqual(response.data['name'], move_target.name)
# name params
self.assertEqual(response.data['names'][0]['name'], move_target_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], move_target_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_target_name.language.pk))
# description params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'], move_target_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
move_target_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_target_description.language.pk))
# move params
self.assertEqual(response.data['moves'][0]['name'], move.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk))
def test_move_api(self):
move_effect = self.setup_move_effect_data()
move_effect_effect_text = self.setup_move_effect_effect_text_data(move_effect)
move = self.setup_move_data(name='base mv', move_effect=move_effect)
move_name = self.setup_move_name_data(move, name='base mv nm')
move_meta = self.setup_move_meta_data(move)
move_stat_change = self.setup_move_stat_change_data(move=move, change=2)
move_change = self.setup_move_change_data(move, power=10, pp=20, accuracy=30)
move_effect_change = self.setup_move_effect_change_data(move_effect)
2016-03-05 11:40:41 +00:00
move_effect_change_effect_text = self.setup_move_effect_change_effect_text_data(
move_effect_change=move_effect_change, effect='efct tx for mv efct chng')
after_move = self.setup_move_data(name='after mv')
before_move = self.setup_move_data(name='before mv')
2016-03-05 11:40:41 +00:00
self.setup_contest_combo_data(move, after_move)
self.setup_contest_combo_data(before_move, move)
self.setup_super_contest_combo_data(move, after_move)
self.setup_super_contest_combo_data(before_move, move)
move_flavor_text = self.setup_move_flavor_text_data(move, flavor_text='flvr text for move')
response = self.client.get('{}/move/{}/'.format(API_V2, move.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], move.pk)
self.assertEqual(response.data['name'], move.name)
self.assertEqual(response.data['accuracy'], move.accuracy)
self.assertEqual(response.data['effect_chance'], move.move_effect_chance)
self.assertEqual(response.data['power'], move.power)
self.assertEqual(response.data['pp'], move.pp)
self.assertEqual(response.data['priority'], move.priority)
# name params
self.assertEqual(response.data['names'][0]['name'], move_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], move_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_name.language.pk))
# damage class params
self.assertEqual(response.data['damage_class']['name'], move.move_damage_class.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['damage_class']['url'],
'{}{}/move-damage-class/{}/'.format(TEST_HOST, API_V2, move.move_damage_class.pk))
# contest type params
self.assertEqual(response.data['contest_type']['name'], move.contest_type.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_type']['url'],
'{}{}/contest-type/{}/'.format(TEST_HOST, API_V2, move.contest_type.pk))
# contest effect params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_effect']['url'],
'{}{}/contest-effect/{}/'.format(TEST_HOST, API_V2, move.contest_effect.pk))
# super contest effect params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['super_contest_effect']['url'],
'{}{}/super-contest-effect/{}/'.format(TEST_HOST, API_V2, move.super_contest_effect.pk))
# generation params
self.assertEqual(response.data['generation']['name'], move.generation.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, move.generation.pk))
# target params
self.assertEqual(response.data['target']['name'], move.move_target.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['target']['url'],
'{}{}/move-target/{}/'.format(TEST_HOST, API_V2, move.move_target.pk))
# type params
self.assertEqual(response.data['type']['name'], move.type.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['type']['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, move.type.pk))
# stat change params
self.assertEqual(response.data['stat_changes'][0]['change'], move_stat_change.change)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['stat_changes'][0]['stat']['name'], move_stat_change.stat.name)
self.assertEqual(
response.data['stat_changes'][0]['stat']['url'],
'{}{}/stat/{}/'.format(TEST_HOST, API_V2, move_stat_change.stat.pk))
# effect entries params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_entries'][0]['effect'], move_effect_effect_text.effect)
self.assertEqual(
response.data['effect_entries'][0]['short_effect'],
move_effect_effect_text.short_effect)
self.assertEqual(
response.data['effect_entries'][0]['language']['name'],
move_effect_effect_text.language.name)
self.assertEqual(
response.data['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_effect_effect_text.language.pk))
# meta data
self.assertEqual(response.data['meta']['min_hits'], move_meta.min_hits)
self.assertEqual(response.data['meta']['max_hits'], move_meta.max_hits)
self.assertEqual(response.data['meta']['min_turns'], move_meta.min_turns)
self.assertEqual(response.data['meta']['max_turns'], move_meta.max_turns)
self.assertEqual(response.data['meta']['drain'], move_meta.drain)
self.assertEqual(response.data['meta']['healing'], move_meta.healing)
self.assertEqual(response.data['meta']['crit_rate'], move_meta.crit_rate)
self.assertEqual(response.data['meta']['ailment_chance'], move_meta.ailment_chance)
self.assertEqual(response.data['meta']['flinch_chance'], move_meta.flinch_chance)
self.assertEqual(response.data['meta']['stat_chance'], move_meta.stat_chance)
# ailment params
self.assertEqual(response.data['meta']['ailment']['name'], move_meta.move_meta_ailment.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['meta']['ailment']['url'],
'{}{}/move-ailment/{}/'.format(TEST_HOST, API_V2, move_meta.move_meta_ailment.pk))
# category params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['meta']['category']['name'], move_meta.move_meta_category.name)
self.assertEqual(
response.data['meta']['category']['url'],
'{}{}/move-category/{}/'.format(TEST_HOST, API_V2, move_meta.move_meta_category.pk))
# combo params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_combos']['normal']['use_before'][0]['name'], after_move.name)
self.assertEqual(
response.data['contest_combos']['normal']['use_before'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, after_move.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_combos']['normal']['use_after'][0]['name'], before_move.name)
self.assertEqual(
response.data['contest_combos']['normal']['use_after'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, before_move.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_combos']['super']['use_before'][0]['name'], after_move.name)
self.assertEqual(
response.data['contest_combos']['super']['use_before'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, after_move.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['contest_combos']['super']['use_after'][0]['name'], before_move.name)
self.assertEqual(
response.data['contest_combos']['super']['use_after'][0]['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, before_move.pk))
# change params
self.assertEqual(response.data['past_values'][0]['accuracy'], move_change.accuracy)
self.assertEqual(response.data['past_values'][0]['power'], move_change.power)
self.assertEqual(response.data['past_values'][0]['pp'], move_change.pp)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['past_values'][0]['effect_chance'], move_change.move_effect_chance)
self.assertEqual(
response.data['past_values'][0]['version_group']['name'],
move_change.version_group.name)
self.assertEqual(
response.data['past_values'][0]['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, move_change.version_group.pk))
# effect changes
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_changes'][0]['version_group']['name'],
move_effect_change.version_group.name)
self.assertEqual(
response.data['effect_changes'][0]['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, move_effect_change.version_group.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['effect_changes'][0]['effect_entries'][0]['effect'],
move_effect_change_effect_text.effect)
self.assertEqual(
response.data['effect_changes'][0]['effect_entries'][0]['language']['name'],
move_effect_change_effect_text.language.name)
self.assertEqual(
response.data['effect_changes'][0]['effect_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(
TEST_HOST, API_V2, move_effect_change_effect_text.language.pk))
# flavor text params
self.assertEqual(
response.data['flavor_text_entries'][0]['flavor_text'], move_flavor_text.flavor_text)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['name'],
move_flavor_text.language.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, move_flavor_text.language.pk))
self.assertEqual(
response.data['flavor_text_entries'][0]['version_group']['name'],
move_flavor_text.version_group.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, move_flavor_text.version_group.pk))
2016-03-05 11:40:41 +00:00
# Stat Tests
def test_stat_api(self):
stat = self.setup_stat_data(name='base stt')
stat_name = self.setup_stat_name_data(stat, name='base stt name')
increase_move = self.setup_move_data(name="incrs mv for base stt")
2016-03-05 11:40:41 +00:00
increase_move_stat_change = self.setup_move_stat_change_data(
move=increase_move, stat=stat, change=2)
decrease_move = self.setup_move_data(name="dcrs mv for base stt")
2016-03-05 11:40:41 +00:00
decrease_move_stat_change = self.setup_move_stat_change_data(
move=decrease_move, stat=stat, change=(-2))
increase_nature = self.setup_nature_data(name="incrs ntr for base stt", increased_stat=stat)
decrease_nature = self.setup_nature_data(name="dcrs ntr for base stt", decreased_stat=stat)
characteristic = self.setup_characteristic_data(stat=stat)
response = self.client.get('{}/stat/{}/'.format(API_V2, stat.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], stat.pk)
self.assertEqual(response.data['name'], stat.name)
self.assertEqual(response.data['game_index'], stat.game_index)
self.assertEqual(response.data['is_battle_only'], stat.is_battle_only)
# name params
self.assertEqual(response.data['names'][0]['name'], stat_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], stat_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, stat_name.language.pk))
# move damage class params
self.assertEqual(response.data['move_damage_class']['name'], stat.move_damage_class.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['move_damage_class']['url'],
'{}{}/move-damage-class/{}/'.format(TEST_HOST, API_V2, stat.move_damage_class.pk))
# nature params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['affecting_natures']['increase'][0]['name'], increase_nature.name)
self.assertEqual(
response.data['affecting_natures']['increase'][0]['url'],
'{}{}/nature/{}/'.format(TEST_HOST, API_V2, increase_nature.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['affecting_natures']['decrease'][0]['name'], decrease_nature.name)
self.assertEqual(
response.data['affecting_natures']['decrease'][0]['url'],
'{}{}/nature/{}/'.format(TEST_HOST, API_V2, decrease_nature.pk))
# move params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['affecting_moves']['increase'][0]['change'],
increase_move_stat_change.change)
self.assertEqual(
response.data['affecting_moves']['increase'][0]['move']['name'], increase_move.name)
self.assertEqual(
response.data['affecting_moves']['increase'][0]['move']['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, increase_move.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['affecting_moves']['decrease'][0]['change'],
decrease_move_stat_change.change)
self.assertEqual(
response.data['affecting_moves']['decrease'][0]['move']['name'], decrease_move.name)
self.assertEqual(
response.data['affecting_moves']['decrease'][0]['move']['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, decrease_move.pk))
# characteristics params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['characteristics'][0]['url'],
'{}{}/characteristic/{}/'.format(TEST_HOST, API_V2, characteristic.pk))
def test_pokeathlon_stat_api(self):
pokeathlon_stat = self.setup_pokeathlon_stat_data(name='base pkathln stt')
2016-03-05 11:40:41 +00:00
pokeathlon_stat_name = self.setup_pokeathlon_stat_name_data(
pokeathlon_stat, name='base pkathln stt name')
response = self.client.get('{}/pokeathlon-stat/{}/'.format(API_V2, pokeathlon_stat.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokeathlon_stat.pk)
self.assertEqual(response.data['name'], pokeathlon_stat.name)
# name params
self.assertEqual(response.data['names'][0]['name'], pokeathlon_stat_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], pokeathlon_stat_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokeathlon_stat_name.language.pk))
2016-03-05 11:40:41 +00:00
# Characteristic Tests
def test_characteristic_api(self):
characteristic = self.setup_characteristic_data(gene_mod_5=5)
2016-03-05 11:40:41 +00:00
characteristic_description = self.setup_characteristic_description_data(
characteristic, description='base char desc')
response = self.client.get('{}/characteristic/{}/'.format(API_V2, characteristic.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], characteristic.pk)
self.assertEqual(response.data['gene_modulo'], characteristic.gene_mod_5)
# name params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['descriptions'][0]['description'],
characteristic_description.description)
self.assertEqual(
response.data['descriptions'][0]['language']['name'],
characteristic_description.language.name)
self.assertEqual(
response.data['descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, characteristic_description.language.pk))
# stat params
self.assertEqual(response.data['highest_stat']['name'], characteristic.stat.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['highest_stat']['url'],
'{}{}/stat/{}/'.format(TEST_HOST, API_V2, characteristic.stat.pk))
2016-03-05 11:40:41 +00:00
# Nature Tests
def test_nature_api(self):
2015-10-18 23:01:33 +00:00
hates_flavor = self.setup_berry_flavor_data(name='hts flvr for base ntr')
likes_flavor = self.setup_berry_flavor_data(name='lks flvr for base ntr')
decreased_stat = self.setup_stat_data(name='dcrs stt for base ntr')
increased_stat = self.setup_stat_data(name='ncrs stt for base ntr')
2016-03-05 11:40:41 +00:00
nature = self.setup_nature_data(
name='base ntr', hates_flavor=hates_flavor, likes_flavor=likes_flavor,
decreased_stat=decreased_stat, increased_stat=increased_stat)
nature_name = self.setup_nature_name_data(nature, name='base ntr name')
2016-03-05 08:26:51 +00:00
pokeathlon_stat = self.setup_pokeathlon_stat_data(name='pkeathln stt for ntr stt')
2016-03-05 11:40:41 +00:00
nature_pokeathlon_stat = self.setup_nature_pokeathlon_stat_data(
nature=nature, pokeathlon_stat=pokeathlon_stat, max_change=1)
move_battle_style = self.setup_move_battle_style_data(name='mv btl stl for ntr stt')
2016-03-05 11:40:41 +00:00
nature_battle_style_preference = self.setup_nature_battle_style_preference_data(
nature=nature, move_battle_style=move_battle_style)
2015-10-18 23:01:33 +00:00
response = self.client.get('{}/nature/{}/'.format(API_V2, nature.pk))
2015-10-18 23:01:33 +00:00
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], nature.pk)
self.assertEqual(response.data['name'], nature.name)
# name params
self.assertEqual(response.data['names'][0]['name'], nature_name.name)
self.assertEqual(response.data['names'][0]['language']['name'], nature_name.language.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, nature_name.language.pk))
# stat params
self.assertEqual(response.data['decreased_stat']['name'], decreased_stat.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['decreased_stat']['url'],
'{}{}/stat/{}/'.format(TEST_HOST, API_V2, decreased_stat.pk))
self.assertEqual(response.data['increased_stat']['name'], increased_stat.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['increased_stat']['url'],
'{}{}/stat/{}/'.format(TEST_HOST, API_V2, increased_stat.pk))
# flavor params
self.assertEqual(response.data['hates_flavor']['name'], hates_flavor.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['hates_flavor']['url'],
'{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, hates_flavor.pk))
self.assertEqual(response.data['likes_flavor']['name'], likes_flavor.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['likes_flavor']['url'],
'{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, likes_flavor.pk))
# pokeathlon stat params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokeathlon_stat_changes'][0]['max_change'],
nature_pokeathlon_stat.max_change)
self.assertEqual(
response.data['pokeathlon_stat_changes'][0]['pokeathlon_stat']['name'],
pokeathlon_stat.name)
self.assertEqual(
response.data['pokeathlon_stat_changes'][0]['pokeathlon_stat']['url'],
'{}{}/pokeathlon-stat/{}/'.format(TEST_HOST, API_V2, pokeathlon_stat.pk))
# pokeathlon stat params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['move_battle_style_preferences'][0]['low_hp_preference'],
nature_battle_style_preference.low_hp_preference)
self.assertEqual(
response.data['move_battle_style_preferences'][0]['high_hp_preference'],
nature_battle_style_preference.high_hp_preference)
self.assertEqual(
response.data['move_battle_style_preferences'][0]['move_battle_style']['name'],
move_battle_style.name)
self.assertEqual(
response.data['move_battle_style_preferences'][0]['move_battle_style']['url'],
'{}{}/move-battle-style/{}/'.format(TEST_HOST, API_V2, move_battle_style.pk))
2016-03-05 11:40:41 +00:00
# Pokemon Tests
def test_pokemon_habitat_api(self):
pokemon_habitat = self.setup_pokemon_habitat_data(name='base pkmn hbtt trgr')
2016-03-05 11:40:41 +00:00
pokemon_habitat_name = self.setup_pokemon_habitat_name_data(
pokemon_habitat, name='base pkmn hbtt name')
pokemon_species = self.setup_pokemon_species_data(
pokemon_habitat=pokemon_habitat, name='pkmn spcs for pkmn hbtt')
response = self.client.get('{}/pokemon-habitat/{}/'.format(API_V2, pokemon_habitat.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokemon_habitat.pk)
self.assertEqual(response.data['name'], pokemon_habitat.name)
# name params
self.assertEqual(response.data['names'][0]['name'], pokemon_habitat_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], pokemon_habitat_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_habitat_name.language.pk))
# species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
def test_pokemon_color_api(self):
pokemon_color = self.setup_pokemon_color_data(name='base pkmn clr trgr')
2016-03-05 11:40:41 +00:00
pokemon_color_name = self.setup_pokemon_color_name_data(
pokemon_color, name='base pkmn clr name')
pokemon_species = self.setup_pokemon_species_data(
pokemon_color=pokemon_color, name='pkmn spcs for pkmn clr')
response = self.client.get('{}/pokemon-color/{}/'.format(API_V2, pokemon_color.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokemon_color.pk)
self.assertEqual(response.data['name'], pokemon_color.name)
# name params
self.assertEqual(response.data['names'][0]['name'], pokemon_color_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], pokemon_color_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_color_name.language.pk))
# species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
def test_pokemon_shape_api(self):
pokemon_shape = self.setup_pokemon_shape_data(name='base pkmn shp trgr')
2016-03-05 11:40:41 +00:00
pokemon_shape_name = self.setup_pokemon_shape_name_data(
pokemon_shape, name='base pkmn shp name')
pokemon_species = self.setup_pokemon_species_data(
pokemon_shape=pokemon_shape, name='pkmn spcs for pkmn shp')
response = self.client.get('{}/pokemon-shape/{}/'.format(API_V2, pokemon_shape.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokemon_shape.pk)
self.assertEqual(response.data['name'], pokemon_shape.name)
# name params
self.assertEqual(response.data['names'][0]['name'], pokemon_shape_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], pokemon_shape_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_shape_name.language.pk))
# awesome name params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['awesome_names'][0]['awesome_name'], pokemon_shape_name.awesome_name)
self.assertEqual(
response.data['awesome_names'][0]['language']['name'], pokemon_shape_name.language.name)
self.assertEqual(
response.data['awesome_names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_shape_name.language.pk))
# species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
def test_pokemon_species_api(self):
evolves_from_species = self.setup_pokemon_species_data(name='evolves from pkmn spcs')
2016-03-05 11:40:41 +00:00
pokemon_species = self.setup_pokemon_species_data(
evolves_from_species=evolves_from_species, name='base pkmn spcs')
pokemon_species_name = self.setup_pokemon_species_name_data(
pokemon_species, name='base pkmn shp name')
pokemon_species_form_description = self.setup_pokemon_species_form_description_data(
pokemon_species, description='frm dscr for pkmn spcs')
pokemon_species_flavor_text = self.setup_pokemon_species_flavor_text_data(
pokemon_species, flavor_text='flvr txt for pkmn spcs')
pokedex = self.setup_pokedex_data(name='pkdx for pkmn spcs')
2016-03-05 08:26:51 +00:00
pal_park = self.setup_pal_park_data(pokemon_species=pokemon_species)
2016-03-05 11:40:41 +00:00
dex_number = self.setup_pokemon_dex_entry_data(
pokemon_species=pokemon_species, pokedex=pokedex, entry_number=44)
2016-03-05 08:26:51 +00:00
egg_group = self.setup_egg_group_data(name='egg grp for pkmn spcs')
self.setup_pokemon_egg_group_data(pokemon_species=pokemon_species, egg_group=egg_group)
2016-03-05 11:40:41 +00:00
pokemon = self.setup_pokemon_data(
pokemon_species=pokemon_species, name='pkm for base pkmn spcs')
self.setup_pokemon_sprites_data(pokemon)
2016-03-05 11:40:41 +00:00
response = self.client.get(
'{}/pokemon-species/{}/'.format(API_V2, pokemon_species.pk), HTTP_HOST='testserver')
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokemon_species.pk)
self.assertEqual(response.data['name'], pokemon_species.name)
self.assertEqual(response.data['order'], pokemon_species.order)
self.assertEqual(response.data['capture_rate'], pokemon_species.capture_rate)
self.assertEqual(response.data['gender_rate'], pokemon_species.gender_rate)
self.assertEqual(response.data['base_happiness'], pokemon_species.base_happiness)
self.assertEqual(response.data['is_baby'], pokemon_species.is_baby)
self.assertEqual(response.data['hatch_counter'], pokemon_species.hatch_counter)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['has_gender_differences'], pokemon_species.has_gender_differences)
self.assertEqual(response.data['forms_switchable'], pokemon_species.forms_switchable)
# name params
self.assertEqual(response.data['names'][0]['name'], pokemon_species_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], pokemon_species_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_species_name.language.pk))
# growth rate params
self.assertEqual(response.data['growth_rate']['name'], pokemon_species.growth_rate.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['growth_rate']['url'],
'{}{}/growth-rate/{}/'.format(TEST_HOST, API_V2, pokemon_species.growth_rate.pk))
# dex number params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokedex_numbers'][0]['entry_number'], dex_number.pokedex_number)
self.assertEqual(response.data['pokedex_numbers'][0]['pokedex']['name'], pokedex.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokedex_numbers'][0]['pokedex']['url'],
'{}{}/pokedex/{}/'.format(TEST_HOST, API_V2, pokedex.pk))
# egg group params
self.assertEqual(response.data['egg_groups'][0]['name'], egg_group.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['egg_groups'][0]['url'],
'{}{}/egg-group/{}/'.format(TEST_HOST, API_V2, egg_group.pk))
# generation params
self.assertEqual(response.data['generation']['name'], pokemon_species.generation.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['generation']['url'],
'{}{}/generation/{}/'.format(TEST_HOST, API_V2, pokemon_species.generation.pk))
# color params
self.assertEqual(response.data['color']['name'], pokemon_species.pokemon_color.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['color']['url'],
'{}{}/pokemon-color/{}/'.format(TEST_HOST, API_V2, pokemon_species.pokemon_color.pk))
# shape params
self.assertEqual(response.data['shape']['name'], pokemon_species.pokemon_shape.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['shape']['url'],
'{}{}/pokemon-shape/{}/'.format(TEST_HOST, API_V2, pokemon_species.pokemon_shape.pk))
# habitat params
self.assertEqual(response.data['habitat']['name'], pokemon_species.pokemon_habitat.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['habitat']['url'],
'{}{}/pokemon-habitat/{}/'.format(
TEST_HOST, API_V2, pokemon_species.pokemon_habitat.pk))
# evolves from params
self.assertEqual(response.data['evolves_from_species']['name'], evolves_from_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['evolves_from_species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, evolves_from_species.pk))
# genus params
self.assertEqual(response.data['genera'][0]['genus'], pokemon_species_name.genus)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['genera'][0]['language']['name'], pokemon_species_name.language.name)
self.assertEqual(
response.data['genera'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_species_name.language.pk))
# pokemon varieties params
self.assertEqual(response.data['varieties'][0]['is_default'], pokemon.is_default)
self.assertEqual(response.data['varieties'][0]['pokemon']['name'], pokemon.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['varieties'][0]['pokemon']['url'],
'{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk))
# form descriptions params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['form_descriptions'][0]['description'],
pokemon_species_form_description.description)
self.assertEqual(
response.data['form_descriptions'][0]['language']['name'],
pokemon_species_form_description.language.name)
self.assertEqual(
response.data['form_descriptions'][0]['language']['url'],
'{}{}/language/{}/'.format(
TEST_HOST, API_V2, pokemon_species_form_description.language.pk))
2016-02-25 04:55:59 +00:00
# flavor text params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['flavor_text'],
pokemon_species_flavor_text.flavor_text)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['name'],
pokemon_species_flavor_text.language.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_species_flavor_text.language.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['flavor_text_entries'][0]['version']['name'],
pokemon_species_flavor_text.version.name)
self.assertEqual(
response.data['flavor_text_entries'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_species_flavor_text.version.pk))
# pal park params
self.assertEqual(response.data['pal_park_encounters'][0]['base_score'], pal_park.base_score)
self.assertEqual(response.data['pal_park_encounters'][0]['rate'], pal_park.rate)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pal_park_encounters'][0]['area']['name'], pal_park.pal_park_area.name)
self.assertEqual(
response.data['pal_park_encounters'][0]['area']['url'],
'{}{}/pal-park-area/{}/'.format(TEST_HOST, API_V2, pal_park.pal_park_area.pk))
def test_pokemon_api(self):
pokemon_species = self.setup_pokemon_species_data(name='pkmn spcs for base pkmn')
pokemon = self.setup_pokemon_data(pokemon_species=pokemon_species, name='base pkm')
pokemon_form = self.setup_pokemon_form_data(pokemon=pokemon, name='pkm form for base pkmn')
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)
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)
2016-02-25 04:55:59 +00:00
# To test issue #85, we will create one move that has multiple
# learn levels in different version groups. Later, we'll
# assert that we only got one move record back.
pokemon_move = self.setup_move_data(name='mv for pkmn')
pokemon_moves = []
2016-03-05 11:40:41 +00:00
for move in range(0, 4):
2016-02-25 04:55:59 +00:00
version_group = self.setup_version_group_data(
name='ver grp ' + str(move) + ' for pkmn')
2016-02-25 04:55:59 +00:00
new_move = self.setup_pokemon_move_data(
pokemon=pokemon,
move=pokemon_move,
version_group=version_group,
level=move)
2016-02-25 04:55:59 +00:00
pokemon_moves.append(new_move)
2016-03-05 08:26:51 +00:00
encounter_method = self.setup_encounter_method_data(name='encntr mthd for lctn area')
location_area1 = self.setup_location_area_data(name='lctn1 area for base pkmn')
encounter_slot1 = self.setup_encounter_slot_data(encounter_method, slot=1, rarity=30)
self.setup_encounter_data(
2016-03-05 11:40:41 +00:00
location_area=location_area1, pokemon=pokemon,
encounter_slot=encounter_slot1, min_level=30, max_level=35)
location_area2 = self.setup_location_area_data(name='lctn2 area for base pkmn')
encounter_slot2 = self.setup_encounter_slot_data(encounter_method, slot=2, rarity=40)
self.setup_encounter_data(
2016-03-05 11:40:41 +00:00
location_area=location_area2, pokemon=pokemon,
encounter_slot=encounter_slot2, min_level=32, max_level=36)
response = self.client.get(
'{}/pokemon/{}/'.format(API_V2, pokemon.pk), HTTP_HOST='testserver')
sprites_data = json.loads(pokemon_sprites.sprites)
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokemon.pk)
self.assertEqual(response.data['name'], pokemon.name)
self.assertEqual(response.data['order'], pokemon.order)
self.assertEqual(response.data['is_default'], pokemon.is_default)
self.assertEqual(response.data['height'], pokemon.height)
self.assertEqual(response.data['weight'], pokemon.weight)
self.assertEqual(response.data['base_experience'], pokemon.base_experience)
# species params
self.assertEqual(response.data['species']['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
# abilities params
self.assertEqual(response.data['abilities'][0]['is_hidden'], pokemon_ability.is_hidden)
self.assertEqual(response.data['abilities'][0]['slot'], pokemon_ability.slot)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['abilities'][0]['ability']['name'], pokemon_ability.ability.name)
self.assertEqual(
response.data['abilities'][0]['ability']['url'],
'{}{}/ability/{}/'.format(TEST_HOST, API_V2, pokemon_ability.ability.pk))
# stat params
self.assertEqual(response.data['stats'][0]['base_stat'], pokemon_stat.base_stat)
self.assertEqual(response.data['stats'][0]['effort'], pokemon_stat.effort)
self.assertEqual(response.data['stats'][0]['stat']['name'], pokemon_stat.stat.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['stats'][0]['stat']['url'],
'{}{}/stat/{}/'.format(TEST_HOST, API_V2, pokemon_stat.stat.pk))
# stat params
self.assertEqual(response.data['types'][0]['slot'], pokemon_type.slot)
self.assertEqual(response.data['types'][0]['type']['name'], pokemon_type.type.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['types'][0]['type']['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, pokemon_type.type.pk))
# items params
self.assertEqual(response.data['held_items'][0]['item']['name'], pokemon_item.item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['held_items'][0]['item']['url'],
'{}{}/item/{}/'.format(TEST_HOST, API_V2, pokemon_item.item.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['held_items'][0]['version_details'][0]['rarity'], pokemon_item.rarity)
self.assertEqual(
response.data['held_items'][0]['version_details'][0]['version']['name'],
pokemon_item.version.name)
self.assertEqual(
response.data['held_items'][0]['version_details'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_item.version.pk))
2016-02-25 04:55:59 +00:00
# move params -- Make sure that we only got one move back,
# but that we got all of the distinct version group and learn
# level values. (See issue #85)
# Number of Moves
expected = 1
actual = len(response.data['moves'])
self.assertEqual(expected, actual)
# Move name
expected = pokemon_moves[0].move.name
actual = response.data['moves'][0]['move']['name']
self.assertEqual(expected, actual)
# Move URL
expected = '{}{}/move/{}/'.format(
TEST_HOST,
API_V2,
2016-02-25 04:55:59 +00:00
pokemon_moves[0].move.pk)
actual = response.data['moves'][0]['move']['url']
self.assertEqual(expected, actual)
# Numbver of version groups
expected = len(pokemon_moves)
actual = len(response.data['moves'][0]['version_group_details'])
self.assertEqual(expected, actual)
for i, val in enumerate(pokemon_moves): #pylint: disable=unused-variable
2016-02-25 04:55:59 +00:00
version = response.data['moves'][0]['version_group_details'][i]
# Learn Level
expected = pokemon_moves[i].level
actual = version['level_learned_at']
2016-03-05 11:40:41 +00:00
self.assertEqual(expected, actual)
2016-02-25 04:55:59 +00:00
# Version Group Name
expected = pokemon_moves[i].version_group.name
actual = version['version_group']['name']
self.assertEqual(expected, actual)
# Version Group URL
expected = '{}{}/version-group/{}/'.format(
TEST_HOST,
API_V2,
2016-02-25 04:55:59 +00:00
pokemon_moves[i].version_group.pk)
actual = version['version_group']['url']
self.assertEqual(expected, actual)
# Learn Method Name
expected = pokemon_moves[i].move_learn_method.name
actual = version['move_learn_method']['name']
self.assertEqual(expected, actual)
# Learn Method URL
expected = '{}{}/move-learn-method/{}/'.format(
TEST_HOST,
API_V2,
2016-02-25 04:55:59 +00:00
pokemon_moves[i].move_learn_method.pk)
actual = version['move_learn_method']['url']
self.assertEqual(expected, actual)
# game indices params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['game_indices'][0]['game_index'],
pokemon_game_index.game_index)
self.assertEqual(
response.data['game_indices'][0]['version']['name'],
pokemon_game_index.version.name)
self.assertEqual(
response.data['game_indices'][0]['version']['url'],
'{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_game_index.version.pk))
# form params
self.assertEqual(response.data['forms'][0]['name'], pokemon_form.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['forms'][0]['url'],
'{}{}/pokemon-form/{}/'.format(TEST_HOST, API_V2, pokemon_form.pk))
# sprite params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['sprites']['front_default'],
'{}{}'.format(MEDIA_HOST, sprites_data['front_default'].replace('/media/', '')))
self.assertEqual(response.data['sprites']['back_default'], None)
2016-03-05 08:26:51 +00:00
def test_pokemon_form_api(self):
pokemon_species = self.setup_pokemon_species_data()
pokemon = self.setup_pokemon_data(pokemon_species=pokemon_species)
pokemon_form = self.setup_pokemon_form_data(pokemon=pokemon, name='pkm form for base pkmn')
pokemon_form_sprites = self.setup_pokemon_form_sprites_data(pokemon_form)
sprites_data = json.loads(pokemon_form_sprites.sprites)
2016-03-05 11:40:41 +00:00
response = self.client.get(
'{}/pokemon-form/{}/'.format(API_V2, pokemon_form.pk), HTTP_HOST='testserver')
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pokemon_form.pk)
self.assertEqual(response.data['name'], pokemon_form.name)
self.assertEqual(response.data['form_name'], pokemon_form.form_name)
self.assertEqual(response.data['order'], pokemon_form.order)
self.assertEqual(response.data['form_order'], pokemon_form.form_order)
self.assertEqual(response.data['is_default'], pokemon_form.is_default)
self.assertEqual(response.data['is_battle_only'], pokemon_form.is_battle_only)
self.assertEqual(response.data['is_mega'], pokemon_form.is_mega)
# pokemon params
self.assertEqual(response.data['pokemon']['name'], pokemon.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon']['url'], '{}{}/pokemon/{}/'.format(
TEST_HOST, API_V2, pokemon.pk))
# version group params
self.assertEqual(response.data['version_group']['name'], pokemon_form.version_group.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['version_group']['url'],
'{}{}/version-group/{}/'.format(TEST_HOST, API_V2, pokemon_form.version_group.pk))
# sprite params
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['sprites']['front_default'],
'{}{}'.format(MEDIA_HOST, sprites_data['front_default'].replace('/media/', '')))
self.assertEqual(response.data['sprites']['back_default'], None)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
# Evolution test
def test_evolution_trigger_api(self):
2015-10-18 23:01:33 +00:00
evolution_trigger = self.setup_evolution_trigger_data(name='base evltn trgr')
2016-03-05 11:40:41 +00:00
evolution_trigger_name = self.setup_evolution_trigger_name_data(
evolution_trigger, name='base evltn trgr name')
pokemon_species = self.setup_pokemon_species_data(
name='pkmn spcs for base evltn trgr')
self.setup_pokemon_evolution_data(
evolved_species=pokemon_species, evolution_trigger=evolution_trigger)
2015-10-18 23:01:33 +00:00
response = self.client.get('{}/evolution-trigger/{}/'.format(API_V2, evolution_trigger.pk))
2015-10-18 23:01:33 +00:00
self.assertEqual(response.status_code, status.HTTP_200_OK)
2015-10-18 23:01:33 +00:00
# base params
self.assertEqual(response.data['id'], evolution_trigger.pk)
self.assertEqual(response.data['name'], evolution_trigger.name)
# name params
self.assertEqual(response.data['names'][0]['name'], evolution_trigger_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], evolution_trigger_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, evolution_trigger_name.language.pk))
# pokemon species params
self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_species'][0]['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))
def test_evolution_chain_api(self):
2015-10-18 23:01:33 +00:00
baby_trigger_item = self.setup_item_data(name="bby itm for evo chn")
evolution_chain = self.setup_evolution_chain_data(baby_trigger_item=baby_trigger_item)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
baby = self.setup_pokemon_species_data(
name="bby for evo chn", is_baby=True, evolution_chain=evolution_chain)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
basic = self.setup_pokemon_species_data(
name="bsc for evo chn", evolves_from_species=baby, evolution_chain=evolution_chain)
basic_location = self.setup_location_data(name='lctn for bsc evo chn')
2016-03-05 11:40:41 +00:00
basic_evolution = self.setup_pokemon_evolution_data(
evolved_species=basic, min_level=5, location=basic_location)
stage_one = self.setup_pokemon_species_data(
name="stg one for evo chn", evolves_from_species=basic, evolution_chain=evolution_chain)
stage_one_held_item = self.setup_item_data(
name='itm for stg one evo chn')
stage_one_evolution = self.setup_pokemon_evolution_data(
evolved_species=stage_one, min_level=18, held_item=stage_one_held_item)
stage_two_first = self.setup_pokemon_species_data(
name="stg two frst for evo chn",
evolves_from_species=stage_one, evolution_chain=evolution_chain)
stage_two_first_known_move = self.setup_move_data(name="mv for evo chn")
2016-03-05 11:40:41 +00:00
stage_two_first_evolution = self.setup_pokemon_evolution_data(
evolved_species=stage_two_first, min_level=32, known_move=stage_two_first_known_move,)
2015-10-18 23:01:33 +00:00
2016-03-05 11:40:41 +00:00
stage_two_second = self.setup_pokemon_species_data(
name="stg two scnd for evo chn",
evolves_from_species=stage_one, evolution_chain=evolution_chain)
stage_two_second_party_type = self.setup_type_data(name="tp for evo chn")
2016-03-05 11:40:41 +00:00
stage_two_second_evolution = self.setup_pokemon_evolution_data(
evolved_species=stage_two_second, min_level=32, party_type=stage_two_second_party_type)
2015-10-18 23:01:33 +00:00
response = self.client.get('{}/evolution-chain/{}/'.format(API_V2, evolution_chain.pk))
2015-10-18 23:01:33 +00:00
self.assertEqual(response.status_code, status.HTTP_200_OK)
2015-10-18 23:01:33 +00:00
baby_data = response.data['chain']
basic_data = baby_data['evolves_to'][0]
stage_one_data = basic_data['evolves_to'][0]
stage_two_first_data = stage_one_data['evolves_to'][0]
stage_two_second_data = stage_one_data['evolves_to'][1]
2015-10-18 23:01:33 +00:00
# base params
self.assertEqual(response.data['id'], evolution_chain.pk)
# baby trigger params
self.assertEqual(response.data['baby_trigger_item']['name'], baby_trigger_item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['baby_trigger_item']['url'],
'{}{}/item/{}/'.format(TEST_HOST, API_V2, baby_trigger_item.pk))
# baby params
self.assertEqual(baby_data['is_baby'], baby.is_baby)
self.assertEqual(baby_data['species']['name'], baby.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
baby_data['species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, baby.pk))
# basic params
self.assertEqual(basic_data['is_baby'], basic.is_baby)
self.assertEqual(basic_data['species']['name'], basic.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
basic_data['species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, basic.pk))
self.assertEqual(basic_data['evolution_details'][0]['min_level'], basic_evolution.min_level)
2016-03-05 11:40:41 +00:00
self.assertEqual(
basic_data['evolution_details'][0]['location']['name'], basic_location.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
basic_data['evolution_details'][0]['location']['url'],
'{}{}/location/{}/'.format(TEST_HOST, API_V2, basic_location.pk))
# stage one params
self.assertEqual(stage_one_data['is_baby'], stage_one.is_baby)
self.assertEqual(stage_one_data['species']['name'], stage_one.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_one_data['species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, stage_one.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_one_data['evolution_details'][0]['min_level'], stage_one_evolution.min_level)
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_one_data['evolution_details'][0]['held_item']['name'], stage_one_held_item.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_one_data['evolution_details'][0]['held_item']['url'],
'{}{}/item/{}/'.format(TEST_HOST, API_V2, stage_one_held_item.pk))
# stage two first params
self.assertEqual(stage_two_first_data['is_baby'], stage_two_first.is_baby)
self.assertEqual(stage_two_first_data['species']['name'], stage_two_first.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_two_first_data['species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, stage_two_first.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_two_first_data['evolution_details'][0]['min_level'],
2016-03-05 11:40:41 +00:00
stage_two_first_evolution.min_level)
self.assertEqual(
stage_two_first_data['evolution_details'][0]['known_move']['name'],
2016-03-05 11:40:41 +00:00
stage_two_first_known_move.name)
self.assertEqual(
stage_two_first_data['evolution_details'][0]['known_move']['url'],
'{}{}/move/{}/'.format(TEST_HOST, API_V2, stage_two_first_known_move.pk))
# stage two second params
self.assertEqual(stage_two_second_data['is_baby'], stage_two_second.is_baby)
self.assertEqual(stage_two_second_data['species']['name'], stage_two_second.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_two_second_data['species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, stage_two_second.pk))
2016-03-05 11:40:41 +00:00
self.assertEqual(
stage_two_second_data['evolution_details'][0]['min_level'],
2016-03-05 11:40:41 +00:00
stage_two_second_evolution.min_level)
self.assertEqual(
stage_two_second_data['evolution_details'][0]['party_type']['name'],
2016-03-05 11:40:41 +00:00
stage_two_second_party_type.name)
self.assertEqual(
stage_two_second_data['evolution_details'][0]['party_type']['url'],
'{}{}/type/{}/'.format(TEST_HOST, API_V2, stage_two_second_party_type.pk))
2016-03-05 11:40:41 +00:00
# Encounter Tests
def test_encounter_method_api(self):
encounter_method = self.setup_encounter_method_data(name='base encntr mthd')
2016-03-05 11:40:41 +00:00
encounter_method_name = self.setup_encounter_method_name_data(
encounter_method, name='base encntr mthd name')
response = self.client.get('{}/encounter-method/{}/'.format(API_V2, encounter_method.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], encounter_method.pk)
self.assertEqual(response.data['name'], encounter_method.name)
self.assertEqual(response.data['order'], encounter_method.order)
# name params
self.assertEqual(response.data['names'][0]['name'], encounter_method_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], encounter_method_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, encounter_method_name.language.pk))
def test_encounter_condition_value_api(self):
2016-03-05 11:40:41 +00:00
encounter_condition = self.setup_encounter_condition_data(
name='encntr cndtn for base encntr cndtn vlu')
encounter_condition_value = self.setup_encounter_condition_value_data(
encounter_condition, name='base encntr cndtn vlu')
encounter_condition_value_name = self.setup_encounter_condition_value_name_data(
encounter_condition_value, name='base encntr cndtn vlu name')
2016-03-05 11:40:41 +00:00
response = self.client.get('{}/encounter-condition-value/{}/'.format(
API_V2, encounter_condition_value.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], encounter_condition_value.pk)
self.assertEqual(response.data['name'], encounter_condition_value.name)
# name params
self.assertEqual(response.data['names'][0]['name'], encounter_condition_value_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'],
encounter_condition_value_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(
TEST_HOST, API_V2, encounter_condition_value_name.language.pk))
# condition params
self.assertEqual(response.data['condition']['name'], encounter_condition.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['condition']['url'],
'{}{}/encounter-condition/{}/'.format(TEST_HOST, API_V2, encounter_condition.pk))
def test_encounter_condition_api(self):
encounter_condition = self.setup_encounter_condition_data(name='base encntr cndtn')
2016-03-05 11:40:41 +00:00
encounter_condition_name = self.setup_encounter_condition_name_data(
encounter_condition, name='base encntr cndtn name')
encounter_condition_value = self.setup_encounter_condition_value_data(
encounter_condition, name='encntr cndtn vlu for base encntr', is_default=True)
2016-03-05 11:40:41 +00:00
response = self.client.get(
'{}/encounter-condition/{}/'.format(API_V2, encounter_condition.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], encounter_condition.pk)
self.assertEqual(response.data['name'], encounter_condition.name)
# name params
self.assertEqual(response.data['names'][0]['name'], encounter_condition_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], encounter_condition_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, encounter_condition_name.language.pk))
# value params
self.assertEqual(response.data['values'][0]['name'], encounter_condition_value.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['values'][0]['url'],
'{}{}/encounter-condition-value/{}/'.format(
TEST_HOST, API_V2, encounter_condition_value.pk))
2016-03-05 11:40:41 +00:00
# Pal Park Tests
def test_pal_park_area_api(self):
pal_park_area = self.setup_pal_park_area_data(name='base pl prk area')
2016-03-05 11:40:41 +00:00
pal_park_area_name = self.setup_pal_park_area_name_data(
pal_park_area, name='base pl prk area nm')
pokemon_species = self.setup_pokemon_species_data(name='pkmn spcs for pl prk')
2016-03-05 11:40:41 +00:00
pal_park = self.setup_pal_park_data(
pal_park_area=pal_park_area, pokemon_species=pokemon_species, base_score=10, rate=20)
response = self.client.get('{}/pal-park-area/{}/'.format(API_V2, pal_park_area.pk))
self.assertEqual(response.status_code, status.HTTP_200_OK)
# base params
self.assertEqual(response.data['id'], pal_park_area.pk)
self.assertEqual(response.data['name'], pal_park_area.name)
# name params
self.assertEqual(response.data['names'][0]['name'], pal_park_area_name.name)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['names'][0]['language']['name'], pal_park_area_name.language.name)
self.assertEqual(
response.data['names'][0]['language']['url'],
'{}{}/language/{}/'.format(TEST_HOST, API_V2, pal_park_area_name.language.pk))
# encounter params
self.assertEqual(response.data['pokemon_encounters'][0]['base_score'], pal_park.base_score)
self.assertEqual(response.data['pokemon_encounters'][0]['rate'], pal_park.rate)
2016-03-05 11:40:41 +00:00
self.assertEqual(
response.data['pokemon_encounters'][0]['pokemon_species']['name'], pokemon_species.name)
self.assertEqual(
response.data['pokemon_encounters'][0]['pokemon_species']['url'],
'{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk))