2018-10-20 00:05:10 +00:00
|
|
|
import json
|
2015-03-11 20:07:30 +00:00
|
|
|
from rest_framework import status
|
2015-10-18 23:01:33 +00:00
|
|
|
from rest_framework.test import APITestCase
|
2018-10-20 00:05:10 +00:00
|
|
|
from pokemon_v2.models import *
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
# pylint: disable=redefined-builtin
|
2014-12-06 22:57:42 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
TEST_HOST = "http://testserver"
|
|
|
|
API_V2 = "/api/v2"
|
2014-12-06 22:57:42 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
class APIData:
|
2021-07-06 04:58:55 +00:00
|
|
|
"""Data Initializers"""
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
# Gender Data
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_gender_data(cls, name="gndr"):
|
2016-03-05 11:40:41 +00:00
|
|
|
gender = Gender.objects.create(
|
|
|
|
name=name,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
gender.save()
|
|
|
|
|
|
|
|
return gender
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Language Data
|
2015-10-18 23:01:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_language_data(cls, name="lang"):
|
2016-03-05 11:40:41 +00:00
|
|
|
language = Language.objects.create(
|
2021-02-06 22:15:12 +00:00
|
|
|
iso639="ts",
|
|
|
|
iso3166="tt",
|
2016-03-05 11:40:41 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_language_name_data(cls, language, name="lang nm"):
|
|
|
|
local_language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
language_name = LanguageName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Region Data
|
2015-10-23 04:56:01 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_region_data(cls, name="reg"):
|
|
|
|
region = Region.objects.create(name=name)
|
2015-10-23 04:56:01 +00:00
|
|
|
region.save()
|
|
|
|
|
|
|
|
return region
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_region_name_data(cls, region, name="reg 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
|
|
|
region_name = RegionName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2021-07-19 18:00:40 +00:00
|
|
|
def setup_generation_data(cls, region=None, name="gen"):
|
2020-02-17 20:58:07 +00:00
|
|
|
region = region or cls.setup_region_data(name="reg for " + name)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2021-07-19 18:00:40 +00:00
|
|
|
generation = Generation.objects.create(region=region, name=name)
|
2015-10-23 04:56:01 +00:00
|
|
|
generation.save()
|
|
|
|
|
|
|
|
return generation
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_generation_name_data(cls, generation, name="gen nm"):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_version_group_data(cls, name="ver grp", generation=None):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_version_group_region_data(cls, version_group=None, region=None):
|
2016-03-05 11:40:41 +00:00
|
|
|
version_group_region = VersionGroupRegion.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
version_group=version_group, region=region
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
version_group_region.save()
|
|
|
|
|
|
|
|
return version_group_region
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_version_data(cls, version_group=None, name="ver"):
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_version_name_data(cls, version, name="ver 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
|
|
|
version_name = VersionName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
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-03-11 20:07:30 +00:00
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
return version_name
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Ability Data
|
2015-10-18 23:01:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_ability_data(cls, name="ablty", generation=None):
|
|
|
|
generation = generation or cls.setup_generation_data(name="gen for " + name)
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
ability = Ability.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_ability_name_data(cls, ability, name="ablty 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
|
|
|
ability_name = AbilityName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
ability=ability, language=language, name=name
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
ability_name.save()
|
|
|
|
|
|
|
|
return ability_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_ability_effect_text_data(
|
|
|
|
cls, ability, short_effect="ablty shrt efct", effect="ablty efct"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
ability=ability, language=language, short_effect=short_effect, effect=effect
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
ability_effect_text.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return ability_effect_text
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_ability_change_data(cls, ability):
|
2020-02-17 20:58:07 +00:00
|
|
|
version_group = cls.setup_version_group_data(name="ver grp for ablty chng")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
ability_change = AbilityChange.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
ability=ability, version_group=version_group
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
ability_change.save()
|
|
|
|
|
|
|
|
return ability_change
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_ability_change_effect_text_data(
|
|
|
|
cls, ability_change, effect="ablty change efct"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + effect)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
ability_change_effect_text = AbilityChangeEffectText.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
ability_change=ability_change, language=language, effect=effect
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
ability_change_effect_text.save()
|
|
|
|
|
|
|
|
return ability_change_effect_text
|
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_ability_flavor_text_data(cls, ability, flavor_text="ablty flvr txt"):
|
|
|
|
version_group = cls.setup_version_group_data(name="ver grp for " + flavor_text)
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +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
|
|
|
ability_flavor_text = AbilityFlavorText.objects.create(
|
|
|
|
ability=ability,
|
|
|
|
version_group=version_group,
|
|
|
|
language=language,
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_item_attribute_data(cls, name="itm attr"):
|
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
|
|
|
|
|
2015-11-26 01:18:35 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_attribute_name_data(cls, item_attribute, name="itm attr 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_attribute_name = ItemAttributeName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_attribute=item_attribute, name=name, language=language
|
2015-10-18 23:01:33 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
item_attribute_name.save()
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return item_attribute_name
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2015-11-26 01:18:35 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_attribute_description_data(
|
|
|
|
cls, item_attribute, description="itm attr desc"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_attribute=item_attribute, description=description, language=language
|
2015-03-11 20:07:30 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
item_attribute_description.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return item_attribute_description
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-11-26 01:18:35 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_item_attribute_map_data(cls, item, item_attribute):
|
2020-02-17 20:58:07 +00:00
|
|
|
item_attribute_map = ItemAttributeMap(item=item, item_attribute=item_attribute)
|
2015-11-26 01:18:35 +00:00
|
|
|
item_attribute_map.save()
|
|
|
|
|
|
|
|
return item_attribute_map
|
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
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-03-11 20:07:30 +00:00
|
|
|
)
|
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
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_fling_effect_effect_text_data(
|
|
|
|
cls, item_fling_effect, effect="itm flng efct efct txt"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_fling_effect=item_fling_effect, effect=effect, language=language
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
item_fling_effect_effect_text.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
return item_fling_effect_effect_text
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_pocket_data(cls, name="itm pkt"):
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_pocket_name_data(cls, item_pocket, name="itm pkt 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_pocket_name = ItemPocketName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_pocket=item_pocket, name=name, language=language
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
item_pocket_name.save()
|
|
|
|
|
|
|
|
return item_pocket_name
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_item_category_data(cls, name="itm ctgry", item_pocket=None):
|
|
|
|
item_pocket = item_pocket or cls.setup_item_pocket_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="itm pkt for " + name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
2020-02-17 20:58:07 +00:00
|
|
|
|
|
|
|
item_category = ItemCategory.objects.create(name=name, item_pocket=item_pocket)
|
2015-10-27 13:36:33 +00:00
|
|
|
item_category.save()
|
|
|
|
|
|
|
|
return item_category
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_category=item_category, name=name, language=language
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
item_category_name.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return item_category_name
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2016-02-16 06:31:19 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_item_sprites_data(cls, item, default=True):
|
2024-07-30 02:36:43 +00:00
|
|
|
sprite_path = "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/items/%s.png"
|
2016-02-16 06:31:19 +00:00
|
|
|
|
|
|
|
sprites = {
|
2020-02-17 20:58:07 +00:00
|
|
|
"default": sprite_path % item.id if default else None,
|
2016-02-16 06:31:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
item_sprites = ItemSprites.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
item=item, sprites=json.dumps(sprites)
|
2016-02-16 06:31:19 +00:00
|
|
|
)
|
|
|
|
item_sprites.save()
|
|
|
|
|
|
|
|
return item_sprites
|
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_data(
|
|
|
|
cls,
|
|
|
|
item_category=None,
|
|
|
|
item_fling_effect=None,
|
|
|
|
name="itm",
|
|
|
|
cost=100,
|
|
|
|
fling_power=100,
|
|
|
|
):
|
2016-03-05 11:40:41 +00:00
|
|
|
item = Item.objects.create(
|
|
|
|
name=name,
|
|
|
|
item_category=item_category,
|
2018-10-20 00:05:10 +00:00
|
|
|
cost=cost,
|
|
|
|
fling_power=fling_power,
|
2020-02-17 20:58:07 +00:00
|
|
|
item_fling_effect=item_fling_effect,
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
item.save()
|
|
|
|
|
|
|
|
return item
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_name_data(cls, item, name="itm nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +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
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_effect_text_data(
|
|
|
|
cls, item, short_effect="ablty shrt efct", effect="ablty efct"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + effect)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
item_effect_text = ItemEffectText.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
item=item, language=language, short_effect=short_effect, effect=effect
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
item_effect_text.save()
|
|
|
|
|
|
|
|
return item_effect_text
|
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_item_flavor_text_data(cls, item, flavor_text="itm flvr txt"):
|
|
|
|
version_group = cls.setup_version_group_data(name="ver grp for " + flavor_text)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +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,
|
2020-02-17 20:58:07 +00:00
|
|
|
flavor_text=flavor_text,
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
item_flavor_text.save()
|
|
|
|
|
|
|
|
return item_flavor_text
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_item_game_index_data(cls, item, game_index=0):
|
2020-02-17 20:58:07 +00:00
|
|
|
generation = cls.setup_generation_data(name="gen for itm gm indx")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
item_game_index = ItemGameIndex.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
item=item, game_index=game_index, generation=generation
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
item_game_index.save()
|
|
|
|
|
|
|
|
return item_game_index
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Contest Data
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_contest_type_data(cls, name="cntst tp"):
|
2016-03-05 11:40:41 +00:00
|
|
|
contest_type = ContestType.objects.create(
|
|
|
|
name=name,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
contest_type.save()
|
|
|
|
|
|
|
|
return contest_type
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_contest_type_name_data(cls, contest_type, name="cntst tp nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
contest_type_name = ContestTypeName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language, name=name, contest_type=contest_type
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
contest_type_name.save()
|
|
|
|
|
|
|
|
return contest_type_name
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_contest_effect_data(cls, appeal=2, jam=0):
|
2020-02-17 20:58:07 +00:00
|
|
|
contest_effect = ContestEffect.objects.create(appeal=appeal, jam=jam)
|
2015-11-16 03:29:30 +00:00
|
|
|
contest_effect.save()
|
|
|
|
|
|
|
|
return contest_effect
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_contest_effect_flavor_text_data(
|
|
|
|
cls, contest_effect, flavor_text="cntst efct flvr txt"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + flavor_text)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
contest_effect_flavor_text = ContestEffectFlavorText.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language, flavor_text=flavor_text, contest_effect=contest_effect
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
contest_effect_flavor_text.save()
|
|
|
|
|
|
|
|
return contest_effect_flavor_text
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_contest_effect_effect_text_data(
|
|
|
|
cls, contest_effect, effect="cntst efct efct txt"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + effect)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
contest_effect_effect_text = ContestEffectEffectText.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language, effect=effect, contest_effect=contest_effect
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
contest_effect_effect_text.save()
|
|
|
|
|
|
|
|
return contest_effect_effect_text
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
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,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
super_contest_effect.save()
|
|
|
|
|
|
|
|
return super_contest_effect
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_super_contest_effect_flavor_text_data(
|
|
|
|
cls, super_contest_effect, flavor_text="spr cntst efct flvr txt"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + flavor_text)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
super_contest_effect_flavor_text = SuperContestEffectFlavorText.objects.create(
|
|
|
|
language=language,
|
|
|
|
flavor_text=flavor_text,
|
2020-02-17 20:58:07 +00:00
|
|
|
super_contest_effect=super_contest_effect,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
super_contest_effect_flavor_text.save()
|
|
|
|
|
|
|
|
return super_contest_effect_flavor_text
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Berry Data
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_berry_flavor_data(cls, contest_type=None, name="bry flvr"):
|
|
|
|
contest_type = contest_type or cls.setup_contest_type_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="cntst tp for bry flvr"
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
2020-02-17 20:58:07 +00:00
|
|
|
|
|
|
|
berry_flavor = BerryFlavor.objects.create(name=name, contest_type=contest_type)
|
2015-11-16 03:29:30 +00:00
|
|
|
berry_flavor.save()
|
|
|
|
|
|
|
|
return berry_flavor
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_berry_flavor_name_data(cls, berry_flavor, name="bry flvr nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
berry_flavor_name = BerryFlavorName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language, name=name, berry_flavor=berry_flavor
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
berry_flavor_name.save()
|
|
|
|
|
|
|
|
return berry_flavor_name
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_berry_firmness_data(cls, name="bry frmns"):
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_berry_firmness_name_data(cls, berry_firmness, name="bry frmns 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
|
|
|
berry_firmness_name = BerryFirmnessName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_berry_flavor_map_data(cls, berry, berry_flavor, potency=20):
|
2016-03-05 11:40:41 +00:00
|
|
|
berry_flavor_map = BerryFlavorMap(
|
2020-02-17 20:58:07 +00:00
|
|
|
berry=berry, berry_flavor=berry_flavor, potency=potency
|
2015-11-26 01:18:35 +00:00
|
|
|
)
|
|
|
|
berry_flavor_map.save()
|
|
|
|
|
|
|
|
return berry_flavor_map
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_berry_data(
|
|
|
|
cls,
|
|
|
|
berry_firmness=None,
|
|
|
|
item=None,
|
|
|
|
natural_gift_type=None,
|
|
|
|
name="bry",
|
|
|
|
natural_gift_power=50,
|
|
|
|
size=20,
|
|
|
|
max_harvest=5,
|
|
|
|
growth_time=2,
|
|
|
|
soil_dryness=15,
|
|
|
|
smoothness=25,
|
|
|
|
):
|
|
|
|
item = item or cls.setup_item_data(name="itm for " + name)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
berry_firmness = berry_firmness or cls.setup_berry_firmness_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_egg_group_data(cls, name="egg grp"):
|
2016-03-05 11:40:41 +00:00
|
|
|
egg_group = EggGroup.objects.create(
|
|
|
|
name=name,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
egg_group.save()
|
|
|
|
|
|
|
|
return egg_group
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_egg_group_name_data(cls, egg_group, name="ntr nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
egg_group_name = EggGroupName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
egg_group=egg_group, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_growth_rate_data(cls, name="grth rt", formula="pie*1000"):
|
|
|
|
growth_rate = GrowthRate(name=name, formula=formula)
|
2015-10-23 04:56:01 +00:00
|
|
|
growth_rate.save()
|
|
|
|
|
|
|
|
return growth_rate
|
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_growth_rate_description_data(
|
|
|
|
cls, growth_rate, description="grth rt desc"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_location_data(cls, region=None, name="lctn"):
|
|
|
|
region = region or cls.setup_region_data(name="rgn for " + name)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
location = Location(name=name, region=region)
|
2015-10-23 04:56:01 +00:00
|
|
|
location.save()
|
|
|
|
|
|
|
|
return location
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_location_game_index_data(cls, location, game_index=0):
|
2020-02-17 20:58:07 +00:00
|
|
|
generation = cls.setup_generation_data(name="gen for itm gm indx")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
location_game_index = LocationGameIndex.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
location=location, game_index=game_index, generation=generation
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
location_game_index.save()
|
|
|
|
|
|
|
|
return location_game_index
|
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_location_name_data(cls, location, name="lctn 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
|
|
|
location_name = LocationName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language, name=name, location=location
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
location_name.save()
|
|
|
|
|
|
|
|
return location_name
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
location_area = LocationArea(
|
2020-02-17 20:58:07 +00:00
|
|
|
location=location, name=name, game_index=game_index
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
location_area.save()
|
|
|
|
|
|
|
|
return location_area
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_location_area_name_data(cls, location_area, name="lctn area nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
location_area_name = LocationAreaName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language, name=name, location_area=location_area
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_type_data(cls, name="tp", move_damage_class=None, generation=None):
|
2018-10-20 00:05:10 +00:00
|
|
|
move_damage_class = move_damage_class or cls.setup_move_damage_class_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="mv dmg cls for " + name
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +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(
|
2020-02-17 20:58:07 +00:00
|
|
|
name=name, generation=generation, move_damage_class=move_damage_class
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
type.save()
|
|
|
|
|
|
|
|
return type
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_type_name_data(cls, type, name="tp nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +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
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_type_game_index_data(cls, type, game_index=0):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
type=type, game_index=game_index, generation=generation
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
type_game_index.save()
|
|
|
|
|
|
|
|
return type_game_index
|
|
|
|
|
2024-07-30 02:26:15 +00:00
|
|
|
def setup_type_sprites_data(cls, type):
|
|
|
|
game_map = {
|
|
|
|
"generation-iii": [
|
|
|
|
"colosseum",
|
|
|
|
"emerald",
|
|
|
|
"firered-leafgreen",
|
|
|
|
"ruby-saphire",
|
|
|
|
"xd",
|
|
|
|
],
|
|
|
|
"generation-iv": ["diamond-pearl", "heartgold-soulsilver", "platinum"],
|
|
|
|
"generation-v": ["black-2-white-2", "black-white"],
|
|
|
|
"generation-vi": ["omega-ruby-alpha-sapphire", "x-y"],
|
|
|
|
"generation-vii": [
|
|
|
|
"lets-go-pikachu-lets-go-eevee",
|
|
|
|
"sun-moon",
|
|
|
|
"ultra-sun-ultra-moon",
|
|
|
|
],
|
|
|
|
"generation-viii": [
|
|
|
|
"brilliant-diamond-and-shining-pearl",
|
|
|
|
"legends-arceus",
|
|
|
|
"sword-shield",
|
|
|
|
],
|
|
|
|
"generation-ix": ["scarlet-violet"],
|
|
|
|
}
|
|
|
|
sprites = {}
|
|
|
|
for generation in game_map.keys():
|
|
|
|
for game in game_map[generation]:
|
|
|
|
if generation not in sprites:
|
|
|
|
sprites[generation] = {}
|
|
|
|
|
|
|
|
if type.id == 18 and generation.endswith(("-iii", "-iv", "-v")):
|
|
|
|
sprites[generation][game] = None
|
|
|
|
elif type.id == 19 and generation.endswith(
|
|
|
|
("-iii", "-iv", "-v", "-vi", "-vii", "-viii")
|
|
|
|
):
|
|
|
|
sprites[generation][game] = None
|
|
|
|
else:
|
|
|
|
sprites[generation][game] = {
|
|
|
|
"name_icon": f"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/types/{generation}/{game}/{type.id}.png"
|
|
|
|
}
|
|
|
|
|
|
|
|
type_sprites = TypeSprites.objects.create(
|
|
|
|
type=type, sprites=json.dumps(sprites)
|
|
|
|
)
|
|
|
|
type_sprites.save()
|
|
|
|
|
|
|
|
return type_sprites, game_map
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Move Data
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_ailment_data(cls, name="mv almnt"):
|
|
|
|
move_ailment = MoveMetaAilment.objects.create(name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_ailment.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_ailment
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_ailment_name_data(cls, move_ailment, name="mv almnt nm"):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_meta_ailment=move_ailment, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_ailment_name.save()
|
2015-03-11 20:07:30 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_ailment_name
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_battle_style_data(cls, name="mv btl stl"):
|
|
|
|
move_battle_style = MoveBattleStyle.objects.create(name=name)
|
2015-11-16 03:29:30 +00:00
|
|
|
move_battle_style.save()
|
|
|
|
|
|
|
|
return move_battle_style
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_battle_style_name_data(cls, move_battle_style, name="mv almnt nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
move_battle_style_name = MoveBattleStyleName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_battle_style=move_battle_style, language=language, name=name
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
move_battle_style_name.save()
|
|
|
|
|
|
|
|
return move_battle_style_name
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_category_data(cls, name="mv ctgry"):
|
|
|
|
move_category = MoveMetaCategory.objects.create(name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_category.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_category
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_category_description_data(
|
|
|
|
cls, move_category, description="mv ctgry desc"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_meta_category=move_category, language=language, description=description
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_category_description.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_category_description
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_move_effect_data(cls):
|
2016-03-05 11:40:41 +00:00
|
|
|
move_effect = MoveEffect.objects.create()
|
2015-11-16 03:29:30 +00:00
|
|
|
move_effect.save()
|
|
|
|
|
|
|
|
return move_effect
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_effect_effect_text_data(
|
|
|
|
cls,
|
|
|
|
move_effect,
|
|
|
|
effect="mv efct efct txt",
|
|
|
|
short_effect="mv efct shrt efct txt",
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + effect)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
effect_effect_text = MoveEffectEffectText.objects.create(
|
|
|
|
effect=effect,
|
|
|
|
short_effect=short_effect,
|
|
|
|
move_effect=move_effect,
|
2020-02-17 20:58:07 +00:00
|
|
|
language=language,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
effect_effect_text.save()
|
|
|
|
|
|
|
|
return effect_effect_text
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_damage_class_data(cls, name="mv dmg cls"):
|
|
|
|
move_damage_class = MoveDamageClass.objects.create(name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_damage_class.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_damage_class
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_damage_class_name_data(cls, move_damage_class, name="mv dmg cls nm"):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_damage_class=move_damage_class, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_damage_class_name.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_damage_class_name
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_damage_class_description_data(
|
|
|
|
cls, move_damage_class, description="mv dmg cls desc"
|
|
|
|
):
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
description=description,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_damage_class_description.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_damage_class_description
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_learn_method_data(cls, name="mv lrn mthd"):
|
|
|
|
move_learn_method = MoveLearnMethod.objects.create(name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_learn_method.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_learn_method
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_learn_method_name_data(
|
|
|
|
cls, move_learn_method, name="mv lrn mthd nm"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_learn_method=move_learn_method, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_learn_method_name.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_learn_method_name
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_learn_method_description_data(
|
|
|
|
cls, move_learn_method, description="mv lrn mthd desc"
|
|
|
|
):
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
description=description,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_learn_method_description.save()
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_learn_method_description
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_target_data(cls, name="mv trgt"):
|
|
|
|
move_target = MoveTarget.objects.create(name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_target.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_target
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_target_name_data(cls, move_target, name="mv trgt nm"):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_target=move_target, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_target_name.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_target_name
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_target_description_data(
|
|
|
|
cls, move_target, description="mv trgt desc"
|
|
|
|
):
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_target=move_target, language=language, description=description
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move_target_description.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move_target_description
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_contest_combo_data(cls, first_move, second_move):
|
2016-03-05 11:40:41 +00:00
|
|
|
contest_combo = ContestCombo.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
first_move=first_move, second_move=second_move
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
contest_combo.save()
|
|
|
|
|
|
|
|
return contest_combo
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_version_group_move_learn_method_data(
|
|
|
|
cls, version_group=None, move_learn_method=None
|
|
|
|
):
|
2016-03-05 11:40:41 +00:00
|
|
|
version_group_move_learn_method = VersionGroupMoveLearnMethod.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
version_group=version_group, move_learn_method=move_learn_method
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
version_group_move_learn_method.save()
|
|
|
|
|
|
|
|
return version_group_move_learn_method
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
first_move=first_move, second_move=second_move
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
super_contest_combo.save()
|
|
|
|
|
|
|
|
return super_contest_combo
|
|
|
|
|
2016-07-05 08:42:03 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2016-07-05 08:42:03 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
language = cls.setup_language_data(name="lang for " + flavor_text)
|
2016-07-05 08:42:03 +00:00
|
|
|
|
|
|
|
move_flavor_text = MoveFlavorText.objects.create(
|
|
|
|
move=move,
|
|
|
|
version_group=version_group,
|
|
|
|
language=language,
|
2020-02-17 20:58:07 +00:00
|
|
|
flavor_text=flavor_text,
|
2016-07-05 08:42:03 +00:00
|
|
|
)
|
|
|
|
move_flavor_text.save()
|
|
|
|
|
|
|
|
return move_flavor_text
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_data(
|
|
|
|
cls,
|
|
|
|
contest_type=None,
|
|
|
|
contest_effect=None,
|
|
|
|
super_contest_effect=None,
|
|
|
|
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,
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
contest_type = contest_type or cls.setup_contest_type_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="cntst tp for " + name
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
contest_effect = contest_effect or cls.setup_contest_effect_data()
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
super_contest_effect = (
|
|
|
|
super_contest_effect or cls.setup_super_contest_effect_data()
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
generation = generation or cls.setup_generation_data(name="gen for " + name)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
type = type or cls.setup_type_data(name="tp for " + name)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
move_target = move_target or cls.setup_move_target_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="mv trgt for " + name
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
move_damage_class = move_damage_class or cls.setup_move_damage_class_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
super_contest_effect=super_contest_effect,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
move.save()
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
return move
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_name_data(cls, move, name="mv nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
move_name = MoveName.objects.create(move=move, language=language, name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_name.save()
|
|
|
|
|
|
|
|
return move_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_meta_data(
|
|
|
|
cls,
|
|
|
|
move,
|
|
|
|
move_ailment=None,
|
|
|
|
move_category=None,
|
|
|
|
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,
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
move_ailment = move_ailment or cls.setup_move_ailment_data()
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
move_category = move_category or cls.setup_move_category_data()
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
stat_chance=stat_chance,
|
2018-10-19 18:03:48 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
move_meta.save()
|
|
|
|
|
|
|
|
return move_meta
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_change_data(
|
|
|
|
cls,
|
|
|
|
move=None,
|
|
|
|
type=None,
|
|
|
|
move_effect=None,
|
|
|
|
version_group=None,
|
|
|
|
power=20,
|
|
|
|
pp=20,
|
|
|
|
accuracy=80,
|
|
|
|
effect_chance=50,
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
version_group = version_group or cls.setup_version_group_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="ver grp for mv chng"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
move_effect_chance=effect_chance,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
move_change.save()
|
|
|
|
|
|
|
|
return move_change
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_move_effect_change_data(cls, move_effect=None):
|
2020-02-17 20:58:07 +00:00
|
|
|
version_group = cls.setup_version_group_data(name="ver grp for mv chng")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
move_effect_change = MoveEffectChange.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_effect=move_effect, version_group=version_group
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
move_effect_change.save()
|
|
|
|
|
|
|
|
return move_effect_change
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_move_effect_change_effect_text_data(
|
|
|
|
cls, move_effect_change=None, effect="mv efct chng efct txt"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + effect)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
move_effect_change_effect_text = MoveEffectChangeEffectText.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_effect_change=move_effect_change, language=language, effect=effect
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
move_effect_change_effect_text.save()
|
|
|
|
|
|
|
|
return move_effect_change_effect_text
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Stat Data
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_stat_data(cls, name="stt", is_battle_only=True, game_index=1):
|
2018-10-20 00:05:10 +00:00
|
|
|
move_damage_class = cls.setup_move_damage_class_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="mv dmg cls for " + name
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
game_index=game_index,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
stat.save()
|
|
|
|
|
|
|
|
return stat
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_stat_name_data(cls, stat, name="stt nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
stat_name = StatName.objects.create(stat=stat, language=language, name=name)
|
2015-10-27 13:36:33 +00:00
|
|
|
stat_name.save()
|
|
|
|
|
|
|
|
return stat_name
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_move_stat_change_data(cls, move, stat=None, change=1):
|
2020-02-17 20:58:07 +00:00
|
|
|
stat = stat or cls.setup_stat_data(name="stt for mv")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
move_stat_change = MoveMetaStatChange.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
move=move, stat=stat, change=change
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
move_stat_change.save()
|
|
|
|
|
|
|
|
return move_stat_change
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokeathlon_stat_data(cls, name="pkathln stt"):
|
|
|
|
pokeathlon_stat = PokeathlonStat.objects.create(name=name)
|
2015-11-16 03:29:30 +00:00
|
|
|
pokeathlon_stat.save()
|
|
|
|
|
|
|
|
return pokeathlon_stat
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokeathlon_stat_name_data(cls, pokeathlon_stat, name="pkathln stt nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokeathlon_stat_name = PokeathlonStatName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokeathlon_stat=pokeathlon_stat, language=language, name=name
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
pokeathlon_stat_name.save()
|
|
|
|
|
|
|
|
return pokeathlon_stat_name
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Characteristic Data
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_characteristic_data(cls, gene_mod_5=0, stat=None):
|
2020-02-17 20:58:07 +00:00
|
|
|
stat = stat or cls.setup_stat_data(name="stt for char")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
characteristic = Characteristic.objects.create(stat=stat, gene_mod_5=gene_mod_5)
|
2015-11-16 03:29:30 +00:00
|
|
|
characteristic.save()
|
|
|
|
|
|
|
|
return characteristic
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_characteristic_description_data(
|
|
|
|
cls, characteristic, description="char desc"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + description)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
characteristic_description = CharacteristicDescription.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
characteristic=characteristic, language=language, description=description
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
characteristic_description.save()
|
|
|
|
|
|
|
|
return characteristic_description
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Nature Data
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_nature_data(
|
|
|
|
cls,
|
|
|
|
decreased_stat=None,
|
|
|
|
increased_stat=None,
|
|
|
|
likes_flavor=None,
|
|
|
|
hates_flavor=None,
|
|
|
|
name="ntr",
|
|
|
|
game_index=1,
|
|
|
|
):
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
game_index=game_index,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
nature.save()
|
|
|
|
|
|
|
|
return nature
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_nature_name_data(cls, nature, name="ntr nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
nature_name = NatureName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
nature=nature, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
nature_name.save()
|
|
|
|
|
|
|
|
return nature_name
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_nature_pokeathlon_stat_data(
|
|
|
|
cls, nature=None, pokeathlon_stat=None, max_change=1
|
|
|
|
):
|
2016-03-05 11:40:41 +00:00
|
|
|
nature_pokeathlon_stat = NaturePokeathlonStat.objects.create(
|
|
|
|
nature=nature,
|
|
|
|
pokeathlon_stat=pokeathlon_stat,
|
|
|
|
max_change=max_change,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
nature_pokeathlon_stat.save()
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
return nature_pokeathlon_stat
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_nature_battle_style_preference_data(
|
|
|
|
cls,
|
|
|
|
nature=None,
|
|
|
|
move_battle_style=None,
|
|
|
|
low_hp_preference=10,
|
|
|
|
high_hp_preference=20,
|
|
|
|
):
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
high_hp_preference=high_hp_preference,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
nature_battle_style_preference.save()
|
|
|
|
|
|
|
|
return nature_battle_style_preference
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Pokedex Data
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokedex_data(cls, region=None, name="pkdx"):
|
|
|
|
region = region or cls.setup_region_data(name="rgn for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokedex = Pokedex.objects.create(
|
|
|
|
name=name,
|
|
|
|
region=region,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokedex.save()
|
|
|
|
|
|
|
|
return pokedex
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokedex_name_data(cls, pokedex, name="pkdx nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokedex_name = PokedexName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokedex=pokedex, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokedex_name.save()
|
|
|
|
|
|
|
|
return pokedex_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokedex_description_data(cls, pokedex, description="pkdx desc"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + description)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokedex_description = PokedexDescription.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokedex=pokedex, language=language, description=description
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokedex_description.save()
|
|
|
|
|
|
|
|
return pokedex_description
|
|
|
|
|
2015-11-26 01:18:35 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokedex_version_group_data(cls, pokedex, version_group=None):
|
|
|
|
version_group = version_group or cls.setup_language_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="ver grp for pkdx"
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokedex_version_group = PokedexVersionGroup.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokedex=pokedex, version_group=version_group
|
2015-11-26 01:18:35 +00:00
|
|
|
)
|
|
|
|
pokedex_version_group.save()
|
|
|
|
|
|
|
|
return pokedex_version_group
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Pokemon Data
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_habitat_data(cls, name="pkm hbtt"):
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_habitat = PokemonHabitat.objects.create(
|
|
|
|
name=name,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_habitat.save()
|
|
|
|
|
|
|
|
return pokemon_habitat
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_habitat_name_data(cls, pokemon_habitat, name="pkm hbtt nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_habitat_name = PokemonHabitatName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_habitat=pokemon_habitat, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_habitat_name.save()
|
|
|
|
|
|
|
|
return pokemon_habitat_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_color_data(cls, name="pkm clr"):
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_color = PokemonColor.objects.create(
|
|
|
|
name=name,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_color.save()
|
|
|
|
|
|
|
|
return pokemon_color
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_color_name_data(cls, pokemon_color, name="pkm clr nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_color_name = PokemonColorName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_color=pokemon_color, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_color_name.save()
|
|
|
|
|
|
|
|
return pokemon_color_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_shape_data(cls, name="pkm shp"):
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_shape = PokemonShape.objects.create(
|
|
|
|
name=name,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_shape.save()
|
|
|
|
|
|
|
|
return pokemon_shape
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_shape_name_data(
|
|
|
|
cls, pokemon_shape, name="pkm shp nm", awesome_name="pkm shp awsm nm"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_shape_name = PokemonShapeName.objects.create(
|
|
|
|
pokemon_shape=pokemon_shape,
|
|
|
|
language=language,
|
|
|
|
name=name,
|
2020-02-17 20:58:07 +00:00
|
|
|
awesome_name=awesome_name,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_shape_name.save()
|
|
|
|
|
|
|
|
return pokemon_shape_name
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_species_form_description_data(
|
|
|
|
cls, pokemon_species=None, description="pkm spcs frm dscr"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + description)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species_form_description = PokemonSpeciesDescription.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species=pokemon_species, language=language, description=description
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
pokemon_species_form_description.save()
|
|
|
|
|
|
|
|
return pokemon_species_form_description
|
|
|
|
|
2016-02-25 04:55:59 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_species_flavor_text_data(
|
|
|
|
cls, pokemon_species, flavor_text="pkmn spcs flvr txt"
|
|
|
|
):
|
|
|
|
version = cls.setup_version_data(name="ver for " + flavor_text)
|
2016-02-25 04:55:59 +00:00
|
|
|
|
2020-02-17 20:58:07 +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,
|
2020-02-17 20:58:07 +00:00
|
|
|
flavor_text=flavor_text,
|
2016-02-25 04:55:59 +00:00
|
|
|
)
|
|
|
|
pokemon_species_flavor_text.save()
|
|
|
|
|
|
|
|
return pokemon_species_flavor_text
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_species_data(
|
|
|
|
cls,
|
|
|
|
generation=None,
|
|
|
|
evolves_from_species=None,
|
|
|
|
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,
|
2020-08-09 19:35:45 +00:00
|
|
|
is_legendary=False,
|
|
|
|
is_mythical=False,
|
2020-02-17 20:58:07 +00:00
|
|
|
order=1,
|
|
|
|
):
|
|
|
|
generation = generation or cls.setup_generation_data(name="gen for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
growth_rate = growth_rate or cls.setup_growth_rate_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="grth rt for " + name
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_shape = pokemon_shape or cls.setup_pokemon_shape_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkmn shp for " + name
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_color = pokemon_color or cls.setup_pokemon_color_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkmn clr for " + name
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_habitat = pokemon_habitat or cls.setup_pokemon_habitat_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkm hbtt for " + name
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-08-09 19:35:45 +00:00
|
|
|
is_legendary=is_legendary,
|
|
|
|
is_mythical=is_mythical,
|
2020-02-17 20:58:07 +00:00
|
|
|
order=order,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_species.save()
|
|
|
|
|
|
|
|
return pokemon_species
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_species_name_data(
|
|
|
|
cls, pokemon_species, name="pkmn spcs nm", genus="pkmn spcs gns"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species_name = PokemonSpeciesName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species=pokemon_species, language=language, name=name, genus=genus
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_species_name.save()
|
|
|
|
|
|
|
|
return pokemon_species_name
|
2015-11-26 01:18:35 +00:00
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
pokedex_number=entry_number,
|
2018-10-19 18:03:48 +00:00
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
dex_number.save()
|
|
|
|
|
|
|
|
return dex_number
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_egg_group_data(cls, pokemon_species, egg_group):
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_egg_group = PokemonEggGroup(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species=pokemon_species, egg_group=egg_group
|
2015-11-26 01:18:35 +00:00
|
|
|
)
|
|
|
|
pokemon_egg_group.save()
|
|
|
|
|
|
|
|
return pokemon_egg_group
|
2016-03-05 08:26:51 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_data(
|
|
|
|
cls,
|
|
|
|
pokemon_species=None,
|
|
|
|
name="pkmn",
|
|
|
|
height=100,
|
|
|
|
weight=100,
|
|
|
|
base_experience=0,
|
|
|
|
order=1,
|
|
|
|
is_default=False,
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
pokemon_species = pokemon_species or cls.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkmn spcs for " + name
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
is_default=is_default,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon.save()
|
|
|
|
|
|
|
|
return pokemon
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_game_index_data(cls, pokemon, game_index=0):
|
2020-02-17 20:58:07 +00:00
|
|
|
version = cls.setup_version_data(name="ver for pkmn gm indx")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_game_index = PokemonGameIndex.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon=pokemon, game_index=game_index, version=version
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
pokemon_game_index.save()
|
|
|
|
|
|
|
|
return pokemon_game_index
|
|
|
|
|
2016-02-16 06:31:19 +00:00
|
|
|
@classmethod
|
|
|
|
def setup_pokemon_form_sprites_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
cls,
|
|
|
|
pokemon_form,
|
|
|
|
front_default=True,
|
|
|
|
front_shiny=False,
|
|
|
|
back_default=False,
|
|
|
|
back_shiny=False,
|
|
|
|
):
|
2023-11-08 10:11:56 +00:00
|
|
|
sprite_path = "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/%s.png"
|
2016-02-16 06:31:19 +00:00
|
|
|
|
|
|
|
sprites = {
|
2020-02-17 20:58:07 +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-02-16 06:31:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_form_sprites = PokemonFormSprites.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_form=pokemon_form, sprites=json.dumps(sprites)
|
2016-02-16 06:31:19 +00:00
|
|
|
)
|
|
|
|
pokemon_form_sprites.save()
|
|
|
|
|
|
|
|
return pokemon_form_sprites
|
|
|
|
|
2020-04-25 13:25:00 +00:00
|
|
|
@classmethod
|
|
|
|
def setup_pokemon_form_type_data(cls, pokemon_form, type=None, slot=1):
|
|
|
|
type = type or cls.setup_type_data(name="tp for pkmn frm")
|
|
|
|
|
|
|
|
form_type = PokemonFormType(pokemon_form=pokemon_form, type=type, slot=slot)
|
|
|
|
form_type.save()
|
|
|
|
|
|
|
|
return form_type
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_form_data(
|
|
|
|
cls,
|
|
|
|
pokemon,
|
|
|
|
name="pkmn nrml frm",
|
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
order=order,
|
2018-10-19 18:03:48 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_form.save()
|
|
|
|
|
|
|
|
return pokemon_form
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_ability_data(cls, pokemon, ability=None, is_hidden=False, slot=1):
|
2020-02-17 20:58:07 +00:00
|
|
|
ability = ability or cls.setup_ability_data(name="ablty for pkmn")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_ability = PokemonAbility(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon=pokemon, ability=ability, is_hidden=is_hidden, slot=slot
|
2018-10-19 18:03:48 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_ability.save()
|
|
|
|
|
|
|
|
return pokemon_ability
|
|
|
|
|
2023-02-16 23:18:04 +00:00
|
|
|
@classmethod
|
2023-02-16 23:53:48 +00:00
|
|
|
def setup_pokemon_past_ability_data(
|
|
|
|
cls, pokemon, generation, ability=None, is_hidden=False, slot=1
|
|
|
|
):
|
2023-02-27 18:19:36 +00:00
|
|
|
ability = ability or cls.setup_ability_data(name="ablty for pkmn")
|
2023-02-16 23:18:04 +00:00
|
|
|
|
|
|
|
pokemon_ability_past = PokemonAbilityPast(
|
2023-02-16 23:53:48 +00:00
|
|
|
pokemon=pokemon,
|
|
|
|
generation=generation,
|
|
|
|
ability=ability,
|
|
|
|
is_hidden=is_hidden,
|
|
|
|
slot=slot,
|
2023-02-16 23:18:04 +00:00
|
|
|
)
|
|
|
|
pokemon_ability_past.save()
|
|
|
|
|
|
|
|
return pokemon_ability_past
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_stat_data(cls, pokemon, base_stat=10, effort=10):
|
2020-02-17 20:58:07 +00:00
|
|
|
stat = cls.setup_stat_data(name="stt for pkmn")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_stat = PokemonStat(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon=pokemon, stat=stat, base_stat=base_stat, effort=effort
|
2018-10-19 18:03:48 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_stat.save()
|
|
|
|
|
|
|
|
return pokemon_stat
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_type_data(cls, pokemon, type=None, slot=1):
|
2020-02-17 20:58:07 +00:00
|
|
|
type = type or cls.setup_type_data(name="tp for pkmn")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_type = PokemonType(pokemon=pokemon, type=type, slot=slot)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_type.save()
|
|
|
|
|
|
|
|
return pokemon_type
|
|
|
|
|
2019-11-30 21:00:26 +00:00
|
|
|
@classmethod
|
|
|
|
def setup_pokemon_past_type_data(cls, pokemon, generation, type=None, slot=1):
|
2021-02-06 21:52:36 +00:00
|
|
|
type = type or cls.setup_type_data(name="tp for pkmn")
|
2019-11-30 21:00:26 +00:00
|
|
|
|
|
|
|
pokemon_type_past = PokemonTypePast(
|
2021-02-06 21:52:36 +00:00
|
|
|
pokemon=pokemon, generation=generation, type=type, slot=slot
|
2019-11-30 21:00:26 +00:00
|
|
|
)
|
|
|
|
pokemon_type_past.save()
|
|
|
|
|
|
|
|
return pokemon_type_past
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_item_data(cls, pokemon=None, item=None, version=None, rarity=50):
|
2020-02-17 20:58:07 +00:00
|
|
|
item = item or cls.setup_item_data(name="itm for pkmn")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon = pokemon or cls.setup_pokemon_data(name="pkmn for pkmn")
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
version = version or cls.setup_version_data(name="ver grp for pkmn itm")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_item = PokemonItem(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon=pokemon, version=version, item=item, rarity=rarity
|
2018-10-19 18:03:48 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_item.save()
|
|
|
|
|
|
|
|
return pokemon_item
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_pokemon_move_data(cls, pokemon, move, version_group, level=0, order=1):
|
|
|
|
move_learn_method = cls.setup_move_learn_method_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="mv lrn mthd for pkmn"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
order=order,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_move.save()
|
|
|
|
|
|
|
|
return pokemon_move
|
|
|
|
|
2016-02-16 06:31:19 +00:00
|
|
|
@classmethod
|
|
|
|
def setup_pokemon_sprites_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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,
|
|
|
|
):
|
2023-11-08 10:11:56 +00:00
|
|
|
sprite_path = "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/%s.png"
|
2023-12-16 04:26:19 +00:00
|
|
|
showdown_path = "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/showdown/%s.png"
|
|
|
|
|
|
|
|
showdown = {
|
|
|
|
"front_default": showdown_path % pokemon.id if front_default else None,
|
2024-04-08 14:05:29 +00:00
|
|
|
"front_female": (
|
|
|
|
showdown_path % f"female/{pokemon.id}" if front_female else None
|
|
|
|
),
|
|
|
|
"front_shiny": (
|
|
|
|
showdown_path % f"shiny/{pokemon.id}" if front_shiny else None
|
|
|
|
),
|
|
|
|
"front_shiny_female": (
|
|
|
|
showdown_path % f"shiny/female/{pokemon.id}"
|
|
|
|
if front_shiny_female
|
|
|
|
else None
|
|
|
|
),
|
|
|
|
"back_default": (
|
|
|
|
showdown_path % f"back/{pokemon.id}" if back_default else None
|
|
|
|
),
|
|
|
|
"back_female": (
|
|
|
|
showdown_path % f"back/female/{pokemon.id}" if back_female else None
|
|
|
|
),
|
|
|
|
"back_shiny": (
|
|
|
|
showdown_path % f"back/shiny/{pokemon.id}" if back_shiny else None
|
|
|
|
),
|
|
|
|
"back_shiny_female": (
|
|
|
|
showdown_path % f"back/shiny/female/{pokemon.id}"
|
|
|
|
if back_shiny_female
|
|
|
|
else None
|
|
|
|
),
|
2023-12-16 04:26:19 +00:00
|
|
|
}
|
2016-02-16 06:31:19 +00:00
|
|
|
|
|
|
|
sprites = {
|
2020-02-17 20:58:07 +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,
|
2024-04-08 14:05:29 +00:00
|
|
|
"front_shiny_female": (
|
|
|
|
sprite_path % pokemon.id if front_shiny_female else None
|
|
|
|
),
|
2020-02-17 20:58:07 +00:00
|
|
|
"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,
|
2024-04-08 14:05:29 +00:00
|
|
|
"back_shiny_female": (
|
|
|
|
sprite_path % pokemon.id if back_shiny_female else None
|
|
|
|
),
|
2016-02-16 06:31:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_sprites = PokemonSprites.objects.create(
|
2023-12-16 04:26:19 +00:00
|
|
|
pokemon=pokemon,
|
|
|
|
sprites=json.dumps(sprites | {"other": {"showdown": showdown}}),
|
2016-02-16 06:31:19 +00:00
|
|
|
)
|
|
|
|
pokemon_sprites.save()
|
|
|
|
|
|
|
|
return pokemon_sprites
|
2024-02-02 19:02:51 +00:00
|
|
|
|
2024-02-02 18:45:39 +00:00
|
|
|
@classmethod
|
|
|
|
def setup_pokemon_cries_data(cls, pokemon, latest=True, legacy=False):
|
2024-02-02 19:02:51 +00:00
|
|
|
cries_path = (
|
|
|
|
"https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/%s.ogg"
|
|
|
|
)
|
2024-02-02 18:45:39 +00:00
|
|
|
cries = {
|
|
|
|
"latest": cries_path % f"latest/{pokemon.id}" if latest else None,
|
|
|
|
"legacy": cries_path % f"legacy/{pokemon.id}" if legacy else None,
|
|
|
|
}
|
|
|
|
pokemon_cries = PokemonCries.objects.create(
|
2024-02-02 19:02:51 +00:00
|
|
|
pokemon=pokemon, cries=json.dumps(cries)
|
2024-02-02 18:45:39 +00:00
|
|
|
)
|
|
|
|
pokemon_cries.save()
|
|
|
|
return pokemon_cries
|
2016-02-16 06:31:19 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Evolution Data
|
2015-10-27 13:36:33 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_evolution_trigger_data(cls, name="evltn trgr"):
|
2016-03-05 11:40:41 +00:00
|
|
|
evolution_trigger = EvolutionTrigger.objects.create(
|
|
|
|
name=name,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
evolution_trigger.save()
|
|
|
|
|
|
|
|
return evolution_trigger
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_evolution_trigger_name_data(cls, evolution_trigger, name="evltn trgr nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
evolution_trigger_name = EvolutionTriggerName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolution_trigger=evolution_trigger, language=language, name=name
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
evolution_trigger_name.save()
|
|
|
|
|
|
|
|
return evolution_trigger_name
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_evolution_chain_data(cls, baby_trigger_item=None):
|
2016-03-05 11:40:41 +00:00
|
|
|
evolution_chain = EvolutionChain.objects.create(
|
2015-10-27 13:36:33 +00:00
|
|
|
baby_trigger_item=baby_trigger_item,
|
|
|
|
)
|
|
|
|
evolution_chain.save()
|
|
|
|
|
|
|
|
return evolution_chain
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pokemon_evolution_data(
|
|
|
|
cls,
|
|
|
|
evolved_species=None,
|
|
|
|
evolution_trigger=None,
|
|
|
|
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,
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
evolved_species = evolved_species or cls.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkmn spcs for pkmn evltn"
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
evolution_trigger = evolution_trigger or cls.setup_evolution_trigger_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="evltn trgr for pkmn evltn"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
turn_upside_down=turn_upside_down,
|
2015-10-27 13:36:33 +00:00
|
|
|
)
|
|
|
|
pokemon_evolution.save()
|
|
|
|
|
|
|
|
return pokemon_evolution
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Encounter Data
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_method_data(cls, name="encntr mthd", order=0):
|
|
|
|
encounter_method = EncounterMethod.objects.create(name=name, order=order)
|
2015-11-16 03:29:30 +00:00
|
|
|
encounter_method.save()
|
|
|
|
|
|
|
|
return encounter_method
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_method_name_data(cls, encounter_method, name="encntr mthd nm"):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_method_name = EncounterMethodName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_method=encounter_method, language=language, name=name
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter_method_name.save()
|
|
|
|
|
|
|
|
return encounter_method_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_condition_data(cls, name="encntr cndtn"):
|
|
|
|
encounter_condition = EncounterCondition.objects.create(name=name)
|
2015-11-16 03:29:30 +00:00
|
|
|
encounter_condition.save()
|
|
|
|
|
|
|
|
return encounter_condition
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_condition_name_data(
|
|
|
|
cls, encounter_condition, name="encntr cndtn nm"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition_name = EncounterConditionName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_condition=encounter_condition, language=language, name=name
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter_condition_name.save()
|
|
|
|
|
|
|
|
return encounter_condition_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_condition_value_data(
|
|
|
|
cls, encounter_condition, name="encntr cndtn vlu", is_default=False
|
|
|
|
):
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition_value = EncounterConditionValue.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_condition=encounter_condition, name=name, is_default=is_default
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter_condition_value.save()
|
|
|
|
|
|
|
|
return encounter_condition_value
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_condition_value_name_data(
|
|
|
|
cls, encounter_condition_value, name="encntr cndtn vlu nm"
|
|
|
|
):
|
|
|
|
language = cls.setup_language_data(name="lang for " + name)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition_value_name = EncounterConditionValueName.objects.create(
|
|
|
|
encounter_condition_value=encounter_condition_value,
|
|
|
|
language=language,
|
2020-02-17 20:58:07 +00:00
|
|
|
name=name,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter_condition_value_name.save()
|
|
|
|
|
|
|
|
return encounter_condition_value_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter=encounter, encounter_condition_value=encounter_condition_value
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter_condition_value_map.save()
|
|
|
|
|
|
|
|
return encounter_condition_value_map
|
|
|
|
|
|
|
|
@classmethod
|
2018-10-20 00:05:10 +00:00
|
|
|
def setup_encounter_slot_data(cls, encounter_method=None, slot=0, rarity=0):
|
|
|
|
encounter_method = encounter_method or cls.setup_encounter_method_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="encntr mthd for encntr slt"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
version_group = cls.setup_version_group_data(name="ver grp for encntr slt")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_slot = EncounterSlot.objects.create(
|
|
|
|
encounter_method=encounter_method,
|
|
|
|
version_group=version_group,
|
|
|
|
slot=slot,
|
2020-02-17 20:58:07 +00:00
|
|
|
rarity=rarity,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter_slot.save()
|
|
|
|
|
|
|
|
return encounter_slot
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_location_area_encounter_rate_data(
|
|
|
|
cls, location_area, encounter_method, rate=0
|
|
|
|
):
|
|
|
|
version = cls.setup_version_data(name="ver for lctn area")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
rate=rate,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
location_area_encounter_rate.save()
|
|
|
|
|
|
|
|
return location_area_encounter_rate
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_encounter_data(
|
|
|
|
cls,
|
|
|
|
location_area=None,
|
|
|
|
encounter_slot=None,
|
|
|
|
pokemon=None,
|
|
|
|
version=None,
|
|
|
|
min_level=10,
|
|
|
|
max_level=15,
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
location_area = location_area or cls.setup_location_area_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="ver for encntr"
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2018-10-20 00:05:10 +00:00
|
|
|
encounter_slot = encounter_slot or cls.setup_encounter_slot_data()
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon = pokemon or cls.setup_pokemon_data(name="pkmn for encntr")
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
version = version or cls.setup_version_data(name="ver for encntr")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
max_level=max_level,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
encounter.save()
|
|
|
|
|
|
|
|
return encounter
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Pal Park Data
|
2015-11-16 03:29:30 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pal_park_area_data(cls, name="pl prk area"):
|
|
|
|
pal_park_area = PalParkArea.objects.create(name=name)
|
2015-11-16 03:29:30 +00:00
|
|
|
pal_park_area.save()
|
|
|
|
|
|
|
|
return pal_park_area
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pal_park_area_name = PalParkAreaName.objects.create(
|
2020-02-17 20:58:07 +00:00
|
|
|
pal_park_area=pal_park_area, language=language, name=name
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
pal_park_area_name.save()
|
|
|
|
|
|
|
|
return pal_park_area_name
|
|
|
|
|
|
|
|
@classmethod
|
2020-02-17 20:58:07 +00:00
|
|
|
def setup_pal_park_data(
|
|
|
|
cls, pokemon_species=None, pal_park_area=None, base_score=10, rate=10
|
|
|
|
):
|
2018-10-20 00:05:10 +00:00
|
|
|
pal_park_area = pal_park_area or cls.setup_pal_park_area_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pl prk area"
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
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,
|
2020-02-17 20:58:07 +00:00
|
|
|
rate=rate,
|
2015-11-16 03:29:30 +00:00
|
|
|
)
|
|
|
|
pal_park.save()
|
|
|
|
|
|
|
|
return pal_park
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Tests
|
2015-11-26 01:18:35 +00:00
|
|
|
class APITests(APIData, APITestCase):
|
2018-10-20 00:05:10 +00:00
|
|
|
# Gender Tests
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_gender_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/gender/{}/".format(API_V2, gender.pk))
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], gender.pk)
|
|
|
|
self.assertEqual(response.data["name"], gender.name)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species_details"][0]["rate"],
|
|
|
|
pokemon_species.gender_rate,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species_details"][0]["pokemon_species"]["name"],
|
|
|
|
pokemon_species.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["required_for_evolution"][0]["name"], evolved_species.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_language_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
language = self.setup_language_data(name="base lang")
|
|
|
|
language_name = self.setup_language_name_data(language, name="base lang name")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/language/{}/".format(API_V2, language.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], language_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
language_name.local_language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, language_name.local_language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Region Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_region_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
region = self.setup_region_data(name="base reg")
|
|
|
|
region_name = self.setup_region_name_data(region, name="base reg name")
|
2015-11-26 01:18:35 +00:00
|
|
|
location = self.setup_location_data(region=region, name="lctn for base rgn")
|
2020-02-17 20:58:07 +00:00
|
|
|
generation = self.setup_generation_data(
|
|
|
|
region=region, name="gnrtn for base rgn"
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/region/{}/".format(API_V2, region.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], region.pk)
|
|
|
|
self.assertEqual(response.data["name"], region.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], region_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], region_name.language.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, region_name.language.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# location params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["locations"][0]["name"], location.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["locations"][0]["url"],
|
|
|
|
"{}{}/location/{}/".format(TEST_HOST, API_V2, location.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# generation params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["main_generation"]["name"], generation.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["main_generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(TEST_HOST, API_V2, generation.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# pokedex params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["pokedexes"][0]["name"], pokedex.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokedexes"][0]["url"],
|
|
|
|
"{}{}/pokedex/{}/".format(TEST_HOST, API_V2, pokedex.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# version group params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["version_groups"][0]["name"], version_group.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["version_groups"][0]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(TEST_HOST, API_V2, version_group.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Generation Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_generation_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="ver grp for base gen", generation=generation
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/generation/{}/".format(API_V2, generation.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], generation.pk)
|
|
|
|
self.assertEqual(response.data["name"], generation.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], generation_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], generation_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, generation_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# region params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["main_region"]["name"], generation.region.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["main_region"]["url"],
|
|
|
|
"{}{}/region/{}/".format(TEST_HOST, API_V2, generation.region.pk),
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
# ability params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["abilities"][0]["name"], ability.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["abilities"][0]["url"],
|
|
|
|
"{}{}/ability/{}/".format(TEST_HOST, API_V2, ability.pk),
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["moves"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, move.pk),
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
# type params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["types"][0]["name"], type.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["version_groups"][0]["name"], version_group.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["version_groups"][0]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(TEST_HOST, API_V2, version_group.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Version Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_version_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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")
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/version/{}/".format(API_V2, version.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], version.pk)
|
|
|
|
self.assertEqual(response.data["name"], version.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, version_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# version group params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["version_group"]["name"], version.version_group.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["version_group"]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(
|
|
|
|
TEST_HOST, API_V2, version.version_group.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_version_group_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2020-02-17 20:58:07 +00:00
|
|
|
pokedex = self.setup_pokedex_data(name="pkdx for base ver group")
|
|
|
|
self.setup_pokedex_version_group_data(
|
|
|
|
pokedex=pokedex, version_group=version_group
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/version-group/{}/".format(API_V2, version_group.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], version_group.pk)
|
|
|
|
self.assertEqual(response.data["name"], version_group.name)
|
|
|
|
self.assertEqual(response.data["order"], version_group.order)
|
2015-11-16 03:29:30 +00:00
|
|
|
# version params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["versions"][0]["name"], version.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["versions"][0]["url"],
|
|
|
|
"{}{}/version/{}/".format(TEST_HOST, API_V2, version.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# generation params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["generation"]["name"], version_group.generation.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, version_group.generation.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# region params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["regions"][0]["name"], region.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["regions"][0]["url"],
|
|
|
|
"{}{}/region/{}/".format(TEST_HOST, API_V2, region.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# move learn method params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["move_learn_methods"][0]["name"], move_learn_method.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["move_learn_methods"][0]["url"],
|
|
|
|
"{}{}/move-learn-method/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_learn_method.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# pokedex group
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["pokedexes"][0]["name"], pokedex.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokedexes"][0]["url"],
|
|
|
|
"{}{}/pokedex/{}/".format(TEST_HOST, API_V2, pokedex.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Egg Group Tests
|
2015-11-26 01:18:35 +00:00
|
|
|
def test_egg_group_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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"
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
pokemon_species = self.setup_pokemon_species_data()
|
2020-02-17 20:58:07 +00:00
|
|
|
self.setup_pokemon_egg_group_data(
|
|
|
|
pokemon_species=pokemon_species, egg_group=egg_group
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/egg-group/{}/".format(API_V2, egg_group.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], egg_group.pk)
|
|
|
|
self.assertEqual(response.data["name"], egg_group.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], egg_group_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], egg_group_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, egg_group_name.language.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon_species"][0]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Ability Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_ability_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
ability, flavor_text="base flvr txt"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/ability/{}/".format(API_V2, ability.pk))
|
2016-03-05 08:26:51 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], ability_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], ability_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["effect"], ability_effect_text.effect
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["effect_entries"][0]["short_effect"],
|
|
|
|
ability_effect_text.short_effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["name"],
|
|
|
|
ability_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, ability_effect_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# flavor text params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["flavor_text"],
|
|
|
|
ability_flavor_text.flavor_text,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["version_group"]["name"],
|
|
|
|
ability_flavor_text.version_group.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["name"],
|
|
|
|
ability_flavor_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, ability_flavor_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# generation params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["generation"]["name"], ability.generation.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(TEST_HOST, API_V2, ability.generation.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# change params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["version_group"]["name"],
|
|
|
|
ability_change.version_group.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["effect_entries"][0]["effect"],
|
|
|
|
ability_change_effect_text.effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["effect_entries"][0]["language"]["name"],
|
|
|
|
ability_change_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["effect_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, ability_change_effect_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# pokemon params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon"][0]["pokemon"]["url"],
|
|
|
|
"{}{}/pokemon/{}/".format(TEST_HOST, API_V2, pokemon.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Item Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_item_attribute_api(self):
|
|
|
|
# item attribute data
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_attribute, name="base itm attr nm"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
item_attribute_description = self.setup_item_attribute_description_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_attribute, description="base itm attr desc"
|
|
|
|
)
|
|
|
|
item = self.setup_item_data(name="itm fr base itm attr")
|
2015-11-26 01:18:35 +00:00
|
|
|
self.setup_item_attribute_map_data(item_attribute=item_attribute, item=item)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/item-attribute/{}/".format(API_V2, item_attribute.pk)
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], item_attribute.pk)
|
|
|
|
self.assertEqual(response.data["name"], item_attribute.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], item_attribute_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
item_attribute_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, item_attribute_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# description params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
item_attribute_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
item_attribute_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, item_attribute_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# item params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["items"][0]["name"], item.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["items"][0]["url"],
|
|
|
|
"{}{}/item/{}/".format(TEST_HOST, API_V2, item.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_item_category_api(self):
|
|
|
|
# item category data
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_category, name="base itm ctgry nm"
|
|
|
|
)
|
|
|
|
item = self.setup_item_data(
|
|
|
|
item_category=item_category, name="itm fr base itm ctgry"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/item-category/{}/".format(API_V2, item_category.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], item_category.pk)
|
|
|
|
self.assertEqual(response.data["name"], item_category.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], item_category_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
item_category_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, item_category_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# pocket params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pocket"]["name"], item_category.item_pocket.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pocket"]["url"],
|
|
|
|
"{}{}/item-pocket/{}/".format(
|
|
|
|
TEST_HOST, API_V2, item_category.item_pocket.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# item params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["items"][0]["name"], item.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["items"][0]["url"],
|
|
|
|
"{}{}/item/{}/".format(TEST_HOST, API_V2, item.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_item_fling_effect_api(self):
|
|
|
|
# item category data
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_fling_effect, effect="base itm flng efct nm"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
item = self.setup_item_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
item_fling_effect=item_fling_effect, name="itm fr base itm attr"
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/item-fling-effect/{}/".format(API_V2, item_fling_effect.pk)
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], item_fling_effect.pk)
|
|
|
|
self.assertEqual(response.data["name"], item_fling_effect.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# description params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["effect"],
|
|
|
|
item_fling_effect_effect_text.effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["name"],
|
|
|
|
item_fling_effect_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# item params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["items"][0]["name"], item.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
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"
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/item-pocket/{}/".format(API_V2, item_pocket.pk))
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], item_pocket.pk)
|
|
|
|
self.assertEqual(response.data["name"], item_pocket.name)
|
2015-10-23 04:56:01 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], item_pocket_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
item_pocket_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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):
|
2020-02-17 20:58:07 +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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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()
|
2015-11-16 03:29:30 +00:00
|
|
|
item_game_index = self.setup_item_game_index_data(item, game_index=10)
|
2016-02-16 06:31:19 +00:00
|
|
|
item_sprites = self.setup_item_sprites_data(item)
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon = self.setup_pokemon_data(name="pkmn for base itm")
|
2015-11-26 01:18:35 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
item_attribute_map = ItemAttributeMap(item=item, item_attribute=item_attribute)
|
2015-10-23 04:56:01 +00:00
|
|
|
item_attribute_map.save()
|
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], item_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], item_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["text"],
|
|
|
|
item_flavor_text.flavor_text,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["version_group"]["name"],
|
|
|
|
item_flavor_text.version_group.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["name"],
|
|
|
|
item_flavor_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, item_flavor_text.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# effect text params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["effect"], item_effect_text.effect
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["effect_entries"][0]["short_effect"],
|
|
|
|
item_effect_text.short_effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["name"],
|
|
|
|
item_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["category"]["name"], item_category.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["fling_effect"]["name"], item_fling_effect.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["attributes"][0]["name"], item_attribute.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["attributes"][0]["url"],
|
|
|
|
"{}{}/item-attribute/{}/".format(TEST_HOST, API_V2, item_attribute.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# game indices params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["game_index"], item_game_index.game_index
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["game_indices"][0]["generation"]["name"],
|
|
|
|
item_game_index.generation.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, item_game_index.generation.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# held by params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_by_pokemon"][0]["pokemon"]["name"], pokemon.name
|
|
|
|
)
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_by_pokemon"][0]["version_details"][0]["rarity"],
|
|
|
|
pokemon_item.rarity,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_by_pokemon"][0]["version_details"][0]["version"][
|
|
|
|
"name"
|
|
|
|
],
|
|
|
|
pokemon_item.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_by_pokemon"][0]["version_details"][0]["version"]["url"],
|
|
|
|
"{}{}/version/{}/".format(TEST_HOST, API_V2, pokemon_item.version.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# baby trigger params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["baby_trigger_for"]["url"],
|
|
|
|
"{}{}/evolution-chain/{}/".format(TEST_HOST, API_V2, evolution_chain.pk),
|
|
|
|
)
|
2023-11-26 13:51:08 +00:00
|
|
|
|
2024-07-30 02:36:43 +00:00
|
|
|
sprites_data = json.loads(item_sprites.sprites)
|
|
|
|
response_sprites_data = json.loads(response.data["sprites"])
|
2023-11-26 13:51:08 +00:00
|
|
|
|
2016-02-16 06:31:19 +00:00
|
|
|
# sprites
|
2024-07-30 02:36:43 +00:00
|
|
|
self.assertEqual(
|
|
|
|
sprites_data["default"],
|
|
|
|
response_sprites_data["default"],
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2023-11-26 13:51:08 +00:00
|
|
|
sprites_data["default"],
|
2023-11-08 10:11:56 +00:00
|
|
|
"{}".format(sprites_data["default"]),
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
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):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/berry-firmness/{}/".format(API_V2, berry_firmness.pk)
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], berry_firmness.pk)
|
|
|
|
self.assertEqual(response.data["name"], berry_firmness.name)
|
2015-10-23 04:56:01 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], berry_firmness_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
berry_firmness_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, berry_firmness_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# berry params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["berries"][0]["name"], berry.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["berries"][0]["url"],
|
|
|
|
"{}{}/berry/{}/".format(TEST_HOST, API_V2, berry.pk),
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_berry_flavor_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
berry=berry, berry_flavor=berry_flavor, potency=50
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/berry-flavor/{}/".format(API_V2, berry_flavor.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], berry_flavor.pk)
|
|
|
|
self.assertEqual(response.data["name"], berry_flavor.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], berry_flavor_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
berry_flavor_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, berry_flavor_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# contest type params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_type"]["name"], berry_flavor.contest_type.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["contest_type"]["url"],
|
|
|
|
"{}{}/contest-type/{}/".format(
|
|
|
|
TEST_HOST, API_V2, berry_flavor.contest_type.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# berry params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["berries"][0]["potency"], berry_flavor_map.potency
|
|
|
|
)
|
|
|
|
self.assertEqual(response.data["berries"][0]["berry"]["name"], berry.name)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["berries"][0]["berry"]["url"],
|
|
|
|
"{}{}/berry/{}/".format(TEST_HOST, API_V2, berry.pk),
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2015-11-26 01:18:35 +00:00
|
|
|
def test_berry_api(self):
|
|
|
|
type = self.setup_type_data(name="tp fr base bry")
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/berry/{}/".format(API_V2, berry.pk))
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
|
|
|
self.assertEqual(response.data["size"], berry.size)
|
|
|
|
self.assertEqual(response.data["smoothness"], berry.smoothness)
|
|
|
|
self.assertEqual(response.data["soil_dryness"], berry.soil_dryness)
|
2015-10-23 04:56:01 +00:00
|
|
|
# firmness params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["firmness"]["name"], berry.berry_firmness.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["item"]["name"], berry.item.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["item"]["url"],
|
|
|
|
"{}{}/item/{}/".format(TEST_HOST, API_V2, berry.item.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# flavor params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavors"][0]["potency"], berry_flavor_map.potency
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["flavors"][0]["flavor"]["name"], berry_flavor.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["flavors"][0]["flavor"]["url"],
|
|
|
|
"{}{}/berry-flavor/{}/".format(TEST_HOST, API_V2, berry_flavor.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# natural gift type
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["natural_gift_type"]["name"], type.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
growth_rate, description="base grth rt desc"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species = self.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkmn spcs for grth rt", growth_rate=growth_rate
|
|
|
|
)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
# map item attribute to item
|
2020-02-17 20:58:07 +00:00
|
|
|
experience = Experience(growth_rate=growth_rate, level=10, experience=3000)
|
2015-10-23 04:56:01 +00:00
|
|
|
experience.save()
|
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/growth-rate/{}/".format(API_V2, growth_rate.pk))
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
growth_rate_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
growth_rate_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["levels"][0]["level"], experience.level)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["levels"][0]["experience"], experience.experience
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
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):
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
2020-02-17 20:58:07 +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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], location.pk)
|
|
|
|
self.assertEqual(response.data["name"], location.name)
|
2015-10-23 04:56:01 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["region"]["name"], location.region.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["region"]["url"],
|
|
|
|
"{}{}/region/{}/".format(TEST_HOST, API_V2, location.region.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# game indices params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["game_index"],
|
|
|
|
location_game_index.game_index,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["generation"]["name"],
|
|
|
|
location_game_index.generation.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, location_game_index.generation.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
def test_location_area_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
location = self.setup_location_data(name="lctn for base lctn area")
|
2015-11-16 03:29:30 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
location_area, name="base lctn area name"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
location_area, encounter_method, rate=20
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species1 = self.setup_pokemon_species_data(name="spcs for pkmn1")
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon1 = self.setup_pokemon_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon=pokemon1,
|
|
|
|
location_area=location_area,
|
|
|
|
encounter_slot=encounter_slot1,
|
|
|
|
min_level=30,
|
|
|
|
max_level=35,
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species2 = self.setup_pokemon_species_data(name="spcs for pkmn2")
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon2 = self.setup_pokemon_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon=pokemon2,
|
|
|
|
location_area=location_area,
|
|
|
|
encounter_slot=encounter_slot2,
|
|
|
|
min_level=32,
|
|
|
|
max_level=36,
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/location-area/{}/".format(API_V2, location_area.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], location_area_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
location_area_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, location_area_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# location params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["location"]["name"], location.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["location"]["url"],
|
|
|
|
"{}{}/location/{}/".format(TEST_HOST, API_V2, location.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# encounter method params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["encounter_method_rates"][0]["encounter_method"]["name"],
|
|
|
|
encounter_method.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["encounter_method_rates"][0]["version_details"][0]["rate"],
|
|
|
|
location_area_encounter_rate.rate,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["encounter_method_rates"][0]["version_details"][0]["version"][
|
|
|
|
"name"
|
|
|
|
],
|
|
|
|
location_area_encounter_rate.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["encounter_method_rates"][0]["version_details"][0]["version"][
|
|
|
|
"url"
|
|
|
|
],
|
|
|
|
"{}{}/version/{}/".format(
|
|
|
|
TEST_HOST, API_V2, location_area_encounter_rate.version.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# encounter params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0]["pokemon"]["name"], pokemon1.name
|
|
|
|
)
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0]["version_details"][0]["max_chance"],
|
|
|
|
encounter_slot1.rarity,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0]["version_details"][0]["version"][
|
|
|
|
"name"
|
|
|
|
],
|
|
|
|
encounter1.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0].get("version_details")[0][
|
|
|
|
"encounter_details"
|
|
|
|
][0]["chance"],
|
|
|
|
encounter_slot1.rarity,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0].get("version_details")[0][
|
|
|
|
"encounter_details"
|
|
|
|
][0]["method"]["name"],
|
|
|
|
encounter_slot1.encounter_method.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][1]["pokemon"]["name"], pokemon2.name
|
|
|
|
)
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][1]["version_details"][0]["max_chance"],
|
|
|
|
encounter_slot2.rarity,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][1]["version_details"][0]["version"][
|
|
|
|
"name"
|
|
|
|
],
|
|
|
|
encounter2.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][1].get("version_details")[0][
|
|
|
|
"encounter_details"
|
|
|
|
][0]["chance"],
|
|
|
|
encounter_slot2.rarity,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][1]["version_details"][0].get(
|
|
|
|
"encounter_details"
|
|
|
|
)[0]["method"]["name"],
|
|
|
|
encounter_slot2.encounter_method.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_contest_type_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
contest_type, name="base cntst tp name"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
berry_flavor = self.setup_berry_flavor_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="bry for base cntst tp", contest_type=contest_type
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/contest-type/{}/".format(API_V2, contest_type.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], contest_type.pk)
|
|
|
|
self.assertEqual(response.data["name"], contest_type.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], contest_type_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
contest_type_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, contest_type_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# berry params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["berry_flavor"]["name"], berry_flavor.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["berry_flavor"]["url"],
|
|
|
|
"{}{}/berry-flavor/{}/".format(TEST_HOST, API_V2, berry_flavor.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
contest_effect, flavor_text="base cntst efct flvr txt"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
contest_effect_effect_text = self.setup_contest_effect_effect_text_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
contest_effect, effect="base cntst efct eftc txt"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/contest-effect/{}/".format(API_V2, contest_effect.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], contest_effect.pk)
|
|
|
|
self.assertEqual(response.data["appeal"], contest_effect.appeal)
|
|
|
|
self.assertEqual(response.data["jam"], contest_effect.jam)
|
2015-11-16 03:29:30 +00:00
|
|
|
# effect text params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["effect"],
|
|
|
|
contest_effect_effect_text.effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["name"],
|
|
|
|
contest_effect_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, contest_effect_effect_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# flavor text params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["flavor_text"],
|
|
|
|
contest_effect_flavor_text.flavor_text,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["name"],
|
|
|
|
contest_effect_flavor_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, contest_effect_flavor_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_super_contest_effect_api(self):
|
|
|
|
super_contest_effect = self.setup_super_contest_effect_data(appeal=10)
|
2021-02-06 22:15:12 +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"
|
|
|
|
)
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
move = self.setup_move_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="mv for base spr cntst efct", super_contest_effect=super_contest_effect
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
response = self.client.get(
|
2020-02-17 20:58:07 +00:00
|
|
|
"{}/super-contest-effect/{}/".format(API_V2, super_contest_effect.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], super_contest_effect.pk)
|
|
|
|
self.assertEqual(response.data["appeal"], super_contest_effect.appeal)
|
2015-11-16 03:29:30 +00:00
|
|
|
# flavor text params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["flavor_text"],
|
|
|
|
super_contest_effect_flavor_text.flavor_text,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["name"],
|
|
|
|
super_contest_effect_flavor_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, super_contest_effect_flavor_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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):
|
2024-07-30 02:26:15 +00:00
|
|
|
type_obj = self.setup_type_data(name="base tp")
|
|
|
|
type_name = self.setup_type_name_data(type_obj, name="base tp nm")
|
|
|
|
type_game_index = self.setup_type_game_index_data(type_obj, game_index=10)
|
|
|
|
move = self.setup_move_data(name="mv for base tp", type=type_obj)
|
2015-11-26 01:18:35 +00:00
|
|
|
pokemon = self.setup_pokemon_data(name="pkmn for base tp")
|
2024-07-30 02:26:15 +00:00
|
|
|
pokemon_type = self.setup_pokemon_type_data(pokemon=pokemon, type=type_obj)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2021-07-19 18:00:40 +00:00
|
|
|
generation = self.setup_generation_data(name="past gen")
|
2021-07-16 21:50:32 +00:00
|
|
|
|
|
|
|
no_damage_to = self.setup_type_data(
|
|
|
|
name="no damage to tp", generation=generation
|
|
|
|
)
|
|
|
|
half_damage_to = self.setup_type_data(
|
|
|
|
name="half damage to tp", generation=generation
|
|
|
|
)
|
|
|
|
double_damage_to = self.setup_type_data(
|
|
|
|
name="double damage to tp", generation=generation
|
|
|
|
)
|
|
|
|
no_damage_from = self.setup_type_data(
|
|
|
|
name="no damage from tp", generation=generation
|
|
|
|
)
|
|
|
|
half_damage_from = self.setup_type_data(
|
|
|
|
name="half damage from tp", generation=generation
|
|
|
|
)
|
|
|
|
double_damage_from = self.setup_type_data(
|
|
|
|
name="double damage from tp", generation=generation
|
|
|
|
)
|
|
|
|
|
2021-07-19 18:00:40 +00:00
|
|
|
newer_generation = self.setup_generation_data(name="newer_generation")
|
2021-07-16 21:50:32 +00:00
|
|
|
|
|
|
|
newer_type = self.setup_type_data(name="newer tp", generation=newer_generation)
|
2015-10-23 04:56:01 +00:00
|
|
|
|
2024-07-30 02:26:15 +00:00
|
|
|
type_sprites, game_map = self.setup_type_sprites_data(type=type_obj)
|
|
|
|
|
2015-10-23 04:56:01 +00:00
|
|
|
# type relations
|
2016-03-05 11:40:41 +00:00
|
|
|
no_damage_to_relation = TypeEfficacy(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=type_obj, 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(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=type_obj, 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(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=type_obj, 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(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=no_damage_from, target_type=type_obj, 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(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=half_damage_from, target_type=type_obj, 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(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=double_damage_from, target_type=type_obj, damage_factor=200
|
2015-10-23 04:56:01 +00:00
|
|
|
)
|
|
|
|
double_damage_from_type_relation.save()
|
|
|
|
|
2021-07-16 21:50:32 +00:00
|
|
|
double_damage_from_newer_type_relation = TypeEfficacy(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=newer_type, target_type=type_obj, damage_factor=200
|
2021-07-16 21:50:32 +00:00
|
|
|
)
|
|
|
|
double_damage_from_newer_type_relation.save()
|
|
|
|
|
2019-12-01 12:42:20 +00:00
|
|
|
# past type relations
|
|
|
|
|
2021-07-16 21:50:32 +00:00
|
|
|
# type used to deal half damage rather than no damage
|
2019-12-01 12:42:20 +00:00
|
|
|
past_no_damage_to_relation = TypeEfficacyPast(
|
2024-07-30 02:26:15 +00:00
|
|
|
damage_type=type_obj,
|
2019-12-01 12:42:20 +00:00
|
|
|
target_type=no_damage_to,
|
|
|
|
damage_factor=50,
|
2021-02-13 22:22:41 +00:00
|
|
|
generation=generation,
|
2019-12-01 12:42:20 +00:00
|
|
|
)
|
2021-07-16 21:50:32 +00:00
|
|
|
past_no_damage_to_relation.save()
|
2019-12-01 12:42:20 +00:00
|
|
|
|
2024-07-30 02:26:15 +00:00
|
|
|
response = self.client.get("{}/type/{}/".format(API_V2, type_obj.pk))
|
2015-10-23 04:56:01 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2024-07-30 02:26:15 +00:00
|
|
|
self.assertEqual(response.data["id"], type_obj.pk)
|
|
|
|
self.assertEqual(response.data["name"], type_obj.name)
|
2015-10-23 04:56:01 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], type_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], type_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2024-07-30 02:26:15 +00:00
|
|
|
self.assertEqual(response.data["generation"]["name"], type_obj.generation.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["generation"]["url"],
|
2024-07-30 02:26:15 +00:00
|
|
|
"{}{}/generation/{}/".format(TEST_HOST, API_V2, type_obj.generation.pk),
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# damage class params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2024-07-30 02:26:15 +00:00
|
|
|
response.data["move_damage_class"]["name"], type_obj.move_damage_class.name
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["move_damage_class"]["url"],
|
|
|
|
"{}{}/move-damage-class/{}/".format(
|
2024-07-30 02:26:15 +00:00
|
|
|
TEST_HOST, API_V2, type_obj.move_damage_class.pk
|
2020-02-17 20:58:07 +00:00
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["moves"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, move.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# pokemon params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["no_damage_to"][0]["name"],
|
|
|
|
no_damage_to.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["half_damage_to"][0]["name"],
|
|
|
|
half_damage_to.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["double_damage_to"][0]["name"],
|
|
|
|
double_damage_to.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["no_damage_from"][0]["name"],
|
|
|
|
no_damage_from.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["half_damage_from"][0]["name"],
|
|
|
|
half_damage_from.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["double_damage_from"][0]["name"],
|
|
|
|
double_damage_from.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_relations"]["double_damage_from"][0]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, double_damage_from.pk),
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
|
|
|
|
# past damage relations params
|
|
|
|
|
|
|
|
# generation
|
2021-02-13 22:22:41 +00:00
|
|
|
past_damage_relations = response.data["past_damage_relations"]
|
|
|
|
gen_data = past_damage_relations[0]["generation"]
|
|
|
|
self.assertEqual(gen_data["name"], generation.name)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_data["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
2019-12-01 12:42:20 +00:00
|
|
|
TEST_HOST, API_V2, past_no_damage_to_relation.generation.pk
|
2021-02-13 22:22:41 +00:00
|
|
|
),
|
2019-12-01 12:42:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# relations
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations = past_damage_relations[0]["damage_relations"]
|
2021-07-16 21:50:32 +00:00
|
|
|
|
|
|
|
# type that currently receives no damage used to receive half damage, so is no longer in
|
|
|
|
# this list...
|
|
|
|
self.assertEqual(len(gen_relations["no_damage_to"]), 0)
|
|
|
|
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["half_damage_to"][0]["name"], half_damage_to.name
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["half_damage_to"][0]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, half_damage_to.pk),
|
|
|
|
)
|
2021-07-16 21:50:32 +00:00
|
|
|
|
|
|
|
# ...it's in this list instead
|
|
|
|
self.assertEqual(gen_relations["half_damage_to"][1]["name"], no_damage_to.name)
|
|
|
|
self.assertEqual(
|
|
|
|
gen_relations["half_damage_to"][1]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, no_damage_to.pk),
|
|
|
|
)
|
|
|
|
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["double_damage_to"][0]["name"], double_damage_to.name
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["double_damage_to"][0]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, double_damage_to.pk),
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["no_damage_from"][0]["name"], no_damage_from.name
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["no_damage_from"][0]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, no_damage_from.pk),
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["half_damage_from"][0]["name"], half_damage_from.name
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["half_damage_from"][0]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, half_damage_from.pk),
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["double_damage_from"][0]["name"], double_damage_from.name
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
self.assertEqual(
|
2021-02-13 22:22:41 +00:00
|
|
|
gen_relations["double_damage_from"][0]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, double_damage_from.pk),
|
|
|
|
)
|
2019-12-01 12:42:20 +00:00
|
|
|
|
2021-07-16 21:50:32 +00:00
|
|
|
# second double-damage-from type is absent because it's from a newer generation than the
|
|
|
|
# generation of this set of relations
|
|
|
|
self.assertEqual(len(gen_relations["double_damage_from"]), 1)
|
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
# game indices params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["game_index"], type_game_index.game_index
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["generation"]["name"],
|
|
|
|
type_game_index.generation.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, type_game_index.generation.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2024-07-30 02:26:15 +00:00
|
|
|
sprites_data = json.loads(type_sprites.sprites)
|
|
|
|
|
|
|
|
for generation in game_map.keys():
|
|
|
|
for game in game_map[generation]:
|
|
|
|
self.assertEqual(
|
|
|
|
json.loads(response.data["sprites"])[generation][game]["name_icon"],
|
|
|
|
sprites_data[generation][game]["name_icon"],
|
|
|
|
)
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Pokedex Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_pokedex_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokedex=pokedex, pokemon_species=pokemon_species
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/pokedex/{}/".format(API_V2, pokedex.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pokedex_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], pokedex_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, pokedex_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# descriptions params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
pokedex_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
pokedex_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokedex_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# region params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["region"]["name"], pokedex.region.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["region"]["url"],
|
|
|
|
"{}{}/region/{}/".format(TEST_HOST, API_V2, pokedex.region.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_entries"][0]["entry_number"],
|
|
|
|
dex_entry.pokedex_number,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_entries"][0]["pokemon_species"]["name"],
|
|
|
|
pokemon_species.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_move_ailment_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/move-ailment/{}/".format(API_V2, move_ailment.pk)
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], move_ailment.pk)
|
|
|
|
self.assertEqual(response.data["name"], move_ailment.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], move_ailment_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
move_ailment_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_ailment_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["moves"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, move.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_move_battle_style_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_battle_style, name="base mv btl stl name"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/move-battle-style/{}/".format(API_V2, move_battle_style.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], move_battle_style.pk)
|
|
|
|
self.assertEqual(response.data["name"], move_battle_style.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], move_battle_style_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
move_battle_style_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_battle_style_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_move_category_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/move-category/{}/".format(API_V2, move_category.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], move_category.pk)
|
|
|
|
self.assertEqual(response.data["name"], move_category.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
move_category_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
move_category_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_category_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["moves"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, move.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_move_damage_class_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_damage_class, name="base mv dmg cls nm"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
move_damage_class_description = self.setup_move_damage_class_description_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_damage_class, description="base mv dmg cls desc"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
move = self.setup_move_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="mv for base mv dmg cls", move_damage_class=move_damage_class
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/move-damage-class/{}/".format(API_V2, move_damage_class.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], move_damage_class.pk)
|
|
|
|
self.assertEqual(response.data["name"], move_damage_class.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], move_damage_class_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
move_damage_class_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_damage_class_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# description params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
move_damage_class_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
move_damage_class_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_damage_class_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["moves"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, move.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_move_learn_method_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_learn_method, name="base mv lrn mthd nm"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
move_learn_method_description = self.setup_move_learn_method_description_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
version_group=version_group, move_learn_method=move_learn_method
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/move-learn-method/{}/".format(API_V2, move_learn_method.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], move_learn_method.pk)
|
|
|
|
self.assertEqual(response.data["name"], move_learn_method.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], move_learn_method_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
move_learn_method_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_learn_method_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# description params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
move_learn_method_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
move_learn_method_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_learn_method_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# version group params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["version_groups"][0]["name"], version_group.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["version_groups"][0]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(TEST_HOST, API_V2, version_group.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_move_target_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_target, description="base mv trgt desc"
|
|
|
|
)
|
|
|
|
move = self.setup_move_data(name="mv for base mv trgt", move_target=move_target)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/move-target/{}/".format(API_V2, move_target.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], move_target.pk)
|
|
|
|
self.assertEqual(response.data["name"], move_target.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], move_target_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
move_target_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, move_target_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# description params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
move_target_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
move_target_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_target_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["moves"][0]["name"], move.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["moves"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, move.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_move_api(self):
|
2015-11-16 03:29:30 +00:00
|
|
|
move_effect = self.setup_move_effect_data()
|
|
|
|
move_effect_effect_text = self.setup_move_effect_effect_text_data(move_effect)
|
2020-02-17 20:58:07 +00:00
|
|
|
move = self.setup_move_data(name="base mv", move_effect=move_effect)
|
|
|
|
move_name = self.setup_move_name_data(move, name="base mv nm")
|
2015-10-27 13:36:33 +00:00
|
|
|
move_meta = self.setup_move_meta_data(move)
|
2015-11-26 01:18:35 +00:00
|
|
|
move_stat_change = self.setup_move_stat_change_data(move=move, change=2)
|
2015-11-16 03:29:30 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move_effect_change=move_effect_change, effect="efct tx for mv efct chng"
|
|
|
|
)
|
2021-01-23 17:22:37 +00:00
|
|
|
pokemon = self.setup_pokemon_data()
|
|
|
|
version_group = self.setup_version_group_data()
|
|
|
|
|
2021-01-26 23:44:54 +00:00
|
|
|
self.setup_pokemon_move_data(pokemon, move, version_group)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
after_move = self.setup_move_data(name="after mv")
|
|
|
|
before_move = self.setup_move_data(name="before mv")
|
2015-11-16 03:29:30 +00:00
|
|
|
|
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)
|
2020-02-17 20:58:07 +00:00
|
|
|
move_flavor_text = self.setup_move_flavor_text_data(
|
|
|
|
move, flavor_text="flvr text for move"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/move/{}/".format(API_V2, move.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], move_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], move_name.language.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, move_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# damage class params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["damage_class"]["name"], move.move_damage_class.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["damage_class"]["url"],
|
|
|
|
"{}{}/move-damage-class/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move.move_damage_class.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# contest type params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["contest_type"]["name"], move.contest_type.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_type"]["url"],
|
|
|
|
"{}{}/contest-type/{}/".format(TEST_HOST, API_V2, move.contest_type.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# contest effect params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_effect"]["url"],
|
|
|
|
"{}{}/contest-effect/{}/".format(TEST_HOST, API_V2, move.contest_effect.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# super contest effect params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["super_contest_effect"]["url"],
|
|
|
|
"{}{}/super-contest-effect/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move.super_contest_effect.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# generation params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["generation"]["name"], move.generation.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(TEST_HOST, API_V2, move.generation.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# target params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["target"]["name"], move.move_target.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["target"]["url"],
|
|
|
|
"{}{}/move-target/{}/".format(TEST_HOST, API_V2, move.move_target.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# type params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["type"]["name"], move.type.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["type"]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, move.type.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# stat change params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["stat_changes"][0]["change"], move_stat_change.change
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["stat_changes"][0]["stat"]["name"], move_stat_change.stat.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["stat_changes"][0]["stat"]["url"],
|
|
|
|
"{}{}/stat/{}/".format(TEST_HOST, API_V2, move_stat_change.stat.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# effect entries params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["effect"], move_effect_effect_text.effect
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["short_effect"],
|
|
|
|
move_effect_effect_text.short_effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["name"],
|
|
|
|
move_effect_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_effect_effect_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# meta data
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# ailment params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["meta"]["ailment"]["name"], move_meta.move_meta_ailment.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["meta"]["ailment"]["url"],
|
|
|
|
"{}{}/move-ailment/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_meta.move_meta_ailment.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# category params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["meta"]["category"]["name"], move_meta.move_meta_category.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["meta"]["category"]["url"],
|
|
|
|
"{}{}/move-category/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_meta.move_meta_category.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# combo params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_combos"]["normal"]["use_before"][0]["name"],
|
|
|
|
after_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_combos"]["normal"]["use_after"][0]["name"],
|
|
|
|
before_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_combos"]["super"]["use_before"][0]["name"],
|
|
|
|
after_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_combos"]["super"]["use_after"][0]["name"],
|
|
|
|
before_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["contest_combos"]["super"]["use_after"][0]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, before_move.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# change params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["past_values"][0]["effect_chance"],
|
|
|
|
move_change.move_effect_chance,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["past_values"][0]["version_group"]["name"],
|
|
|
|
move_change.version_group.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["past_values"][0]["version_group"]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_change.version_group.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# effect changes
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["version_group"]["name"],
|
|
|
|
move_effect_change.version_group.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["effect_entries"][0]["effect"],
|
|
|
|
move_effect_change_effect_text.effect,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["effect_entries"][0]["language"]["name"],
|
|
|
|
move_effect_change_effect_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["effect_changes"][0]["effect_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_effect_change_effect_text.language.pk
|
|
|
|
),
|
|
|
|
)
|
2016-07-05 08:42:03 +00:00
|
|
|
# flavor text params
|
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["flavor_text"],
|
|
|
|
move_flavor_text.flavor_text,
|
|
|
|
)
|
2016-07-05 08:42:03 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["name"],
|
|
|
|
move_flavor_text.language.name,
|
|
|
|
)
|
2016-07-05 08:42:03 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, move_flavor_text.language.pk),
|
|
|
|
)
|
2016-07-05 08:42:03 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["version_group"]["name"],
|
|
|
|
move_flavor_text.version_group.name,
|
|
|
|
)
|
2016-07-05 08:42:03 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["version_group"]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(
|
|
|
|
TEST_HOST, API_V2, move_flavor_text.version_group.pk
|
|
|
|
),
|
|
|
|
)
|
2021-01-23 17:22:37 +00:00
|
|
|
# pokemon
|
2021-01-26 23:44:54 +00:00
|
|
|
self.assertEqual(response.data["learned_by_pokemon"][0]["name"], pokemon.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
|
|
|
# Stat Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_stat_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
stat = self.setup_stat_data(name="base stt")
|
|
|
|
stat_name = self.setup_stat_name_data(stat, name="base stt name")
|
2015-11-26 01:18:35 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
move=increase_move, stat=stat, change=2
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
characteristic = self.setup_characteristic_data(stat=stat)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/stat/{}/".format(API_V2, stat.pk))
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, stat_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# move damage class params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["move_damage_class"]["name"], stat.move_damage_class.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["move_damage_class"]["url"],
|
|
|
|
"{}{}/move-damage-class/{}/".format(
|
|
|
|
TEST_HOST, API_V2, stat.move_damage_class.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# nature params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_natures"]["increase"][0]["name"],
|
|
|
|
increase_nature.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_natures"]["decrease"][0]["name"],
|
|
|
|
decrease_nature.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_natures"]["decrease"][0]["url"],
|
|
|
|
"{}{}/nature/{}/".format(TEST_HOST, API_V2, decrease_nature.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# move params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_moves"]["increase"][0]["change"],
|
|
|
|
increase_move_stat_change.change,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_moves"]["increase"][0]["move"]["name"],
|
|
|
|
increase_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_moves"]["decrease"][0]["change"],
|
|
|
|
decrease_move_stat_change.change,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_moves"]["decrease"][0]["move"]["name"],
|
|
|
|
decrease_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["affecting_moves"]["decrease"][0]["move"]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, decrease_move.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# characteristics params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["characteristics"][0]["url"],
|
|
|
|
"{}{}/characteristic/{}/".format(TEST_HOST, API_V2, characteristic.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_pokeathlon_stat_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokeathlon_stat, name="base pkathln stt name"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/pokeathlon-stat/{}/".format(API_V2, pokeathlon_stat.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], pokeathlon_stat.pk)
|
|
|
|
self.assertEqual(response.data["name"], pokeathlon_stat.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pokeathlon_stat_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
pokeathlon_stat_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokeathlon_stat_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Characteristic Tests
|
2015-11-16 03:29:30 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
characteristic, description="base char desc"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/characteristic/{}/".format(API_V2, characteristic.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], characteristic.pk)
|
|
|
|
self.assertEqual(response.data["gene_modulo"], characteristic.gene_mod_5)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["description"],
|
|
|
|
characteristic_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["name"],
|
|
|
|
characteristic_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["descriptions"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, characteristic_description.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# stat params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["highest_stat"]["name"], characteristic.stat.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["highest_stat"]["url"],
|
|
|
|
"{}{}/stat/{}/".format(TEST_HOST, API_V2, characteristic.stat.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2021-07-06 01:10:39 +00:00
|
|
|
def test_characteristic_values(self):
|
|
|
|
# check for all 5 possible values of gene_modulo
|
|
|
|
for modulo in range(5):
|
|
|
|
characteristic = self.setup_characteristic_data(gene_mod_5=modulo)
|
|
|
|
# note that 'possible_values' is computed solely from gene_modulo
|
|
|
|
# thus it is fine that our test characteristics are indexed 1-5
|
|
|
|
result = self.client.get(
|
2021-07-06 04:58:55 +00:00
|
|
|
"{}/characteristic/{}/".format(API_V2, characteristic.pk)
|
|
|
|
)
|
|
|
|
for i in range(len(result.data["possible_values"])):
|
2021-07-06 01:10:39 +00:00
|
|
|
self.assertEqual(
|
2021-07-06 04:58:55 +00:00
|
|
|
result.data["possible_values"][i], characteristic.gene_mod_5 + i * 5
|
2021-07-06 01:10:39 +00:00
|
|
|
)
|
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Nature Tests
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_nature_api(self):
|
2020-02-17 20:58:07 +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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
2020-02-17 20:58:07 +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(
|
2020-02-17 20:58:07 +00:00
|
|
|
nature=nature, pokeathlon_stat=pokeathlon_stat, max_change=1
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
nature=nature, move_battle_style=move_battle_style
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get("{}/nature/{}/".format(API_V2, nature.pk))
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], nature.pk)
|
|
|
|
self.assertEqual(response.data["name"], nature.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], nature_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"], nature_name.language.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(TEST_HOST, API_V2, nature_name.language.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# stat params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["decreased_stat"]["name"], decreased_stat.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["increased_stat"]["url"],
|
|
|
|
"{}{}/stat/{}/".format(TEST_HOST, API_V2, increased_stat.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# flavor params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["hates_flavor"]["name"], hates_flavor.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["likes_flavor"]["url"],
|
|
|
|
"{}{}/berry-flavor/{}/".format(TEST_HOST, API_V2, likes_flavor.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# pokeathlon stat params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokeathlon_stat_changes"][0]["max_change"],
|
|
|
|
nature_pokeathlon_stat.max_change,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokeathlon_stat_changes"][0]["pokeathlon_stat"]["name"],
|
|
|
|
pokeathlon_stat.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokeathlon_stat_changes"][0]["pokeathlon_stat"]["url"],
|
|
|
|
"{}{}/pokeathlon-stat/{}/".format(TEST_HOST, API_V2, pokeathlon_stat.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# pokeathlon stat params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["move_battle_style_preferences"][0]["low_hp_preference"],
|
|
|
|
nature_battle_style_preference.low_hp_preference,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["move_battle_style_preferences"][0]["high_hp_preference"],
|
|
|
|
nature_battle_style_preference.high_hp_preference,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["move_battle_style_preferences"][0]["move_battle_style"][
|
|
|
|
"name"
|
|
|
|
],
|
|
|
|
move_battle_style.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_pokemon_habitat_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_habitat, name="base pkmn hbtt name"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species = self.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_habitat=pokemon_habitat, name="pkmn spcs for pkmn hbtt"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/pokemon-habitat/{}/".format(API_V2, pokemon_habitat.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], pokemon_habitat.pk)
|
|
|
|
self.assertEqual(response.data["name"], pokemon_habitat.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pokemon_habitat_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
pokemon_habitat_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_habitat_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon_species"][0]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_pokemon_color_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_color, name="base pkmn clr name"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species = self.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_color=pokemon_color, name="pkmn spcs for pkmn clr"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/pokemon-color/{}/".format(API_V2, pokemon_color.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], pokemon_color.pk)
|
|
|
|
self.assertEqual(response.data["name"], pokemon_color.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pokemon_color_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
pokemon_color_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_color_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon_species"][0]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_pokemon_shape_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_shape, name="base pkmn shp name"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species = self.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_shape=pokemon_shape, name="pkmn spcs for pkmn shp"
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/pokemon-shape/{}/".format(API_V2, pokemon_shape.pk)
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], pokemon_shape.pk)
|
|
|
|
self.assertEqual(response.data["name"], pokemon_shape.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pokemon_shape_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
pokemon_shape_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_shape_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# awesome name params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["awesome_names"][0]["awesome_name"],
|
|
|
|
pokemon_shape_name.awesome_name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["awesome_names"][0]["language"]["name"],
|
|
|
|
pokemon_shape_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["awesome_names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_shape_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon_species"][0]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
def test_pokemon_species_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolves_from_species=evolves_from_species, name="base pkmn spcs"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species_name = self.setup_pokemon_species_name_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species, name="base pkmn shp name"
|
|
|
|
)
|
2021-02-06 22:15:12 +00:00
|
|
|
pokemon_species_form_description = (
|
|
|
|
self.setup_pokemon_species_form_description_data(
|
|
|
|
pokemon_species, description="frm dscr for pkmn spcs"
|
|
|
|
)
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species_flavor_text = self.setup_pokemon_species_flavor_text_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
2015-11-26 01:18:35 +00:00
|
|
|
pal_park = self.setup_pal_park_data(pokemon_species=pokemon_species)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
dex_number = self.setup_pokemon_dex_entry_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species=pokemon_species, pokedex=pokedex, entry_number=44
|
|
|
|
)
|
2016-03-05 08:26:51 +00:00
|
|
|
|
2020-02-17 20:58:07 +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
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon = self.setup_pokemon_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_species=pokemon_species, name="pkm for base pkmn spcs"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.setup_pokemon_sprites_data(pokemon)
|
2024-02-02 18:45:39 +00:00
|
|
|
self.setup_pokemon_cries_data(pokemon)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
response = self.client.get(
|
2020-02-17 20:58:07 +00:00
|
|
|
"{}/pokemon-species/{}/".format(API_V2, pokemon_species.pk),
|
|
|
|
HTTP_HOST="testserver",
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2020-08-09 19:35:45 +00:00
|
|
|
self.assertEqual(response.data["is_legendary"], pokemon_species.is_legendary)
|
|
|
|
self.assertEqual(response.data["is_mythical"], pokemon_species.is_mythical)
|
2020-08-15 05:14:09 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["hatch_counter"], pokemon_species.hatch_counter)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["has_gender_differences"],
|
|
|
|
pokemon_species.has_gender_differences,
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["forms_switchable"], pokemon_species.forms_switchable
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pokemon_species_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
pokemon_species_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# growth rate params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["growth_rate"]["name"], pokemon_species.growth_rate.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["growth_rate"]["url"],
|
|
|
|
"{}{}/growth-rate/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species.growth_rate.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# dex number params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokedex_numbers"][0]["entry_number"],
|
|
|
|
dex_number.pokedex_number,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokedex_numbers"][0]["pokedex"]["name"], pokedex.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokedex_numbers"][0]["pokedex"]["url"],
|
|
|
|
"{}{}/pokedex/{}/".format(TEST_HOST, API_V2, pokedex.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# egg group params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["egg_groups"][0]["name"], egg_group.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["egg_groups"][0]["url"],
|
|
|
|
"{}{}/egg-group/{}/".format(TEST_HOST, API_V2, egg_group.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# generation params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["generation"]["name"], pokemon_species.generation.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species.generation.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# color params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["color"]["name"], pokemon_species.pokemon_color.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["color"]["url"],
|
|
|
|
"{}{}/pokemon-color/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species.pokemon_color.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# shape params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["shape"]["name"], pokemon_species.pokemon_shape.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["shape"]["url"],
|
|
|
|
"{}{}/pokemon-shape/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species.pokemon_shape.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# habitat params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["habitat"]["name"], pokemon_species.pokemon_habitat.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["habitat"]["url"],
|
|
|
|
"{}{}/pokemon-habitat/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species.pokemon_habitat.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# evolves from params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["evolves_from_species"]["name"], evolves_from_species.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["evolves_from_species"]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(
|
|
|
|
TEST_HOST, API_V2, evolves_from_species.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# genus params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["genera"][0]["genus"], pokemon_species_name.genus
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["genera"][0]["language"]["name"],
|
|
|
|
pokemon_species_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["genera"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# pokemon varieties params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["varieties"][0]["is_default"], pokemon.is_default
|
|
|
|
)
|
|
|
|
self.assertEqual(response.data["varieties"][0]["pokemon"]["name"], pokemon.name)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["varieties"][0]["pokemon"]["url"],
|
|
|
|
"{}{}/pokemon/{}/".format(TEST_HOST, API_V2, pokemon.pk),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# form descriptions params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["form_descriptions"][0]["description"],
|
|
|
|
pokemon_species_form_description.description,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["form_descriptions"][0]["language"]["name"],
|
|
|
|
pokemon_species_form_description.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["flavor_text"],
|
|
|
|
pokemon_species_flavor_text.flavor_text,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["language"]["name"],
|
|
|
|
pokemon_species_flavor_text.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["version"]["name"],
|
|
|
|
pokemon_species_flavor_text.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["flavor_text_entries"][0]["version"]["url"],
|
|
|
|
"{}{}/version/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_species_flavor_text.version.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# pal park params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pal_park_encounters"][0]["area"]["name"],
|
|
|
|
pal_park.pal_park_area.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pal_park_encounters"][0]["area"]["url"],
|
|
|
|
"{}{}/pal-park-area/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pal_park.pal_park_area.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_pokemon_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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"
|
|
|
|
)
|
2023-02-27 18:19:36 +00:00
|
|
|
generation = self.setup_generation_data(name="base gen")
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_ability = self.setup_pokemon_ability_data(pokemon=pokemon)
|
2023-02-27 18:19:36 +00:00
|
|
|
pokemon_past_ability = self.setup_pokemon_past_ability_data(
|
|
|
|
pokemon=pokemon, generation=generation
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_stat = self.setup_pokemon_stat_data(pokemon=pokemon)
|
|
|
|
pokemon_type = self.setup_pokemon_type_data(pokemon=pokemon)
|
2019-11-30 23:42:46 +00:00
|
|
|
pokemon_past_type = self.setup_pokemon_past_type_data(
|
2021-02-06 21:52:36 +00:00
|
|
|
pokemon=pokemon, generation=generation
|
2019-11-30 23:42:46 +00:00
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
pokemon_item = self.setup_pokemon_item_data(pokemon=pokemon)
|
2016-02-16 06:31:19 +00:00
|
|
|
pokemon_sprites = self.setup_pokemon_sprites_data(pokemon=pokemon)
|
2024-02-02 18:45:39 +00:00
|
|
|
pokemon_cries = self.setup_pokemon_cries_data(pokemon, latest=True, legacy=True)
|
2020-02-17 20:58:07 +00:00
|
|
|
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.
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_move = self.setup_move_data(name="mv for pkmn")
|
2016-02-25 04:55:59 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="ver grp " + str(move) + " for pkmn"
|
|
|
|
)
|
2016-02-25 04:55:59 +00:00
|
|
|
new_move = self.setup_pokemon_move_data(
|
2018-10-19 18:03:48 +00:00
|
|
|
pokemon=pokemon,
|
|
|
|
move=pokemon_move,
|
|
|
|
version_group=version_group,
|
2020-02-17 20:58:07 +00:00
|
|
|
level=move,
|
|
|
|
)
|
2016-02-25 04:55:59 +00:00
|
|
|
pokemon_moves.append(new_move)
|
2016-03-05 08:26:51 +00:00
|
|
|
|
2020-02-17 20:58:07 +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
|
|
|
|
)
|
2016-05-30 13:58:03 +00:00
|
|
|
self.setup_encounter_data(
|
2020-02-17 20:58:07 +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
|
|
|
|
)
|
2016-05-30 13:58:03 +00:00
|
|
|
self.setup_encounter_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
location_area=location_area2,
|
|
|
|
pokemon=pokemon,
|
|
|
|
encounter_slot=encounter_slot2,
|
|
|
|
min_level=32,
|
|
|
|
max_level=36,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
response = self.client.get(
|
2020-02-17 20:58:07 +00:00
|
|
|
"{}/pokemon/{}/".format(API_V2, pokemon.pk), HTTP_HOST="testserver"
|
|
|
|
)
|
2016-02-16 06:31:19 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# species params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["species"]["name"], pokemon_species.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["species"]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# abilities params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["abilities"][0]["ability"]["name"],
|
|
|
|
pokemon_ability.ability.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["abilities"][0]["ability"]["url"],
|
|
|
|
"{}{}/ability/{}/".format(TEST_HOST, API_V2, pokemon_ability.ability.pk),
|
|
|
|
)
|
2023-02-27 18:19:36 +00:00
|
|
|
# past abilities params
|
|
|
|
past_abilities_obj = response.data["past_abilities"][0]
|
|
|
|
self.assertEqual(
|
|
|
|
past_abilities_obj["generation"]["name"],
|
|
|
|
pokemon_past_ability.generation.name,
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
past_abilities_obj["generation"]["url"],
|
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_past_ability.generation.pk
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
past_abilities_abilities_obj = past_abilities_obj["abilities"][0]
|
|
|
|
self.assertEqual(
|
|
|
|
past_abilities_abilities_obj["is_hidden"], pokemon_past_ability.is_hidden
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
past_abilities_abilities_obj["slot"], pokemon_past_ability.slot
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
past_abilities_abilities_obj["ability"]["name"],
|
|
|
|
pokemon_past_ability.ability.name,
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
past_abilities_abilities_obj["ability"]["url"],
|
|
|
|
"{}{}/ability/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_past_ability.ability.pk
|
|
|
|
),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# stat params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["stats"][0]["base_stat"], pokemon_stat.base_stat)
|
|
|
|
self.assertEqual(response.data["stats"][0]["effort"], pokemon_stat.effort)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["stats"][0]["stat"]["name"], pokemon_stat.stat.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["stats"][0]["stat"]["url"],
|
|
|
|
"{}{}/stat/{}/".format(TEST_HOST, API_V2, pokemon_stat.stat.pk),
|
|
|
|
)
|
2019-11-30 21:00:26 +00:00
|
|
|
# type params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["types"][0]["slot"], pokemon_type.slot)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["types"][0]["type"]["name"], pokemon_type.type.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["types"][0]["type"]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, pokemon_type.type.pk),
|
|
|
|
)
|
2019-11-30 21:00:26 +00:00
|
|
|
# past type params
|
2021-02-06 21:29:40 +00:00
|
|
|
past_types_obj = response.data["past_types"][0]
|
2021-02-06 21:52:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
past_types_obj["generation"]["name"], pokemon_past_type.generation.name
|
|
|
|
)
|
2019-11-30 21:00:26 +00:00
|
|
|
self.assertEqual(
|
2021-02-06 21:29:40 +00:00
|
|
|
past_types_obj["generation"]["url"],
|
2021-02-06 21:52:36 +00:00
|
|
|
"{}{}/generation/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_past_type.generation.pk
|
|
|
|
),
|
|
|
|
)
|
2019-11-30 23:42:46 +00:00
|
|
|
|
2021-02-06 21:29:40 +00:00
|
|
|
past_types_types_obj = past_types_obj["types"][0]
|
|
|
|
self.assertEqual(past_types_types_obj["slot"], pokemon_past_type.slot)
|
2021-02-06 21:52:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
past_types_types_obj["type"]["name"], pokemon_past_type.type.name
|
|
|
|
)
|
2019-11-30 21:00:26 +00:00
|
|
|
self.assertEqual(
|
2021-02-06 21:29:40 +00:00
|
|
|
past_types_types_obj["type"]["url"],
|
2021-02-06 21:52:36 +00:00
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, pokemon_past_type.type.pk),
|
|
|
|
)
|
2019-11-30 23:42:46 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
# items params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_items"][0]["item"]["name"], pokemon_item.item.name
|
|
|
|
)
|
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_items"][0]["version_details"][0]["rarity"],
|
|
|
|
pokemon_item.rarity,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["held_items"][0]["version_details"][0]["version"]["name"],
|
|
|
|
pokemon_item.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
actual = len(response.data["moves"])
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
|
|
|
# Move name
|
|
|
|
expected = pokemon_moves[0].move.name
|
2020-02-17 20:58:07 +00:00
|
|
|
actual = response.data["moves"][0]["move"]["name"]
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
|
|
|
# Move URL
|
2020-02-17 20:58:07 +00:00
|
|
|
expected = "{}{}/move/{}/".format(TEST_HOST, API_V2, pokemon_moves[0].move.pk)
|
|
|
|
actual = response.data["moves"][0]["move"]["url"]
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
|
|
|
# Numbver of version groups
|
|
|
|
expected = len(pokemon_moves)
|
2020-02-17 20:58:07 +00:00
|
|
|
actual = len(response.data["moves"][0]["version_group_details"])
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
2018-10-20 00:05:10 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
for i, val in enumerate(pokemon_moves): # pylint: disable=unused-variable
|
|
|
|
version = response.data["moves"][0]["version_group_details"][i]
|
2016-02-25 04:55:59 +00:00
|
|
|
# Learn Level
|
|
|
|
expected = pokemon_moves[i].level
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
2020-02-17 20:58:07 +00:00
|
|
|
actual = version["version_group"]["name"]
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
|
|
|
# Version Group URL
|
2020-02-17 20:58:07 +00:00
|
|
|
expected = "{}{}/version-group/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_moves[i].version_group.pk
|
|
|
|
)
|
|
|
|
actual = version["version_group"]["url"]
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
|
|
|
# Learn Method Name
|
|
|
|
expected = pokemon_moves[i].move_learn_method.name
|
2020-02-17 20:58:07 +00:00
|
|
|
actual = version["move_learn_method"]["name"]
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
|
|
|
# Learn Method URL
|
2020-02-17 20:58:07 +00:00
|
|
|
expected = "{}{}/move-learn-method/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_moves[i].move_learn_method.pk
|
|
|
|
)
|
|
|
|
actual = version["move_learn_method"]["url"]
|
2016-02-25 04:55:59 +00:00
|
|
|
self.assertEqual(expected, actual)
|
2015-11-16 03:29:30 +00:00
|
|
|
# game indices params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["game_index"],
|
|
|
|
pokemon_game_index.game_index,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["version"]["name"],
|
|
|
|
pokemon_game_index.version.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["game_indices"][0]["version"]["url"],
|
|
|
|
"{}{}/version/{}/".format(TEST_HOST, API_V2, pokemon_game_index.version.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# form params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["forms"][0]["name"], pokemon_form.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["forms"][0]["url"],
|
|
|
|
"{}{}/pokemon-form/{}/".format(TEST_HOST, API_V2, pokemon_form.pk),
|
|
|
|
)
|
2023-11-23 10:59:12 +00:00
|
|
|
|
2023-11-26 13:51:08 +00:00
|
|
|
sprites_data = json.loads(pokemon_sprites.sprites)
|
2024-02-02 18:45:39 +00:00
|
|
|
cries_data = json.loads(pokemon_cries.cries)
|
2023-12-16 04:26:19 +00:00
|
|
|
response_sprites_data = json.loads(response.data["sprites"])
|
2024-02-02 18:45:39 +00:00
|
|
|
response_cries_data = json.loads(response.data["cries"])
|
2023-11-23 10:59:12 +00:00
|
|
|
|
2016-02-16 06:31:19 +00:00
|
|
|
# sprite params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2023-11-26 13:51:08 +00:00
|
|
|
sprites_data["front_default"],
|
2023-11-08 10:11:56 +00:00
|
|
|
"{}".format(sprites_data["front_default"]),
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
2023-11-26 13:51:08 +00:00
|
|
|
self.assertEqual(sprites_data["back_default"], None)
|
2016-03-05 08:26:51 +00:00
|
|
|
|
2023-12-16 04:26:19 +00:00
|
|
|
self.assertEqual(
|
|
|
|
sprites_data["other"]["showdown"]["front_default"],
|
|
|
|
response_sprites_data["other"]["showdown"]["front_default"],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
sprites_data["other"]["showdown"]["back_default"],
|
|
|
|
response_sprites_data["other"]["showdown"]["back_default"],
|
|
|
|
)
|
|
|
|
|
2024-02-02 18:45:39 +00:00
|
|
|
# cries params
|
|
|
|
self.assertEqual(
|
|
|
|
cries_data["latest"],
|
|
|
|
"{}".format(cries_data["latest"]),
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
cries_data["legacy"],
|
|
|
|
"{}".format(cries_data["legacy"]),
|
|
|
|
)
|
|
|
|
|
2024-04-08 13:27:14 +00:00
|
|
|
# test search pokemon using search query param `q=partial_name`
|
|
|
|
|
|
|
|
response = self.client.get(
|
|
|
|
"{}/pokemon/?q={}".format(API_V2, pokemon.name[:2]),
|
|
|
|
HTTP_HOST="testserver",
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
self.assertEqual(response.data["count"], 1)
|
|
|
|
self.assertEqual(response.data["results"][0]["name"], pokemon.name)
|
|
|
|
|
|
|
|
response = self.client.get(
|
|
|
|
"{}/pokemon/?q={}".format(API_V2, pokemon.name[-3:]),
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
self.assertEqual(response.data["count"], 1)
|
|
|
|
self.assertEqual(response.data["results"][0]["name"], pokemon.name)
|
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_pokemon_form_api(self):
|
|
|
|
pokemon_species = self.setup_pokemon_species_data()
|
|
|
|
pokemon = self.setup_pokemon_data(pokemon_species=pokemon_species)
|
2020-02-17 20:58:07 +00:00
|
|
|
pokemon_form = self.setup_pokemon_form_data(
|
|
|
|
pokemon=pokemon, name="pkm form for base pkmn"
|
|
|
|
)
|
2016-02-16 06:31:19 +00:00
|
|
|
pokemon_form_sprites = self.setup_pokemon_form_sprites_data(pokemon_form)
|
2020-04-25 13:25:00 +00:00
|
|
|
pokemon_form_type = self.setup_pokemon_form_type_data(pokemon_form)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
response = self.client.get(
|
2020-02-17 20:58:07 +00:00
|
|
|
"{}/pokemon-form/{}/".format(API_V2, pokemon_form.pk),
|
|
|
|
HTTP_HOST="testserver",
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
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)
|
2015-10-27 13:36:33 +00:00
|
|
|
# pokemon params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["pokemon"]["name"], pokemon.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon"]["url"],
|
|
|
|
"{}{}/pokemon/{}/".format(TEST_HOST, API_V2, pokemon.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# version group params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["version_group"]["name"], pokemon_form.version_group.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["version_group"]["url"],
|
|
|
|
"{}{}/version-group/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pokemon_form.version_group.pk
|
|
|
|
),
|
|
|
|
)
|
2023-11-26 13:51:08 +00:00
|
|
|
|
|
|
|
sprites_data = json.loads(pokemon_form_sprites.sprites)
|
|
|
|
|
2016-02-16 06:31:19 +00:00
|
|
|
# sprite params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2023-11-26 13:51:08 +00:00
|
|
|
sprites_data["front_default"],
|
2023-11-08 10:11:56 +00:00
|
|
|
"{}".format(sprites_data["front_default"]),
|
2020-02-17 20:58:07 +00:00
|
|
|
)
|
2023-11-26 13:51:08 +00:00
|
|
|
self.assertEqual(sprites_data["back_default"], None)
|
2020-04-25 13:25:00 +00:00
|
|
|
# type params
|
|
|
|
self.assertEqual(response.data["types"][0]["slot"], pokemon_form_type.slot)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["types"][0]["type"]["name"], pokemon_form_type.type.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["types"][0]["type"]["url"],
|
|
|
|
"{}{}/type/{}/".format(TEST_HOST, API_V2, pokemon_form_type.type.pk),
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Evolution test
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_evolution_trigger_api(self):
|
2020-02-17 20:58:07 +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(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolution_trigger, name="base evltn trgr name"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
pokemon_species = self.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="pkmn spcs for base evltn trgr"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.setup_pokemon_evolution_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolved_species=pokemon_species, evolution_trigger=evolution_trigger
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/evolution-trigger/{}/".format(API_V2, evolution_trigger.pk)
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], evolution_trigger.pk)
|
|
|
|
self.assertEqual(response.data["name"], evolution_trigger.name)
|
2015-10-27 13:36:33 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], evolution_trigger_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
evolution_trigger_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, evolution_trigger_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
# pokemon species params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_species"][0]["name"], pokemon_species.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon_species"][0]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2015-11-26 01:18:35 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
def test_evolution_chain_api(self):
|
|
|
|
baby_trigger_item = self.setup_item_data(name="bby itm for evo chn")
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolved_species=basic, min_level=5, location=basic_location
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
|
|
|
stage_one = self.setup_pokemon_species_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
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")
|
2016-03-05 11:40:41 +00:00
|
|
|
stage_one_evolution = self.setup_pokemon_evolution_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolved_species=stage_one, min_level=18, held_item=stage_one_held_item
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
|
|
|
stage_two_first = self.setup_pokemon_species_data(
|
|
|
|
name="stg two frst for evo chn",
|
2020-02-17 20:58:07 +00:00
|
|
|
evolves_from_species=stage_one,
|
|
|
|
evolution_chain=evolution_chain,
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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",
|
2020-02-17 20:58:07 +00:00
|
|
|
evolves_from_species=stage_one,
|
|
|
|
evolution_chain=evolution_chain,
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
evolved_species=stage_two_second,
|
|
|
|
min_level=32,
|
|
|
|
party_type=stage_two_second_party_type,
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/evolution-chain/{}/".format(API_V2, evolution_chain.pk)
|
|
|
|
)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
2015-10-18 23:01:33 +00:00
|
|
|
|
2020-02-17 20:58:07 +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
|
|
|
|
2015-10-27 13:36:33 +00:00
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], evolution_chain.pk)
|
2015-10-27 13:36:33 +00:00
|
|
|
# baby trigger params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["baby_trigger_item"]["name"], baby_trigger_item.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["baby_trigger_item"]["url"],
|
|
|
|
"{}{}/item/{}/".format(TEST_HOST, API_V2, baby_trigger_item.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# baby params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
baby_data["species"]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, baby.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# basic params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
basic_data["species"]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, basic.pk),
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
basic_data["evolution_details"][0]["min_level"], basic_evolution.min_level
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
basic_data["evolution_details"][0]["location"]["name"], basic_location.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
basic_data["evolution_details"][0]["location"]["url"],
|
|
|
|
"{}{}/location/{}/".format(TEST_HOST, API_V2, basic_location.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# stage one params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_one_data["evolution_details"][0]["min_level"],
|
|
|
|
stage_one_evolution.min_level,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_one_data["evolution_details"][0]["held_item"]["name"],
|
|
|
|
stage_one_held_item.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_one_data["evolution_details"][0]["held_item"]["url"],
|
|
|
|
"{}{}/item/{}/".format(TEST_HOST, API_V2, stage_one_held_item.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# stage two first params
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_two_first_data["evolution_details"][0]["min_level"],
|
|
|
|
stage_two_first_evolution.min_level,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_two_first_data["evolution_details"][0]["known_move"]["name"],
|
|
|
|
stage_two_first_known_move.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_two_first_data["evolution_details"][0]["known_move"]["url"],
|
|
|
|
"{}{}/move/{}/".format(TEST_HOST, API_V2, stage_two_first_known_move.pk),
|
|
|
|
)
|
2015-10-27 13:36:33 +00:00
|
|
|
# stage two second params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(stage_two_second_data["is_baby"], stage_two_second.is_baby)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_two_second_data["species"]["name"], stage_two_second.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_two_second_data["evolution_details"][0]["min_level"],
|
|
|
|
stage_two_second_evolution.min_level,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
stage_two_second_data["evolution_details"][0]["party_type"]["name"],
|
|
|
|
stage_two_second_party_type.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
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
|
|
|
|
2020-04-13 19:07:43 +00:00
|
|
|
# verifies that the wurmple evolution chain is serialized correctly
|
|
|
|
def test_evolution_chain_api_wurmple_bugfix(self):
|
|
|
|
# set up wurmple-like evolution chain
|
|
|
|
evolution_chain = self.setup_evolution_chain_data()
|
|
|
|
|
|
|
|
basic = self.setup_pokemon_species_data(
|
2021-02-06 22:15:12 +00:00
|
|
|
name="wurmple",
|
|
|
|
evolution_chain=evolution_chain,
|
2020-04-13 19:07:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
stage_one_first = self.setup_pokemon_species_data(
|
2021-02-06 22:15:12 +00:00
|
|
|
name="silcoon",
|
|
|
|
evolves_from_species=basic,
|
|
|
|
evolution_chain=evolution_chain,
|
2020-04-13 19:07:43 +00:00
|
|
|
)
|
|
|
|
stage_one_first_evolution = self.setup_pokemon_evolution_data(
|
|
|
|
evolved_species=stage_one_first, min_level=7
|
|
|
|
)
|
|
|
|
|
|
|
|
stage_two_first = self.setup_pokemon_species_data(
|
|
|
|
name="beautifly",
|
|
|
|
evolves_from_species=stage_one_first,
|
|
|
|
evolution_chain=evolution_chain,
|
|
|
|
)
|
|
|
|
stage_two_first_evolution = self.setup_pokemon_evolution_data(
|
|
|
|
evolved_species=stage_two_first, min_level=10
|
|
|
|
)
|
|
|
|
|
|
|
|
stage_one_second = self.setup_pokemon_species_data(
|
2021-02-06 22:15:12 +00:00
|
|
|
name="cascoon",
|
|
|
|
evolves_from_species=basic,
|
|
|
|
evolution_chain=evolution_chain,
|
2020-04-13 19:07:43 +00:00
|
|
|
)
|
|
|
|
stage_one_second_evolution = self.setup_pokemon_evolution_data(
|
|
|
|
evolved_species=stage_one_second, min_level=7
|
|
|
|
)
|
|
|
|
|
|
|
|
stage_two_second = self.setup_pokemon_species_data(
|
|
|
|
name="dustox",
|
|
|
|
evolves_from_species=stage_one_second,
|
|
|
|
evolution_chain=evolution_chain,
|
|
|
|
)
|
|
|
|
stage_two_second_evolution = self.setup_pokemon_evolution_data(
|
|
|
|
evolved_species=stage_two_second, min_level=10
|
|
|
|
)
|
|
|
|
|
|
|
|
response = self.client.get(
|
|
|
|
"{}/evolution-chain/{}/".format(API_V2, evolution_chain.pk)
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
|
|
|
self.assertEqual(response.data["id"], evolution_chain.pk)
|
|
|
|
|
|
|
|
# assert tree has been serialized correctly
|
|
|
|
basic_data = response.data["chain"]
|
|
|
|
self.assertEqual(len(basic_data["evolves_to"]), 2)
|
|
|
|
|
|
|
|
stage_one_first_data = basic_data["evolves_to"][0]
|
|
|
|
self.assertEqual(len(stage_one_first_data["evolves_to"]), 1)
|
|
|
|
|
|
|
|
stage_one_second_data = basic_data["evolves_to"][1]
|
|
|
|
self.assertEqual(len(stage_one_second_data["evolves_to"]), 1)
|
2016-03-05 11:40:41 +00:00
|
|
|
|
|
|
|
# Encounter Tests
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_encounter_method_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_method, name="base encntr mthd name"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/encounter-method/{}/".format(API_V2, encounter_method.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], encounter_method.pk)
|
|
|
|
self.assertEqual(response.data["name"], encounter_method.name)
|
|
|
|
self.assertEqual(response.data["order"], encounter_method.order)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], encounter_method_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
encounter_method_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, encounter_method_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
def test_encounter_condition_value_api(self):
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition = self.setup_encounter_condition_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
name="encntr cndtn for base encntr cndtn vlu"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition_value = self.setup_encounter_condition_value_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_condition, name="base encntr cndtn vlu"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition_value_name = self.setup_encounter_condition_value_name_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_condition_value, name="base encntr cndtn vlu name"
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/encounter-condition-value/{}/".format(
|
|
|
|
API_V2, encounter_condition_value.pk
|
|
|
|
)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], encounter_condition_value.pk)
|
|
|
|
self.assertEqual(response.data["name"], encounter_condition_value.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["name"], encounter_condition_value_name.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
encounter_condition_value_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, encounter_condition_value_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# condition params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["condition"]["name"], encounter_condition.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["condition"]["url"],
|
|
|
|
"{}{}/encounter-condition/{}/".format(
|
|
|
|
TEST_HOST, API_V2, encounter_condition.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
def test_encounter_condition_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_condition, name="base encntr cndtn name"
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
encounter_condition_value = self.setup_encounter_condition_value_data(
|
2020-02-17 20:58:07 +00:00
|
|
|
encounter_condition,
|
|
|
|
name="encntr cndtn vlu for base encntr",
|
|
|
|
is_default=True,
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
response = self.client.get(
|
2020-02-17 20:58:07 +00:00
|
|
|
"{}/encounter-condition/{}/".format(API_V2, encounter_condition.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], encounter_condition.pk)
|
|
|
|
self.assertEqual(response.data["name"], encounter_condition.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["name"], encounter_condition_name.name
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
encounter_condition_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, encounter_condition_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# value params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["values"][0]["name"], encounter_condition_value.name
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["values"][0]["url"],
|
|
|
|
"{}{}/encounter-condition-value/{}/".format(
|
|
|
|
TEST_HOST, API_V2, encounter_condition_value.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2016-03-05 11:40:41 +00:00
|
|
|
# Pal Park Tests
|
2015-11-16 03:29:30 +00:00
|
|
|
def test_pal_park_area_api(self):
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
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(
|
2020-02-17 20:58:07 +00:00
|
|
|
pal_park_area=pal_park_area,
|
|
|
|
pokemon_species=pokemon_species,
|
|
|
|
base_score=10,
|
|
|
|
rate=20,
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
2020-02-17 20:58:07 +00:00
|
|
|
response = self.client.get(
|
|
|
|
"{}/pal-park-area/{}/".format(API_V2, pal_park_area.pk)
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
|
|
|
|
|
|
|
# base params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["id"], pal_park_area.pk)
|
|
|
|
self.assertEqual(response.data["name"], pal_park_area.name)
|
2015-11-16 03:29:30 +00:00
|
|
|
# name params
|
2020-02-17 20:58:07 +00:00
|
|
|
self.assertEqual(response.data["names"][0]["name"], pal_park_area_name.name)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["name"],
|
|
|
|
pal_park_area_name.language.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["names"][0]["language"]["url"],
|
|
|
|
"{}{}/language/{}/".format(
|
|
|
|
TEST_HOST, API_V2, pal_park_area_name.language.pk
|
|
|
|
),
|
|
|
|
)
|
2015-11-16 03:29:30 +00:00
|
|
|
# encounter params
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0]["base_score"], pal_park.base_score
|
|
|
|
)
|
|
|
|
self.assertEqual(response.data["pokemon_encounters"][0]["rate"], pal_park.rate)
|
|
|
|
self.assertEqual(
|
|
|
|
response.data["pokemon_encounters"][0]["pokemon_species"]["name"],
|
|
|
|
pokemon_species.name,
|
|
|
|
)
|
2016-03-05 11:40:41 +00:00
|
|
|
self.assertEqual(
|
2020-02-17 20:58:07 +00:00
|
|
|
response.data["pokemon_encounters"][0]["pokemon_species"]["url"],
|
|
|
|
"{}{}/pokemon-species/{}/".format(TEST_HOST, API_V2, pokemon_species.pk),
|
|
|
|
)
|
2020-05-03 13:02:07 +00:00
|
|
|
|
|
|
|
# ID Range Tests
|
|
|
|
def test_id_range_api(self):
|
|
|
|
response = self.client.get("{}/pokemon/{}/".format(API_V2, 2147483648))
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
|