diff --git a/.pylintrc b/.pylintrc index 5fb72727..16749467 100644 --- a/.pylintrc +++ b/.pylintrc @@ -7,7 +7,7 @@ extension-pkg-whitelist= # Add files or directories to the blacklist. They should be base names, not # paths. -ignore=CVS +ignore=CVS, migrations, docker-compose.py, docker.py # Add files or directories matching the regex patterns to the blacklist. The # regex matches against base names, not paths. @@ -67,7 +67,14 @@ disable=missing-docstring, wildcard-import, function-redefined, too-many-ancestors, - too-many-statements + too-many-statements, + unsubscriptable-object, + too-many-locals, + too-many-arguments, + too-many-public-methods, + too-few-public-methods, + duplicate-code, + no-self-use, # Disabled by default: @@ -204,7 +211,7 @@ argument-naming-style=snake_case # Regular expression matching correct argument names. Overrides argument- # naming-style. -#argument-rgx= +argument-rgx=[a-z0-9_]{1,30}$ # Naming style matching correct attribute names. attr-naming-style=snake_case @@ -303,7 +310,7 @@ variable-naming-style=snake_case # Regular expression matching correct variable names. Overrides variable- # naming-style. -#variable-rgx= +variable-rgx=[a-z0-9_]{1,75}$ [FORMAT] diff --git a/config/docker-compose.py b/config/docker-compose.py index e5f1f2a9..a51ed730 100644 --- a/config/docker-compose.py +++ b/config/docker-compose.py @@ -1,5 +1,5 @@ # Docker settings -from .settings import * # NOQA +from .settings import * DATABASES = { 'default': { diff --git a/config/docker.py b/config/docker.py index 98e07052..f86dc096 100755 --- a/config/docker.py +++ b/config/docker.py @@ -1,5 +1,5 @@ # Docker settings -from .settings import * # NOQA +from .settings import * DATABASES = { 'default': { diff --git a/config/local.py b/config/local.py index c0758580..af1fbcdb 100755 --- a/config/local.py +++ b/config/local.py @@ -1,4 +1,4 @@ -from .settings import * # NOQA +from .settings import * DATABASES = { 'default': { diff --git a/config/settings.py b/config/settings.py index f7cc514c..f9a066fd 100755 --- a/config/settings.py +++ b/config/settings.py @@ -1,6 +1,6 @@ # Production settings -from unipath import Path import os +from unipath import Path PROJECT_ROOT = Path(__file__).ancestor(2) diff --git a/config/urls.py b/config/urls.py index 20f29fae..07557a8a 100755 --- a/config/urls.py +++ b/config/urls.py @@ -1,7 +1,8 @@ from django.conf.urls import include, url - from pokemon_v2 import urls as pokemon_v2_urls +# pylint: disable=invalid-name + urlpatterns = [ url(r'^', include(pokemon_v2_urls)), ] diff --git a/data/v2/__init__.py b/data/v2/__init__.py index edae34fb..39496a2f 100644 --- a/data/v2/__init__.py +++ b/data/v2/__init__.py @@ -1 +1 @@ -from .build import * # NOQA +from .build import * diff --git a/data/v2/build.py b/data/v2/build.py index 3d06f0d8..a4f8d543 100644 --- a/data/v2/build.py +++ b/data/v2/build.py @@ -17,33 +17,32 @@ import os.path import re import json from django.db import connection -from pokemon_v2.models import * # NOQA +from pokemon_v2.models import * # why this way? how about use `__file__` -DATA_LOCATION = 'data/v2/csv/' -DATA_LOCATION2 = os.path.join(os.path.dirname(__file__), 'csv') +DATA_LOCATION = "data/v2/csv/" +DATA_LOCATION2 = os.path.join(os.path.dirname(__file__), "csv") GROUP_RGX = r"\[(.*?)\]\{(.*?)\}" SUB_RGX = r"\[.*?\]\{.*?\}" -db_cursor = connection.cursor() +DB_CURSOR = connection.cursor() DB_VENDOR = connection.vendor -imageDir = os.getcwd() + '/data/v2/sprites/' -resourceImages = [] -for root, dirs, files in os.walk(imageDir): +MEDIA_DIR = "/media/sprites/{0}" +IMAGE_DIR = os.getcwd() + "/data/v2/sprites/" +RESOURCE_IMAGES = [] + +for root, dirs, files in os.walk(IMAGE_DIR): for file in files: - image_path = os.path.join(root.replace(imageDir, ""), file) - image_path = image_path.replace("\\", "/") # convert Windows-style path to Unix - resourceImages.append(image_path) + image_path = os.path.join(root.replace(IMAGE_DIR, ""), file) + image_path = image_path.replace("\\", "/") # convert Windows-style path to Unix + RESOURCE_IMAGES.append(image_path) -mediaDir = '/media/sprites/{0}' - - -def filePathOrNone(fileName): - return mediaDir.format(fileName) if fileName in resourceImages else None +def file_path_or_none(file_name): + return MEDIA_DIR.format(file_name) if file_name in RESOURCE_IMAGES else None def with_iter(context, iterable=None): @@ -54,28 +53,37 @@ def with_iter(context, iterable=None): yield value -def load_data(fileName): +def load_data(file_name): # with_iter closes the file when it has finished - return csv.reader(with_iter(open(DATA_LOCATION + fileName, 'rt', encoding="utf8")), delimiter=',') + return csv.reader( + with_iter(open(DATA_LOCATION + file_name, "rt", encoding="utf8")), delimiter="," + ) def clear_table(model): table_name = model._meta.db_table model.objects.all().delete() - print('building ' + table_name) + print("building " + table_name) # Reset DB auto increments to start at 1 - if DB_VENDOR == 'sqlite': - db_cursor.execute("DELETE FROM sqlite_sequence WHERE name = " + "'" + table_name + "'") + if DB_VENDOR == "sqlite": + DB_CURSOR.execute( + "DELETE FROM sqlite_sequence WHERE name = " + "'" + table_name + "'" + ) else: - db_cursor.execute( - "SELECT setval(pg_get_serial_sequence(" + "'" + table_name + "'" + ",'id'), 1, false);") + DB_CURSOR.execute( + "SELECT setval(pg_get_serial_sequence(" + + "'" + + table_name + + "'" + + ",'id'), 1, false);" + ) def build_generic(model_classes, file_name, csv_record_to_objects): batches = {} for model_class in model_classes: clear_table(model_class) - batches[model_class] = [] # one batch per model class + batches[model_class] = [] # one batch per model class csv_data = load_data(file_name) next(csv_data, None) # skip header @@ -94,7 +102,7 @@ def build_generic(model_classes, file_name, csv_record_to_objects): model_class.objects.bulk_create(batch) -def scrubStr(str): +def scrub_str(string): """ The purpose of this function is to scrub the weird template mark-up out of strings that Veekun is using for their pokedex. @@ -105,23 +113,23 @@ def scrubStr(str): If you find this results in weird strings please take a stab at improving or re-writing. """ - groups = re.findall(GROUP_RGX, str) + groups = re.findall(GROUP_RGX, string) for group in groups: if group[0]: sub = group[0] else: sub = group[1].split(":")[1] sub = sub.replace("-", " ") - str = re.sub(SUB_RGX, sub, str, 1) - return str + string = re.sub(SUB_RGX, sub, string, 1) + return string ############## # LANGUAGE # ############## -def _build_languages(): +def _build_languages(): def csv_record_to_objects(info): yield Language( id=int(info[0]), @@ -131,1559 +139,1556 @@ def _build_languages(): official=bool(int(info[4])), order=info[5], ) - build_generic((Language,), 'languages.csv', csv_record_to_objects) + + build_generic((Language,), "languages.csv", csv_record_to_objects) def csv_record_to_objects(info): yield LanguageName( - language_id=int(info[0]), - local_language_id=int(info[1]), - name=info[2] + language_id=int(info[0]), local_language_id=int(info[1]), name=info[2] ) - build_generic((LanguageName,), 'language_names.csv', csv_record_to_objects) + build_generic((LanguageName,), "language_names.csv", csv_record_to_objects) ############ # REGION # ############ + def _build_regions(): + def csv_record_to_objects(info): + yield Region(id=int(info[0]), name=info[1]) + + build_generic((Region,), "regions.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield Region( - id=int(info[0]), - name=info[1] - ) - build_generic((Region,), 'regions.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield RegionName( - region_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((RegionName,), 'region_names.csv', csv_record_to_objects) + yield RegionName(region_id=int(info[0]), language_id=int(info[1]), name=info[2]) + build_generic((RegionName,), "region_names.csv", csv_record_to_objects) ################ # GENERATION # ################ + def _build_generations(): def csv_record_to_objects(info): - yield Generation( - id = int(info[0]), - region_id = int(info[1]), - name = info[2] - ) - build_generic((Generation,), 'generations.csv', csv_record_to_objects) + yield Generation(id=int(info[0]), region_id=int(info[1]), name=info[2]) + + build_generic((Generation,), "generations.csv", csv_record_to_objects) def csv_record_to_objects(info): yield GenerationName( - generation_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + generation_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((GenerationName,), 'generation_names.csv', csv_record_to_objects) + build_generic((GenerationName,), "generation_names.csv", csv_record_to_objects) ############# # VERSION # ############# -def _build_versions(): +def _build_versions(): def csv_record_to_objects(info): yield VersionGroup( - id = int(info[0]), - name = info[1], - generation_id = int(info[2]), - order = int(info[3]) + id=int(info[0]), + name=info[1], + generation_id=int(info[2]), + order=int(info[3]), ) - build_generic((VersionGroup,), 'version_groups.csv', csv_record_to_objects) + + build_generic((VersionGroup,), "version_groups.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield VersionGroupRegion( - version_group_id = int(info[0]), - region_id = int(info[1]), - ) - build_generic((VersionGroupRegion,), 'version_group_regions.csv', csv_record_to_objects) + yield VersionGroupRegion(version_group_id=int(info[0]), region_id=int(info[1])) + + build_generic( + (VersionGroupRegion,), "version_group_regions.csv", csv_record_to_objects + ) def csv_record_to_objects(info): - yield Version( - id = int(info[0]), - version_group_id = int(info[1]), - name = info[2] - ) - build_generic((Version,), 'versions.csv', csv_record_to_objects) + yield Version(id=int(info[0]), version_group_id=int(info[1]), name=info[2]) + + build_generic((Version,), "versions.csv", csv_record_to_objects) def csv_record_to_objects(info): yield VersionName( - version_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + version_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((VersionName,), 'version_names.csv', csv_record_to_objects) + build_generic((VersionName,), "version_names.csv", csv_record_to_objects) ################## # DAMAGE CLASS # ################## -def _build_damage_classes(): +def _build_damage_classes(): def csv_record_to_objects(info): - yield MoveDamageClass( - id = int(info[0]), - name = info[1] - ) - build_generic((MoveDamageClass,), 'move_damage_classes.csv', csv_record_to_objects) + yield MoveDamageClass(id=int(info[0]), name=info[1]) + + build_generic((MoveDamageClass,), "move_damage_classes.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveDamageClassName( - move_damage_class_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + move_damage_class_id=int(info[0]), language_id=int(info[1]), name=info[2] ) yield MoveDamageClassDescription( - move_damage_class_id = int(info[0]), - language_id = int(info[1]), - description = info[3] + move_damage_class_id=int(info[0]), + language_id=int(info[1]), + description=info[3], ) + build_generic( (MoveDamageClassName, MoveDamageClassDescription), - 'move_damage_class_prose.csv', - csv_record_to_objects + "move_damage_class_prose.csv", + csv_record_to_objects, ) - ########### # STATS # ########### -def _build_stats(): +def _build_stats(): def csv_record_to_objects(info): yield Stat( - id = int(info[0]), - move_damage_class_id = int(info[1]) if info[1] != '' else None, - name = info[2], - is_battle_only = bool(int(info[3])), - game_index = int(info[4]) if info[4] else 0, + id=int(info[0]), + move_damage_class_id=int(info[1]) if info[1] != "" else None, + name=info[2], + is_battle_only=bool(int(info[3])), + game_index=int(info[4]) if info[4] else 0, ) - build_generic((Stat,), 'stats.csv', csv_record_to_objects) + + build_generic((Stat,), "stats.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield StatName( - stat_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((StatName,), 'stat_names.csv', csv_record_to_objects) + yield StatName(stat_id=int(info[0]), language_id=int(info[1]), name=info[2]) + + build_generic((StatName,), "stat_names.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield PokeathlonStat( - id = int(info[0]), - name = info[1], - ) - build_generic((PokeathlonStat,), 'pokeathlon_stats.csv', csv_record_to_objects) + yield PokeathlonStat(id=int(info[0]), name=info[1]) + + build_generic((PokeathlonStat,), "pokeathlon_stats.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokeathlonStatName( - pokeathlon_stat_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + pokeathlon_stat_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((PokeathlonStatName,), 'pokeathlon_stat_names.csv', csv_record_to_objects) + build_generic( + (PokeathlonStatName,), "pokeathlon_stat_names.csv", csv_record_to_objects + ) # ############### # # ABILITIES # # ############### -def _build_abilities(): +def _build_abilities(): def csv_record_to_objects(info): yield Ability( - id = int(info[0]), - name = info[1], - generation_id = int(info[2]), - is_main_series = bool(int(info[3])) + id=int(info[0]), + name=info[1], + generation_id=int(info[2]), + is_main_series=bool(int(info[3])), ) - build_generic((Ability,), 'abilities.csv', csv_record_to_objects) + + build_generic((Ability,), "abilities.csv", csv_record_to_objects) def csv_record_to_objects(info): yield AbilityName( - ability_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + ability_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((AbilityName,), 'ability_names.csv', csv_record_to_objects) + + build_generic((AbilityName,), "ability_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield AbilityChange( - id = int(info[0]), - ability_id = int(info[1]), - version_group_id = int(info[2]) + id=int(info[0]), ability_id=int(info[1]), version_group_id=int(info[2]) ) - build_generic((AbilityChange,), 'ability_changelog.csv', csv_record_to_objects) + + build_generic((AbilityChange,), "ability_changelog.csv", csv_record_to_objects) def csv_record_to_objects(info): yield AbilityEffectText( - ability_id = int(info[0]), - language_id = int(info[1]), - short_effect = scrubStr(info[2]), - effect = scrubStr(info[3]) + ability_id=int(info[0]), + language_id=int(info[1]), + short_effect=scrub_str(info[2]), + effect=scrub_str(info[3]), ) - build_generic((AbilityEffectText,), 'ability_prose.csv', csv_record_to_objects) + + build_generic((AbilityEffectText,), "ability_prose.csv", csv_record_to_objects) def csv_record_to_objects(info): yield AbilityChangeEffectText( - ability_change_id = int(info[0]), - language_id = int(info[1]), - effect = scrubStr(info[2]) + ability_change_id=int(info[0]), + language_id=int(info[1]), + effect=scrub_str(info[2]), ) - build_generic((AbilityChangeEffectText,), 'ability_changelog_prose.csv', csv_record_to_objects) + + build_generic( + (AbilityChangeEffectText,), "ability_changelog_prose.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield AbilityFlavorText( - ability_id = int(info[0]), - version_group_id = int(info[1]), - language_id = int(info[2]), - flavor_text = info[3] + ability_id=int(info[0]), + version_group_id=int(info[1]), + language_id=int(info[2]), + flavor_text=info[3], ) - build_generic((AbilityFlavorText,), 'ability_flavor_text.csv', csv_record_to_objects) + build_generic( + (AbilityFlavorText,), "ability_flavor_text.csv", csv_record_to_objects + ) #################### # CHARACTERISTIC # #################### -def _build_characteristics(): +def _build_characteristics(): def csv_record_to_objects(info): yield Characteristic( - id = int(info[0]), - stat_id = int(info[1]), - gene_mod_5 = int(info[2]) + id=int(info[0]), stat_id=int(info[1]), gene_mod_5=int(info[2]) ) - build_generic((Characteristic,), 'characteristics.csv', csv_record_to_objects) + + build_generic((Characteristic,), "characteristics.csv", csv_record_to_objects) def csv_record_to_objects(info): yield CharacteristicDescription( - characteristic_id = int(info[0]), - language_id = int(info[1]), - description = info[2] + characteristic_id=int(info[0]), + language_id=int(info[1]), + description=info[2], ) - build_generic((CharacteristicDescription,), 'characteristic_text.csv', csv_record_to_objects) + build_generic( + (CharacteristicDescription,), "characteristic_text.csv", csv_record_to_objects + ) ############### # EGG GROUP # ############### -def _build_egg_groups(): +def _build_egg_groups(): def csv_record_to_objects(info): - yield EggGroup( - id = int(info[0]), - name = info[1] - ) - build_generic((EggGroup,), 'egg_groups.csv', csv_record_to_objects) + yield EggGroup(id=int(info[0]), name=info[1]) + + build_generic((EggGroup,), "egg_groups.csv", csv_record_to_objects) def csv_record_to_objects(info): yield EggGroupName( - egg_group_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + egg_group_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((EggGroupName,), 'egg_group_prose.csv', csv_record_to_objects) + build_generic((EggGroupName,), "egg_group_prose.csv", csv_record_to_objects) ################# # GROWTH RATE # ################# -def _build_growth_rates(): +def _build_growth_rates(): def csv_record_to_objects(info): - yield GrowthRate( - id = int(info[0]), - name = info[1], - formula = info[2] - ) - build_generic((GrowthRate,), 'growth_rates.csv', csv_record_to_objects) + yield GrowthRate(id=int(info[0]), name=info[1], formula=info[2]) + + build_generic((GrowthRate,), "growth_rates.csv", csv_record_to_objects) def csv_record_to_objects(info): yield GrowthRateDescription( - growth_rate_id = int(info[0]), - language_id = int(info[1]), - description = info[2] + growth_rate_id=int(info[0]), language_id=int(info[1]), description=info[2] ) - build_generic((GrowthRateDescription,), 'growth_rate_prose.csv', csv_record_to_objects) + build_generic( + (GrowthRateDescription,), "growth_rate_prose.csv", csv_record_to_objects + ) # ########### # # ITEMS # # ########### -def _build_items(): +def _build_items(): def csv_record_to_objects(info): - yield ItemPocket( - id = int(info[0]), - name = info[1] - ) - build_generic((ItemPocket,), 'item_pockets.csv', csv_record_to_objects) + yield ItemPocket(id=int(info[0]), name=info[1]) + + build_generic((ItemPocket,), "item_pockets.csv", csv_record_to_objects) def csv_record_to_objects(info): yield ItemPocketName( - item_pocket_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + item_pocket_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((ItemPocketName,), 'item_pocket_names.csv', csv_record_to_objects) + + build_generic((ItemPocketName,), "item_pocket_names.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield ItemFlingEffect( - id = int(info[0]), - name = info[1] - ) - build_generic((ItemFlingEffect,), 'item_fling_effects.csv', csv_record_to_objects) + yield ItemFlingEffect(id=int(info[0]), name=info[1]) + + build_generic((ItemFlingEffect,), "item_fling_effects.csv", csv_record_to_objects) def csv_record_to_objects(info): yield ItemFlingEffectEffectText( - item_fling_effect_id = int(info[0]), - language_id = int(info[1]), - effect = scrubStr(info[2]) + item_fling_effect_id=int(info[0]), + language_id=int(info[1]), + effect=scrub_str(info[2]), ) - build_generic((ItemFlingEffectEffectText,), 'item_fling_effect_prose.csv', csv_record_to_objects) - def csv_record_to_objects(info): - yield ItemCategory( - id = int(info[0]), - item_pocket_id = int(info[1]), - name = info[2] - ) - build_generic((ItemCategory,), 'item_categories.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemCategoryName( - item_category_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((ItemCategoryName,), 'item_category_prose.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield Item( - id = int(info[0]), - name = info[1], - item_category_id = int(info[2]), - cost = int(info[3]), - fling_power = int(info[4]) if info[4] != '' else None, - item_fling_effect_id = int(info[5]) if info[5] != '' else None - ) - build_generic((Item,), 'items.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - if re.search(r"^data-card", info[1]): - fileName = 'data-card.png' - elif re.search(r"^tm[0-9]", info[1]): - fileName = 'tm-normal.png' - elif re.search(r"^hm[0-9]", info[1]): - fileName = 'hm-normal.png' - else: - fileName = '%s.png' % info[1] - - itemSprites = 'items/{0}'; - sprites = { - 'default': filePathOrNone(itemSprites.format(fileName)), - } - yield ItemSprites( - id = int(info[0]), - item_id = int(info[0]), - sprites = json.dumps(sprites) - ) - build_generic((ItemSprites,), 'items.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemName( - item_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((ItemName,), 'item_names.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemEffectText( - item_id = int(info[0]), - language_id = int(info[1]), - short_effect = scrubStr(info[2]), - effect = scrubStr(info[3]) - ) - build_generic((ItemEffectText,), 'item_prose.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemGameIndex( - item_id = int(info[0]), - generation_id = int(info[1]), - game_index = int(info[2]) - ) - build_generic((ItemGameIndex,), 'item_game_indices.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemFlavorText( - item_id = int(info[0]), - version_group_id = int(info[1]), - language_id = int(info[2]), - flavor_text = info[3] - ) - build_generic((ItemFlavorText,), 'item_flavor_text.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemAttribute( - id = int(info[0]), - name = info[1] - ) - build_generic((ItemAttribute,), 'item_flags.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield ItemAttributeName( - item_attribute_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - yield ItemAttributeDescription( - item_attribute_id = int(info[0]), - language_id = int(info[1]), - description = info[3] - ) build_generic( - (ItemAttributeName, ItemAttributeDescription), - 'item_flag_prose.csv', - csv_record_to_objects + (ItemFlingEffectEffectText,), + "item_fling_effect_prose.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): - yield ItemAttributeMap( - item_id = int(info[0]), - item_attribute_id = int(info[1]) - ) - build_generic((ItemAttributeMap,), 'item_flag_map.csv', csv_record_to_objects) + yield ItemCategory(id=int(info[0]), item_pocket_id=int(info[1]), name=info[2]) + build_generic((ItemCategory,), "item_categories.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemCategoryName( + item_category_id=int(info[0]), language_id=int(info[1]), name=info[2] + ) + + build_generic((ItemCategoryName,), "item_category_prose.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield Item( + id=int(info[0]), + name=info[1], + item_category_id=int(info[2]), + cost=int(info[3]), + fling_power=int(info[4]) if info[4] != "" else None, + item_fling_effect_id=int(info[5]) if info[5] != "" else None, + ) + + build_generic((Item,), "items.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + if re.search(r"^data-card", info[1]): + file_name = "data-card.png" + elif re.search(r"^tm[0-9]", info[1]): + file_name = "tm-normal.png" + elif re.search(r"^hm[0-9]", info[1]): + file_name = "hm-normal.png" + else: + file_name = "%s.png" % info[1] + + item_sprites = "items/{0}" + sprites = {"default": file_path_or_none(item_sprites.format(file_name))} + yield ItemSprites( + id=int(info[0]), item_id=int(info[0]), sprites=json.dumps(sprites) + ) + + build_generic((ItemSprites,), "items.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemName(item_id=int(info[0]), language_id=int(info[1]), name=info[2]) + + build_generic((ItemName,), "item_names.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemEffectText( + item_id=int(info[0]), + language_id=int(info[1]), + short_effect=scrub_str(info[2]), + effect=scrub_str(info[3]), + ) + + build_generic((ItemEffectText,), "item_prose.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemGameIndex( + item_id=int(info[0]), generation_id=int(info[1]), game_index=int(info[2]) + ) + + build_generic((ItemGameIndex,), "item_game_indices.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemFlavorText( + item_id=int(info[0]), + version_group_id=int(info[1]), + language_id=int(info[2]), + flavor_text=info[3], + ) + + build_generic((ItemFlavorText,), "item_flavor_text.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemAttribute(id=int(info[0]), name=info[1]) + + build_generic((ItemAttribute,), "item_flags.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield ItemAttributeName( + item_attribute_id=int(info[0]), language_id=int(info[1]), name=info[2] + ) + yield ItemAttributeDescription( + item_attribute_id=int(info[0]), + language_id=int(info[1]), + description=info[3], + ) + + build_generic( + (ItemAttributeName, ItemAttributeDescription), + "item_flag_prose.csv", + csv_record_to_objects, + ) + + def csv_record_to_objects(info): + yield ItemAttributeMap(item_id=int(info[0]), item_attribute_id=int(info[1])) + + build_generic((ItemAttributeMap,), "item_flag_map.csv", csv_record_to_objects) ########### # TYPES # ########### -def _build_types(): +def _build_types(): def csv_record_to_objects(info): yield Type( - id = int(info[0]), - name = info[1], - generation_id = int(info[2]), - move_damage_class_id = int(info[3]) if info[3] != '' else None + id=int(info[0]), + name=info[1], + generation_id=int(info[2]), + move_damage_class_id=int(info[3]) if info[3] != "" else None, ) - build_generic((Type,), 'types.csv', csv_record_to_objects) + + build_generic((Type,), "types.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield TypeName( - type_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((TypeName,), 'type_names.csv', csv_record_to_objects) + yield TypeName(type_id=int(info[0]), language_id=int(info[1]), name=info[2]) + + build_generic((TypeName,), "type_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield TypeGameIndex( - type_id = int(info[0]), - generation_id = int(info[1]), - game_index = int(info[2]) + type_id=int(info[0]), generation_id=int(info[1]), game_index=int(info[2]) ) - build_generic((TypeGameIndex,), 'type_game_indices.csv', csv_record_to_objects) + + build_generic((TypeGameIndex,), "type_game_indices.csv", csv_record_to_objects) def csv_record_to_objects(info): yield TypeEfficacy( - damage_type_id = int(info[0]), - target_type_id = int(info[1]), - damage_factor = int(info[2]) + damage_type_id=int(info[0]), + target_type_id=int(info[1]), + damage_factor=int(info[2]), ) - build_generic((TypeEfficacy,), 'type_efficacy.csv', csv_record_to_objects) + build_generic((TypeEfficacy,), "type_efficacy.csv", csv_record_to_objects) ############# # CONTEST # ############# -def _build_contests(): +def _build_contests(): def csv_record_to_objects(info): - yield ContestType( - id = int(info[0]), - name = info[1] - ) - build_generic((ContestType,), 'contest_types.csv', csv_record_to_objects) + yield ContestType(id=int(info[0]), name=info[1]) + + build_generic((ContestType,), "contest_types.csv", csv_record_to_objects) def csv_record_to_objects(info): yield ContestTypeName( - contest_type_id = int(info[0]), - language_id = int(info[1]), - name = info[2], - flavor = info[3], - color = info[4] + contest_type_id=int(info[0]), + language_id=int(info[1]), + name=info[2], + flavor=info[3], + color=info[4], ) - build_generic((ContestTypeName,), 'contest_type_names.csv', csv_record_to_objects) + + build_generic((ContestTypeName,), "contest_type_names.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield ContestEffect( - id = int(info[0]), - appeal = int(info[1]), - jam = int(info[2]) - ) - build_generic((ContestEffect,), 'contest_effects.csv', csv_record_to_objects) + yield ContestEffect(id=int(info[0]), appeal=int(info[1]), jam=int(info[2])) + + build_generic((ContestEffect,), "contest_effects.csv", csv_record_to_objects) def csv_record_to_objects(info): yield ContestEffectEffectText( - contest_effect_id = int(info[0]), - language_id = int(info[1]), - effect = info[3] + contest_effect_id=int(info[0]), language_id=int(info[1]), effect=info[3] ) yield ContestEffectFlavorText( - contest_effect_id = int(info[0]), - language_id = int(info[1]), - flavor_text = info[2] + contest_effect_id=int(info[0]), + language_id=int(info[1]), + flavor_text=info[2], ) + build_generic( (ContestEffectEffectText, ContestEffectFlavorText), - 'contest_effect_prose.csv', - csv_record_to_objects + "contest_effect_prose.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): - yield SuperContestEffect( - id = int(info[0]), - appeal = int(info[1]) - ) - build_generic((SuperContestEffect,), 'super_contest_effects.csv', csv_record_to_objects) + yield SuperContestEffect(id=int(info[0]), appeal=int(info[1])) + + build_generic( + (SuperContestEffect,), "super_contest_effects.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield SuperContestEffectFlavorText( - super_contest_effect_id = int(info[0]), - language_id = int(info[1]), - flavor_text = info[2] + super_contest_effect_id=int(info[0]), + language_id=int(info[1]), + flavor_text=info[2], ) - build_generic( - (SuperContestEffectFlavorText,), 'super_contest_effect_prose.csv', csv_record_to_objects - ) + build_generic( + (SuperContestEffectFlavorText,), + "super_contest_effect_prose.csv", + csv_record_to_objects, + ) ########### # MOVES # ########### -def _build_moves(): +def _build_moves(): def csv_record_to_objects(info): - yield MoveEffect( - id = int(info[0]) - ) - build_generic((MoveEffect,), 'move_effects.csv', csv_record_to_objects) + yield MoveEffect(id=int(info[0])) + + build_generic((MoveEffect,), "move_effects.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveEffectEffectText( - move_effect_id = int(info[0]), - language_id = int(info[1]), - short_effect = scrubStr(info[2]), - effect = scrubStr(info[3]) + move_effect_id=int(info[0]), + language_id=int(info[1]), + short_effect=scrub_str(info[2]), + effect=scrub_str(info[3]), ) - build_generic((MoveEffectEffectText,), 'move_effect_prose.csv', csv_record_to_objects) - def csv_record_to_objects(info): - yield MoveEffectChange( - id = int(info[0]), - move_effect_id = int(info[1]), - version_group_id = int(info[2]) - ) - build_generic((MoveEffectChange,), 'move_effect_changelog.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield MoveEffectChangeEffectText( - move_effect_change_id = int(info[0]), - language_id = int(info[1]), - effect = scrubStr(info[2]) - ) build_generic( - (MoveEffectChangeEffectText,), 'move_effect_changelog_prose.csv', csv_record_to_objects + (MoveEffectEffectText,), "move_effect_prose.csv", csv_record_to_objects ) def csv_record_to_objects(info): - yield MoveLearnMethod( - id = int(info[0]), - name = info[1] + yield MoveEffectChange( + id=int(info[0]), move_effect_id=int(info[1]), version_group_id=int(info[2]) ) - build_generic((MoveLearnMethod,), 'pokemon_move_methods.csv', csv_record_to_objects) + + build_generic( + (MoveEffectChange,), "move_effect_changelog.csv", csv_record_to_objects + ) + + def csv_record_to_objects(info): + yield MoveEffectChangeEffectText( + move_effect_change_id=int(info[0]), + language_id=int(info[1]), + effect=scrub_str(info[2]), + ) + + build_generic( + (MoveEffectChangeEffectText,), + "move_effect_changelog_prose.csv", + csv_record_to_objects, + ) + + def csv_record_to_objects(info): + yield MoveLearnMethod(id=int(info[0]), name=info[1]) + + build_generic((MoveLearnMethod,), "pokemon_move_methods.csv", csv_record_to_objects) def csv_record_to_objects(info): yield VersionGroupMoveLearnMethod( - version_group_id = int(info[0]), - move_learn_method_id = int(info[1]), + version_group_id=int(info[0]), move_learn_method_id=int(info[1]) ) + build_generic( (VersionGroupMoveLearnMethod,), - 'version_group_pokemon_move_methods.csv', - csv_record_to_objects + "version_group_pokemon_move_methods.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield MoveLearnMethodName( - move_learn_method_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + move_learn_method_id=int(info[0]), language_id=int(info[1]), name=info[2] ) yield MoveLearnMethodDescription( - move_learn_method_id = int(info[0]), - language_id = int(info[1]), - description = info[3] + move_learn_method_id=int(info[0]), + language_id=int(info[1]), + description=info[3], ) + build_generic( (MoveLearnMethodName, MoveLearnMethodDescription), - 'pokemon_move_method_prose.csv', - csv_record_to_objects + "pokemon_move_method_prose.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): - yield MoveTarget( - id = int(info[0]), - name = info[1] - ) - build_generic((MoveTarget,), 'move_targets.csv', csv_record_to_objects) + yield MoveTarget(id=int(info[0]), name=info[1]) + + build_generic((MoveTarget,), "move_targets.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveTargetName( - move_target_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + move_target_id=int(info[0]), language_id=int(info[1]), name=info[2] ) yield MoveTargetDescription( - move_target_id = int(info[0]), - language_id = int(info[1]), - description = info[3] + move_target_id=int(info[0]), language_id=int(info[1]), description=info[3] ) + build_generic( - (MoveTargetName, MoveTargetDescription), 'move_target_prose.csv', csv_record_to_objects + (MoveTargetName, MoveTargetDescription), + "move_target_prose.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield Move( - id = int(info[0]), - name = info[1], - generation_id = int(info[2]), - type_id = int(info[3]), - power = int(info[4]) if info[4] != '' else None, - pp = int(info[5]) if info[5] != '' else None, - accuracy = int(info[6]) if info[6] != '' else None, - priority = int(info[7]) if info[7] != '' else None, - move_target_id = int(info[8]), - move_damage_class_id = int(info[9]), - move_effect_id = int(info[10]), - move_effect_chance = int(info[11]) if info[11] != '' else None, - contest_type_id = int(info[12]) if info[12] != '' else None, - contest_effect_id = int(info[13]) if info[13] != '' else None, - super_contest_effect_id = int(info[14]) if info[14] != '' else None + id=int(info[0]), + name=info[1], + generation_id=int(info[2]), + type_id=int(info[3]), + power=int(info[4]) if info[4] != "" else None, + pp=int(info[5]) if info[5] != "" else None, + accuracy=int(info[6]) if info[6] != "" else None, + priority=int(info[7]) if info[7] != "" else None, + move_target_id=int(info[8]), + move_damage_class_id=int(info[9]), + move_effect_id=int(info[10]), + move_effect_chance=int(info[11]) if info[11] != "" else None, + contest_type_id=int(info[12]) if info[12] != "" else None, + contest_effect_id=int(info[13]) if info[13] != "" else None, + super_contest_effect_id=int(info[14]) if info[14] != "" else None, ) - build_generic((Move,), 'moves.csv', csv_record_to_objects) + + build_generic((Move,), "moves.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield MoveName( - move_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((MoveName,), 'move_names.csv', csv_record_to_objects) + yield MoveName(move_id=int(info[0]), language_id=int(info[1]), name=info[2]) + + build_generic((MoveName,), "move_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveFlavorText( - move_id = int(info[0]), - version_group_id = int(info[1]), - language_id = int(info[2]), - flavor_text = info[3] + move_id=int(info[0]), + version_group_id=int(info[1]), + language_id=int(info[2]), + flavor_text=info[3], ) - build_generic((MoveFlavorText,), 'move_flavor_text.csv', csv_record_to_objects) + + build_generic((MoveFlavorText,), "move_flavor_text.csv", csv_record_to_objects) def csv_record_to_objects(info): _move_effect = None try: - _move_effect = MoveEffect.objects.get(pk = int(info[6])) if info[6] != '' else None + _move_effect = ( + MoveEffect.objects.get(pk=int(info[6])) if info[6] != "" else None + ) except: pass yield MoveChange( - move_id = int(info[0]), - version_group_id = int(info[1]), - type_id = int(info[2]) if info[2] != '' else None, - power = int(info[3]) if info[3] != '' else None, - pp = int(info[4]) if info[4] != '' else None, - accuracy = int(info[5]) if info[5] != '' else None, - move_effect_id = _move_effect.pk if _move_effect else None, - move_effect_chance = int(info[7]) if info[7] != '' else None + move_id=int(info[0]), + version_group_id=int(info[1]), + type_id=int(info[2]) if info[2] != "" else None, + power=int(info[3]) if info[3] != "" else None, + pp=int(info[4]) if info[4] != "" else None, + accuracy=int(info[5]) if info[5] != "" else None, + move_effect_id=_move_effect.pk if _move_effect else None, + move_effect_chance=int(info[7]) if info[7] != "" else None, ) - build_generic((MoveChange,), 'move_changelog.csv', csv_record_to_objects) + + build_generic((MoveChange,), "move_changelog.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield MoveBattleStyle( - id = int(info[0]), - name = info[1] - ) - build_generic((MoveBattleStyle,), 'move_battle_styles.csv', csv_record_to_objects) + yield MoveBattleStyle(id=int(info[0]), name=info[1]) + + build_generic((MoveBattleStyle,), "move_battle_styles.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveBattleStyleName( - move_battle_style_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + move_battle_style_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((MoveBattleStyleName,), 'move_battle_style_prose.csv', csv_record_to_objects) - def csv_record_to_objects(info): - yield MoveAttribute( - id = int(info[0]), - name = info[1] - ) - build_generic((MoveAttribute,), 'move_flags.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield MoveAttributeMap( - move_id = int(info[0]), - move_attribute_id = int(info[1]), - ) - build_generic((MoveAttributeMap,), 'move_flag_map.csv', csv_record_to_objects) - - def csv_record_to_objects(info): - yield MoveAttributeName( - move_attribute_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - yield MoveAttributeDescription( - move_attribute_id = int(info[0]), - language_id = int(info[1]), - description = scrubStr(info[3]) - ) build_generic( - (MoveAttributeName, MoveAttributeDescription), 'move_flag_prose.csv', csv_record_to_objects + (MoveBattleStyleName,), "move_battle_style_prose.csv", csv_record_to_objects ) def csv_record_to_objects(info): - yield MoveMetaAilment( - id = int(info[0]), - name = info[1] + yield MoveAttribute(id=int(info[0]), name=info[1]) + + build_generic((MoveAttribute,), "move_flags.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield MoveAttributeMap(move_id=int(info[0]), move_attribute_id=int(info[1])) + + build_generic((MoveAttributeMap,), "move_flag_map.csv", csv_record_to_objects) + + def csv_record_to_objects(info): + yield MoveAttributeName( + move_attribute_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((MoveMetaAilment,), 'move_meta_ailments.csv', csv_record_to_objects) + yield MoveAttributeDescription( + move_attribute_id=int(info[0]), + language_id=int(info[1]), + description=scrub_str(info[3]), + ) + + build_generic( + (MoveAttributeName, MoveAttributeDescription), + "move_flag_prose.csv", + csv_record_to_objects, + ) + + def csv_record_to_objects(info): + yield MoveMetaAilment(id=int(info[0]), name=info[1]) + + build_generic((MoveMetaAilment,), "move_meta_ailments.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveMetaAilmentName( - move_meta_ailment_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + move_meta_ailment_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((MoveMetaAilmentName,), 'move_meta_ailment_names.csv', csv_record_to_objects) + + build_generic( + (MoveMetaAilmentName,), "move_meta_ailment_names.csv", csv_record_to_objects + ) def csv_record_to_objects(info): - yield MoveMetaCategory( - id = int(info[0]), - name = info[1] - ) - build_generic((MoveMetaCategory,), 'move_meta_categories.csv', csv_record_to_objects) + yield MoveMetaCategory(id=int(info[0]), name=info[1]) + + build_generic( + (MoveMetaCategory,), "move_meta_categories.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield MoveMetaCategoryDescription( - move_meta_category_id = int(info[0]), - language_id = int(info[1]), - description = info[2] + move_meta_category_id=int(info[0]), + language_id=int(info[1]), + description=info[2], ) + build_generic( - (MoveMetaCategoryDescription,), 'move_meta_category_prose.csv', csv_record_to_objects + (MoveMetaCategoryDescription,), + "move_meta_category_prose.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield MoveMeta( - move_id = int(info[0]), - move_meta_category_id = int(info[1]), - move_meta_ailment_id = int(info[2]), - min_hits = int(info[3]) if info[3] != '' else None, - max_hits = int(info[4]) if info[4] != '' else None, - min_turns = int(info[5]) if info[5] != '' else None, - max_turns = int(info[6]) if info[6] != '' else None, - drain = int(info[7]) if info[7] != '' else None, - healing = int(info[8]) if info[8] != '' else None, - crit_rate = int(info[9]) if info[9] != '' else None, - ailment_chance = int(info[10]) if info[10] != '' else None, - flinch_chance = int(info[11]) if info[11] != '' else None, - stat_chance = int(info[12]) if info[12] != '' else None + move_id=int(info[0]), + move_meta_category_id=int(info[1]), + move_meta_ailment_id=int(info[2]), + min_hits=int(info[3]) if info[3] != "" else None, + max_hits=int(info[4]) if info[4] != "" else None, + min_turns=int(info[5]) if info[5] != "" else None, + max_turns=int(info[6]) if info[6] != "" else None, + drain=int(info[7]) if info[7] != "" else None, + healing=int(info[8]) if info[8] != "" else None, + crit_rate=int(info[9]) if info[9] != "" else None, + ailment_chance=int(info[10]) if info[10] != "" else None, + flinch_chance=int(info[11]) if info[11] != "" else None, + stat_chance=int(info[12]) if info[12] != "" else None, ) - build_generic((MoveMeta,), 'move_meta.csv', csv_record_to_objects) + + build_generic((MoveMeta,), "move_meta.csv", csv_record_to_objects) def csv_record_to_objects(info): yield MoveMetaStatChange( - move_id = int(info[0]), - stat_id = int(info[1]), - change = int(info[2]) + move_id=int(info[0]), stat_id=int(info[1]), change=int(info[2]) ) - build_generic((MoveMetaStatChange,), 'move_meta_stat_changes.csv', csv_record_to_objects) + + build_generic( + (MoveMetaStatChange,), "move_meta_stat_changes.csv", csv_record_to_objects + ) def csv_record_to_objects(info): - yield ContestCombo( - first_move_id = int(info[0]), - second_move_id = int(info[1]) - ) - build_generic((ContestCombo,), 'contest_combos.csv', csv_record_to_objects) + yield ContestCombo(first_move_id=int(info[0]), second_move_id=int(info[1])) + + build_generic((ContestCombo,), "contest_combos.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield SuperContestCombo( - first_move_id = int(info[0]), - second_move_id = int(info[1]) - ) - build_generic((SuperContestCombo,), 'super_contest_combos.csv', csv_record_to_objects) + yield SuperContestCombo(first_move_id=int(info[0]), second_move_id=int(info[1])) + build_generic( + (SuperContestCombo,), "super_contest_combos.csv", csv_record_to_objects + ) ############# # BERRIES # ############# -def _build_berries(): +def _build_berries(): def csv_record_to_objects(info): - yield BerryFirmness( - id = int(info[0]), - name = info[1] - ) - build_generic((BerryFirmness,), 'berry_firmness.csv', csv_record_to_objects) + yield BerryFirmness(id=int(info[0]), name=info[1]) + + build_generic((BerryFirmness,), "berry_firmness.csv", csv_record_to_objects) def csv_record_to_objects(info): yield BerryFirmnessName( - berry_firmness_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + berry_firmness_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((BerryFirmnessName,), 'berry_firmness_names.csv', csv_record_to_objects) + + build_generic( + (BerryFirmnessName,), "berry_firmness_names.csv", csv_record_to_objects + ) def csv_record_to_objects(info): - item = Item.objects.get(pk = int(info[1])) + item = Item.objects.get(pk=int(info[1])) yield Berry( - id = int(info[0]), - item_id = int(info[1]), - name = item.name[:item.name.index('-')], - berry_firmness_id = int(info[2]), - natural_gift_power = int(info[3]), - natural_gift_type_id = int(info[4]), - size = int(info[5]), - max_harvest = int(info[6]), - growth_time = int(info[7]), - soil_dryness = int(info[8]), - smoothness = int(info[9]) + id=int(info[0]), + item_id=int(info[1]), + name=item.name[: item.name.index("-")], + berry_firmness_id=int(info[2]), + natural_gift_power=int(info[3]), + natural_gift_type_id=int(info[4]), + size=int(info[5]), + max_harvest=int(info[6]), + growth_time=int(info[7]), + soil_dryness=int(info[8]), + smoothness=int(info[9]), ) - build_generic((Berry,), 'berries.csv', csv_record_to_objects) + + build_generic((Berry,), "berries.csv", csv_record_to_objects) def csv_record_to_objects(info): # Get the english name for this contest type - contest_type_name = ContestTypeName.objects.get(contest_type_id=int(info[0]), language_id=9) - yield BerryFlavor( - id = int(info[0]), - name = contest_type_name.flavor.lower(), - contest_type = ContestType.objects.get(pk = int(info[0])) + contest_type_name = ContestTypeName.objects.get( + contest_type_id=int(info[0]), language_id=9 ) + yield BerryFlavor( + id=int(info[0]), + name=contest_type_name.flavor.lower(), + contest_type=ContestType.objects.get(pk=int(info[0])), + ) + # This is not an error - build_generic((BerryFlavor,), 'contest_types.csv', csv_record_to_objects) + build_generic((BerryFlavor,), "contest_types.csv", csv_record_to_objects) def csv_record_to_objects(info): yield BerryFlavorName( - berry_flavor_id = int(info[0]), - language_id = int(info[1]), - name = info[3] + berry_flavor_id=int(info[0]), language_id=int(info[1]), name=info[3] ) + # This is not an error - build_generic((BerryFlavorName,), 'contest_type_names.csv', csv_record_to_objects) + build_generic((BerryFlavorName,), "contest_type_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield BerryFlavorMap( - berry_id = int(info[0]), - berry_flavor_id = int(info[1]), - potency = int(info[2]) + berry_id=int(info[0]), berry_flavor_id=int(info[1]), potency=int(info[2]) ) - # This is not an error - build_generic((BerryFlavorMap,), 'berry_flavors.csv', csv_record_to_objects) + # This is not an error + build_generic((BerryFlavorMap,), "berry_flavors.csv", csv_record_to_objects) ############ # NATURE # ############ -def _build_natures(): +def _build_natures(): def csv_record_to_objects(info): decreased_stat = None increased_stat = None hates_flavor = None likes_flavor = None - if (info[2] != info[3]): - decreased_stat = Stat.objects.get(pk = int(info[2])) - increased_stat = Stat.objects.get(pk = int(info[3])) + if info[2] != info[3]: + decreased_stat = Stat.objects.get(pk=int(info[2])) + increased_stat = Stat.objects.get(pk=int(info[3])) - if (info[4] != info[5]): - hates_flavor = BerryFlavor.objects.get(pk = int(info[4])) - likes_flavor = BerryFlavor.objects.get(pk = int(info[5])) + if info[4] != info[5]: + hates_flavor = BerryFlavor.objects.get(pk=int(info[4])) + likes_flavor = BerryFlavor.objects.get(pk=int(info[5])) yield Nature( - id = int(info[0]), - name = info[1], - decreased_stat = decreased_stat, - increased_stat = increased_stat, - hates_flavor = hates_flavor, - likes_flavor = likes_flavor, - game_index = info[6] + id=int(info[0]), + name=info[1], + decreased_stat=decreased_stat, + increased_stat=increased_stat, + hates_flavor=hates_flavor, + likes_flavor=likes_flavor, + game_index=info[6], ) - build_generic((Nature,), 'natures.csv', csv_record_to_objects) + + build_generic((Nature,), "natures.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield NatureName( - nature_id = int(info[0]), - language_id = int(info[1]), - name = info[2] - ) - build_generic((NatureName,), 'nature_names.csv', csv_record_to_objects) + yield NatureName(nature_id=int(info[0]), language_id=int(info[1]), name=info[2]) + + build_generic((NatureName,), "nature_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield NaturePokeathlonStat( - nature_id = (info[0]), - pokeathlon_stat_id = (info[1]), - max_change = info[2] + nature_id=(info[0]), pokeathlon_stat_id=(info[1]), max_change=info[2] ) - build_generic((NaturePokeathlonStat,), 'nature_pokeathlon_stats.csv', csv_record_to_objects) + + build_generic( + (NaturePokeathlonStat,), "nature_pokeathlon_stats.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield NatureBattleStylePreference( - nature_id = int(info[0]), - move_battle_style_id = int(info[1]), - low_hp_preference = info[2], - high_hp_preference = info[3] + nature_id=int(info[0]), + move_battle_style_id=int(info[1]), + low_hp_preference=info[2], + high_hp_preference=info[3], ) - build_generic( - (NatureBattleStylePreference,), 'nature_battle_style_preferences.csv', csv_record_to_objects - ) + build_generic( + (NatureBattleStylePreference,), + "nature_battle_style_preferences.csv", + csv_record_to_objects, + ) ########### # GENDER # ########### + def _build_genders(): - def csv_record_to_objects(info): - yield Gender( - id = int(info[0]), - name = info[1] - ) - build_generic((Gender,), 'genders.csv', csv_record_to_objects) + yield Gender(id=int(info[0]), name=info[1]) + build_generic((Gender,), "genders.csv", csv_record_to_objects) ################ # EXPERIENCE # ################ -def _build_experiences(): +def _build_experiences(): def csv_record_to_objects(info): yield Experience( - growth_rate_id = int(info[0]), - level = int(info[1]), - experience = int(info[2]) + growth_rate_id=int(info[0]), level=int(info[1]), experience=int(info[2]) ) - build_generic((Experience,), 'experience.csv', csv_record_to_objects) + build_generic((Experience,), "experience.csv", csv_record_to_objects) ############## # MACHINES # ############## -def _build_machines(): +def _build_machines(): def csv_record_to_objects(info): yield Machine( - machine_number = int(info[0]), - version_group_id = int(info[1]), - item_id = int(info[2]), - move_id = int(info[3]), + machine_number=int(info[0]), + version_group_id=int(info[1]), + item_id=int(info[2]), + move_id=int(info[3]), ) - build_generic((Machine,), 'machines.csv', csv_record_to_objects) + build_generic((Machine,), "machines.csv", csv_record_to_objects) ############### # EVOLUTION # ############### -def _build_evolutions(): +def _build_evolutions(): def csv_record_to_objects(info): yield EvolutionChain( - id = int(info[0]), - baby_trigger_item_id = int(info[1]) if info[1] != '' else None, + id=int(info[0]), + baby_trigger_item_id=int(info[1]) if info[1] != "" else None, ) - build_generic((EvolutionChain,), 'evolution_chains.csv', csv_record_to_objects) + + build_generic((EvolutionChain,), "evolution_chains.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield EvolutionTrigger( - id = int(info[0]), - name = info[1] - ) - build_generic((EvolutionTrigger,), 'evolution_triggers.csv', csv_record_to_objects) + yield EvolutionTrigger(id=int(info[0]), name=info[1]) + + build_generic((EvolutionTrigger,), "evolution_triggers.csv", csv_record_to_objects) def csv_record_to_objects(info): yield EvolutionTriggerName( - evolution_trigger_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + evolution_trigger_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((EvolutionTriggerName,), 'evolution_trigger_prose.csv', csv_record_to_objects) + build_generic( + (EvolutionTriggerName,), "evolution_trigger_prose.csv", csv_record_to_objects + ) ############# # POKEDEX # ############# -def _build_pokedexes(): +def _build_pokedexes(): def csv_record_to_objects(info): yield Pokedex( - id = int(info[0]), - region_id = int(info[1]) if info[1] != '' else None, - name = info[2], - is_main_series = bool(int(info[3])) + id=int(info[0]), + region_id=int(info[1]) if info[1] != "" else None, + name=info[2], + is_main_series=bool(int(info[3])), ) - build_generic((Pokedex,), 'pokedexes.csv', csv_record_to_objects) + + build_generic((Pokedex,), "pokedexes.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokedexName( - pokedex_id = int(info[0]), - language_id = int(info[1]), - name = info[2], + pokedex_id=int(info[0]), language_id=int(info[1]), name=info[2] ) yield PokedexDescription( - pokedex_id = int(info[0]), - language_id = int(info[1]), - description = info[3] + pokedex_id=int(info[0]), language_id=int(info[1]), description=info[3] ) - build_generic((PokedexName, PokedexDescription), 'pokedex_prose.csv', csv_record_to_objects) + + build_generic( + (PokedexName, PokedexDescription), "pokedex_prose.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield PokedexVersionGroup( - pokedex_id = int(info[0]), - version_group_id = int(info[1]) + pokedex_id=int(info[0]), version_group_id=int(info[1]) ) - build_generic((PokedexVersionGroup,), 'pokedex_version_groups.csv', csv_record_to_objects) + build_generic( + (PokedexVersionGroup,), "pokedex_version_groups.csv", csv_record_to_objects + ) ############## # LOCATION # ############## -def _build_locations(): +def _build_locations(): def csv_record_to_objects(info): yield Location( - id = int(info[0]), - region_id = int(info[1]) if info[1] != '' else None, - name = info[2] + id=int(info[0]), + region_id=int(info[1]) if info[1] != "" else None, + name=info[2], ) - build_generic((Location,), 'locations.csv', csv_record_to_objects) + + build_generic((Location,), "locations.csv", csv_record_to_objects) def csv_record_to_objects(info): yield LocationName( - location_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + location_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((LocationName,), 'location_names.csv', csv_record_to_objects) + + build_generic((LocationName,), "location_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield LocationGameIndex( - location_id = int(info[0]), - generation_id = int(info[1]), - game_index = int(info[2]) + location_id=int(info[0]), + generation_id=int(info[1]), + game_index=int(info[2]), ) - build_generic((LocationGameIndex,), 'location_game_indices.csv', csv_record_to_objects) + + build_generic( + (LocationGameIndex,), "location_game_indices.csv", csv_record_to_objects + ) def csv_record_to_objects(info): - location = Location.objects.get(pk = int(info[1])) + location = Location.objects.get(pk=int(info[1])) yield LocationArea( - id = int(info[0]), - location_id = int(info[1]), - game_index = int(info[2]), - name = '{}-{}'.format( - location.name, info[3] - ) if info[3] else '{}-{}'.format(location.name, 'area') + id=int(info[0]), + location_id=int(info[1]), + game_index=int(info[2]), + name="{}-{}".format(location.name, info[3]) + if info[3] + else "{}-{}".format(location.name, "area"), ) - build_generic((LocationArea,), 'location_areas.csv', csv_record_to_objects) + + build_generic((LocationArea,), "location_areas.csv", csv_record_to_objects) def csv_record_to_objects(info): yield LocationAreaName( - location_area_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + location_area_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((LocationAreaName,), 'location_area_prose.csv', csv_record_to_objects) + build_generic((LocationAreaName,), "location_area_prose.csv", csv_record_to_objects) ############# # POKEMON # ############# -def _build_pokemons(): +def _build_pokemons(): def csv_record_to_objects(info): - yield PokemonColor( - id = int(info[0]), - name = info[1] - ) - build_generic((PokemonColor,), 'pokemon_colors.csv', csv_record_to_objects) + yield PokemonColor(id=int(info[0]), name=info[1]) + + build_generic((PokemonColor,), "pokemon_colors.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonColorName( - pokemon_color_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + pokemon_color_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((PokemonColorName,), 'pokemon_color_names.csv', csv_record_to_objects) + + build_generic((PokemonColorName,), "pokemon_color_names.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield PokemonShape( - id = int(info[0]), - name = info[1] - ) - build_generic((PokemonShape,), 'pokemon_shapes.csv', csv_record_to_objects) + yield PokemonShape(id=int(info[0]), name=info[1]) + + build_generic((PokemonShape,), "pokemon_shapes.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonShapeName( - pokemon_shape_id = int(info[0]), - language_id = int(info[1]), - name = info[2], - awesome_name = info[3] + pokemon_shape_id=int(info[0]), + language_id=int(info[1]), + name=info[2], + awesome_name=info[3], ) - build_generic((PokemonShapeName,), 'pokemon_shape_prose.csv', csv_record_to_objects) + + build_generic((PokemonShapeName,), "pokemon_shape_prose.csv", csv_record_to_objects) def csv_record_to_objects(info): - yield PokemonHabitat( - id = int(info[0]), - name = info[1] - ) - build_generic((PokemonHabitat,), 'pokemon_habitats.csv', csv_record_to_objects) + yield PokemonHabitat(id=int(info[0]), name=info[1]) + + build_generic((PokemonHabitat,), "pokemon_habitats.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonSpecies( - id = int(info[0]), - name = info[1], - generation_id = int(info[2]), - evolves_from_species = None, - evolution_chain_id = int(info[4]), - pokemon_color_id = int(info[5]), - pokemon_shape_id = int(info[6]), - pokemon_habitat_id = int(info[7]) if info[7] != '' else None, - gender_rate = int(info[8]), - capture_rate = int(info[9]), - base_happiness = int(info[10]), - is_baby = bool(int(info[11])), - hatch_counter = int(info[12]), - has_gender_differences = bool(int(info[13])), - growth_rate_id = int(info[14]), - forms_switchable = bool(int(info[15])), - order = int(info[16]) + id=int(info[0]), + name=info[1], + generation_id=int(info[2]), + evolves_from_species=None, + evolution_chain_id=int(info[4]), + pokemon_color_id=int(info[5]), + pokemon_shape_id=int(info[6]), + pokemon_habitat_id=int(info[7]) if info[7] != "" else None, + gender_rate=int(info[8]), + capture_rate=int(info[9]), + base_happiness=int(info[10]), + is_baby=bool(int(info[11])), + hatch_counter=int(info[12]), + has_gender_differences=bool(int(info[13])), + growth_rate_id=int(info[14]), + forms_switchable=bool(int(info[15])), + order=int(info[16]), ) - build_generic((PokemonSpecies,), 'pokemon_species.csv', csv_record_to_objects) + + build_generic((PokemonSpecies,), "pokemon_species.csv", csv_record_to_objects) # PokemonSpecies.evolves_from_species can't be set until all the species are created - data = load_data('pokemon_species.csv') + data = load_data("pokemon_species.csv") for index, info in enumerate(data): if index > 0: - evolves = PokemonSpecies.objects.get(pk = int(info[3])) if info[3] != '' else None + evolves = ( + PokemonSpecies.objects.get(pk=int(info[3])) if info[3] != "" else None + ) if evolves: - species = PokemonSpecies.objects.get(pk = int(info[0])) + species = PokemonSpecies.objects.get(pk=int(info[0])) species.evolves_from_species = evolves species.save() def csv_record_to_objects(info): yield PokemonSpeciesName( - pokemon_species_id = int(info[0]), - language_id = int(info[1]), - name = info[2], - genus = info[3] + pokemon_species_id=int(info[0]), + language_id=int(info[1]), + name=info[2], + genus=info[3], ) - build_generic((PokemonSpeciesName,), 'pokemon_species_names.csv', csv_record_to_objects) + + build_generic( + (PokemonSpeciesName,), "pokemon_species_names.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield PokemonSpeciesDescription( - pokemon_species_id = int(info[0]), - language_id = int(info[1]), - description = scrubStr(info[2]) + pokemon_species_id=int(info[0]), + language_id=int(info[1]), + description=scrub_str(info[2]), ) - build_generic((PokemonSpeciesDescription,), 'pokemon_species_prose.csv', csv_record_to_objects) + + build_generic( + (PokemonSpeciesDescription,), "pokemon_species_prose.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield PokemonSpeciesFlavorText( - pokemon_species_id = int(info[0]), - version_id = int(info[1]), - language_id = int(info[2]), - flavor_text = info[3] + pokemon_species_id=int(info[0]), + version_id=int(info[1]), + language_id=int(info[2]), + flavor_text=info[3], ) + build_generic( - (PokemonSpeciesFlavorText,), 'pokemon_species_flavor_text.csv', csv_record_to_objects + (PokemonSpeciesFlavorText,), + "pokemon_species_flavor_text.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield Pokemon( - id = int(info[0]), - name = info[1], - pokemon_species_id = int(info[2]), - height = int(info[3]), - weight = int(info[4]), - base_experience = int(info[5]), - order = int(info[6]), - is_default = bool(int(info[7])) + id=int(info[0]), + name=info[1], + pokemon_species_id=int(info[2]), + height=int(info[3]), + weight=int(info[4]), + base_experience=int(info[5]), + order=int(info[6]), + is_default=bool(int(info[7])), ) - build_generic((Pokemon,), 'pokemon.csv', csv_record_to_objects) + + build_generic((Pokemon,), "pokemon.csv", csv_record_to_objects) def csv_record_to_objects(info): - fileName = '%s.png' % info[0] - pokeSprites = 'pokemon/{0}'; + file_name = "%s.png" % info[0] + poke_sprites = "pokemon/{0}" sprites = { - 'front_default' : filePathOrNone(pokeSprites.format(fileName)), - 'front_female' : filePathOrNone(pokeSprites.format('female/'+fileName)), - 'front_shiny' : filePathOrNone(pokeSprites.format('shiny/'+fileName)), - 'front_shiny_female' : filePathOrNone(pokeSprites.format('shiny/female/'+fileName)), - 'back_default' : filePathOrNone(pokeSprites.format('back/'+fileName)), - 'back_female' : filePathOrNone(pokeSprites.format('back/female/'+fileName)), - 'back_shiny' : filePathOrNone(pokeSprites.format('back/shiny/'+fileName)), - 'back_shiny_female' : filePathOrNone(pokeSprites.format('back/shiny/female/'+fileName)), + "front_default": file_path_or_none(poke_sprites.format(file_name)), + "front_female": file_path_or_none( + poke_sprites.format("female/" + file_name) + ), + "front_shiny": file_path_or_none(poke_sprites.format("shiny/" + file_name)), + "front_shiny_female": file_path_or_none( + poke_sprites.format("shiny/female/" + file_name) + ), + "back_default": file_path_or_none(poke_sprites.format("back/" + file_name)), + "back_female": file_path_or_none( + poke_sprites.format("back/female/" + file_name) + ), + "back_shiny": file_path_or_none( + poke_sprites.format("back/shiny/" + file_name) + ), + "back_shiny_female": file_path_or_none( + poke_sprites.format("back/shiny/female/" + file_name) + ), } yield PokemonSprites( - id = int(info[0]), - pokemon = Pokemon.objects.get(pk=int(info[0])), - sprites = json.dumps(sprites) + id=int(info[0]), + pokemon=Pokemon.objects.get(pk=int(info[0])), + sprites=json.dumps(sprites), ) - build_generic((PokemonSprites,), 'pokemon.csv', csv_record_to_objects) + + build_generic((PokemonSprites,), "pokemon.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonAbility( - pokemon_id = int(info[0]), - ability_id = int(info[1]), - is_hidden = bool(int(info[2])), - slot = int(info[3]) + pokemon_id=int(info[0]), + ability_id=int(info[1]), + is_hidden=bool(int(info[2])), + slot=int(info[3]), ) - build_generic((PokemonAbility,), 'pokemon_abilities.csv', csv_record_to_objects) + + build_generic((PokemonAbility,), "pokemon_abilities.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonDexNumber( - pokemon_species_id = int(info[0]), - pokedex_id = int(info[1]), - pokedex_number = int(info[2]) + pokemon_species_id=int(info[0]), + pokedex_id=int(info[1]), + pokedex_number=int(info[2]), ) - build_generic((PokemonDexNumber,), 'pokemon_dex_numbers.csv', csv_record_to_objects) + + build_generic((PokemonDexNumber,), "pokemon_dex_numbers.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonEggGroup( - pokemon_species_id = int(info[0]), - egg_group_id = int(info[1]) + pokemon_species_id=int(info[0]), egg_group_id=int(info[1]) ) - build_generic((PokemonEggGroup,), 'pokemon_egg_groups.csv', csv_record_to_objects) + + build_generic((PokemonEggGroup,), "pokemon_egg_groups.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonEvolution( - id = int(info[0]), - evolved_species_id = int(info[1]), - evolution_trigger_id = int(info[2]), - evolution_item_id = int(info[3]) if info[3] != '' else None, - min_level = int(info[4]) if info[4] != '' else None, - gender_id = int(info[5]) if info[5] != '' else None, - location_id = int(info[6]) if info[6] != '' else None, - held_item_id = int(info[7]) if info[7] != '' else None, - time_of_day = info[8], - known_move_id = int(info[9]) if info[9] != '' else None, - known_move_type_id = int(info[10]) if info[10] != '' else None, - min_happiness = int(info[11]) if info[11] != '' else None, - min_beauty = int(info[12]) if info[12] != '' else None, - min_affection = int(info[13]) if info[13] != '' else None, - relative_physical_stats = int(info[14]) if info[14] != '' else None, - party_species_id = int(info[15]) if info[15] != '' else None, - party_type_id = int(info[16]) if info[16] != '' else None, - trade_species_id = int(info[17]) if info[17] != '' else None, - needs_overworld_rain = bool(int(info[18])), - turn_upside_down = bool(int(info[19])) + id=int(info[0]), + evolved_species_id=int(info[1]), + evolution_trigger_id=int(info[2]), + evolution_item_id=int(info[3]) if info[3] != "" else None, + min_level=int(info[4]) if info[4] != "" else None, + gender_id=int(info[5]) if info[5] != "" else None, + location_id=int(info[6]) if info[6] != "" else None, + held_item_id=int(info[7]) if info[7] != "" else None, + time_of_day=info[8], + known_move_id=int(info[9]) if info[9] != "" else None, + known_move_type_id=int(info[10]) if info[10] != "" else None, + min_happiness=int(info[11]) if info[11] != "" else None, + min_beauty=int(info[12]) if info[12] != "" else None, + min_affection=int(info[13]) if info[13] != "" else None, + relative_physical_stats=int(info[14]) if info[14] != "" else None, + party_species_id=int(info[15]) if info[15] != "" else None, + party_type_id=int(info[16]) if info[16] != "" else None, + trade_species_id=int(info[17]) if info[17] != "" else None, + needs_overworld_rain=bool(int(info[18])), + turn_upside_down=bool(int(info[19])), ) - build_generic((PokemonEvolution,), 'pokemon_evolution.csv', csv_record_to_objects) + + build_generic((PokemonEvolution,), "pokemon_evolution.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonForm( - id = int(info[0]), - name = info[1], - form_name = info[2], - pokemon_id = int(info[3]), - version_group_id = int(info[4]), - is_default = bool(int(info[5])), - is_battle_only = bool(int(info[6])), - is_mega = bool(int(info[7])), - form_order = int(info[8]), - order = int(info[9]) + id=int(info[0]), + name=info[1], + form_name=info[2], + pokemon_id=int(info[3]), + version_group_id=int(info[4]), + is_default=bool(int(info[5])), + is_battle_only=bool(int(info[6])), + is_mega=bool(int(info[7])), + form_order=int(info[8]), + order=int(info[9]), ) - build_generic((PokemonForm,), 'pokemon_forms.csv', csv_record_to_objects) + + build_generic((PokemonForm,), "pokemon_forms.csv", csv_record_to_objects) def csv_record_to_objects(info): - pokemon = Pokemon.objects.get(pk = int(info[3])) + pokemon = Pokemon.objects.get(pk=int(info[3])) if info[2]: if re.search(r"^mega", info[2]): - fileName = '%s.png' % info[3] + file_name = "%s.png" % info[3] else: - fileName = '%s-%s.png' % (getattr(pokemon, 'pokemon_species_id'), info[2]) + file_name = "%s-%s.png" % ( + getattr(pokemon, "pokemon_species_id"), + info[2], + ) else: - fileName = '%s.png' % getattr(pokemon, 'pokemon_species_id') - pokeSprites = 'pokemon/{0}' + file_name = "%s.png" % getattr(pokemon, "pokemon_species_id") + poke_sprites = "pokemon/{0}" sprites = { - 'front_default' : filePathOrNone(pokeSprites.format(fileName)), - 'front_shiny' : filePathOrNone(pokeSprites.format('shiny/'+fileName)), - 'back_default' : filePathOrNone(pokeSprites.format('back/'+fileName)), - 'back_shiny' : filePathOrNone(pokeSprites.format('back/shiny/'+fileName)), + "front_default": file_path_or_none(poke_sprites.format(file_name)), + "front_shiny": file_path_or_none(poke_sprites.format("shiny/" + file_name)), + "back_default": file_path_or_none(poke_sprites.format("back/" + file_name)), + "back_shiny": file_path_or_none( + poke_sprites.format("back/shiny/" + file_name) + ), } yield PokemonFormSprites( - id = int(info[0]), - pokemon_form_id = int(info[0]), - sprites = json.dumps(sprites) + id=int(info[0]), pokemon_form_id=int(info[0]), sprites=json.dumps(sprites) ) - build_generic((PokemonFormSprites,), 'pokemon_forms.csv', csv_record_to_objects) + + build_generic((PokemonFormSprites,), "pokemon_forms.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonFormName( - pokemon_form = PokemonForm.objects.get(pk = int(info[0])), - language = Language.objects.get(pk = int(info[1])), - name = info[2], - pokemon_name = info[3] + pokemon_form=PokemonForm.objects.get(pk=int(info[0])), + language=Language.objects.get(pk=int(info[1])), + name=info[2], + pokemon_name=info[3], ) - build_generic((PokemonFormName,), 'pokemon_form_names.csv', csv_record_to_objects) + + build_generic((PokemonFormName,), "pokemon_form_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonFormGeneration( - pokemon_form_id = int(info[0]), - generation_id = int(info[1]), - game_index = int(info[2]) + pokemon_form_id=int(info[0]), + generation_id=int(info[1]), + game_index=int(info[2]), ) - build_generic((PokemonFormGeneration,), 'pokemon_form_generations.csv', csv_record_to_objects) + + build_generic( + (PokemonFormGeneration,), "pokemon_form_generations.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield PokemonGameIndex( - pokemon_id = int(info[0]), - version_id = int(info[1]), - game_index = int(info[2]) + pokemon_id=int(info[0]), version_id=int(info[1]), game_index=int(info[2]) ) - build_generic((PokemonGameIndex,), 'pokemon_game_indices.csv', csv_record_to_objects) + + build_generic( + (PokemonGameIndex,), "pokemon_game_indices.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield PokemonHabitatName( - pokemon_habitat_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + pokemon_habitat_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((PokemonHabitatName,), 'pokemon_habitat_names.csv', csv_record_to_objects) + + build_generic( + (PokemonHabitatName,), "pokemon_habitat_names.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield PokemonItem( - pokemon_id = int(info[0]), - version_id = int(info[1]), - item_id = int(info[2]), - rarity = int(info[3]) + pokemon_id=int(info[0]), + version_id=int(info[1]), + item_id=int(info[2]), + rarity=int(info[3]), ) - build_generic((PokemonItem,), 'pokemon_items.csv', csv_record_to_objects) + + build_generic((PokemonItem,), "pokemon_items.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonMove( - pokemon_id = int(info[0]), - version_group_id = int(info[1]), - move_id = int(info[2]), - move_learn_method_id = int(info[3]), - level = int(info[4]), - order = int(info[5]) if info[5] != '' else None, + pokemon_id=int(info[0]), + version_group_id=int(info[1]), + move_id=int(info[2]), + move_learn_method_id=int(info[3]), + level=int(info[4]), + order=int(info[5]) if info[5] != "" else None, ) - build_generic((PokemonMove,), 'pokemon_moves.csv', csv_record_to_objects) + + build_generic((PokemonMove,), "pokemon_moves.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonStat( - pokemon_id = int(info[0]), - stat_id = int(info[1]), - base_stat = int(info[2]), - effort = int(info[3]) + pokemon_id=int(info[0]), + stat_id=int(info[1]), + base_stat=int(info[2]), + effort=int(info[3]), ) - build_generic((PokemonStat,), 'pokemon_stats.csv', csv_record_to_objects) + + build_generic((PokemonStat,), "pokemon_stats.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PokemonType( - pokemon_id = int(info[0]), - type_id = int(info[1]), - slot = int(info[2]) + pokemon_id=int(info[0]), type_id=int(info[1]), slot=int(info[2]) ) - build_generic((PokemonType,), 'pokemon_types.csv', csv_record_to_objects) + build_generic((PokemonType,), "pokemon_types.csv", csv_record_to_objects) ############### # ENCOUNTER # ############### -def _build_encounters(): +def _build_encounters(): def csv_record_to_objects(info): - yield EncounterMethod( - id = int(info[0]), - name = info[1], - order = int(info[2]) - ) - build_generic((EncounterMethod,), 'encounter_methods.csv', csv_record_to_objects) + yield EncounterMethod(id=int(info[0]), name=info[1], order=int(info[2])) + + build_generic((EncounterMethod,), "encounter_methods.csv", csv_record_to_objects) def csv_record_to_objects(info): yield LocationAreaEncounterRate( - location_area_id = int(info[0]), - encounter_method_id = int(info[1]), - version_id = int(info[2]), - rate = int(info[3]) + location_area_id=int(info[0]), + encounter_method_id=int(info[1]), + version_id=int(info[2]), + rate=int(info[3]), ) + build_generic( - (LocationAreaEncounterRate,), 'location_area_encounter_rates.csv', csv_record_to_objects + (LocationAreaEncounterRate,), + "location_area_encounter_rates.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield EncounterMethodName( - encounter_method_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + encounter_method_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((EncounterMethodName,), 'encounter_method_prose.csv', csv_record_to_objects) + + build_generic( + (EncounterMethodName,), "encounter_method_prose.csv", csv_record_to_objects + ) def csv_record_to_objects(info): - yield EncounterCondition( - id = int(info[0]), - name = info[1] - ) - build_generic((EncounterCondition,), 'encounter_conditions.csv', csv_record_to_objects) + yield EncounterCondition(id=int(info[0]), name=info[1]) + + build_generic( + (EncounterCondition,), "encounter_conditions.csv", csv_record_to_objects + ) def csv_record_to_objects(info): yield EncounterConditionName( - encounter_condition_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + encounter_condition_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((EncounterConditionName,), 'encounter_condition_prose.csv', csv_record_to_objects) + + build_generic( + (EncounterConditionName,), + "encounter_condition_prose.csv", + csv_record_to_objects, + ) def csv_record_to_objects(info): yield EncounterSlot( - id = int(info[0]), - version_group_id = int(info[1]), - encounter_method_id = int(info[2]), - slot = int(info[3]) if info[3] != '' else None, - rarity = int(info[4]) + id=int(info[0]), + version_group_id=int(info[1]), + encounter_method_id=int(info[2]), + slot=int(info[3]) if info[3] != "" else None, + rarity=int(info[4]), ) - build_generic((EncounterSlot,), 'encounter_slots.csv', csv_record_to_objects) + + build_generic((EncounterSlot,), "encounter_slots.csv", csv_record_to_objects) def csv_record_to_objects(info): yield Encounter( - id = int(info[0]), - version_id = int(info[1]), - location_area_id = int(info[2]), - encounter_slot_id = int(info[3]), - pokemon_id = int(info[4]), - min_level = int(info[5]), - max_level = int(info[6]) + id=int(info[0]), + version_id=int(info[1]), + location_area_id=int(info[2]), + encounter_slot_id=int(info[3]), + pokemon_id=int(info[4]), + min_level=int(info[5]), + max_level=int(info[6]), ) - build_generic((Encounter,), 'encounters.csv', csv_record_to_objects) + + build_generic((Encounter,), "encounters.csv", csv_record_to_objects) def csv_record_to_objects(info): yield EncounterConditionValue( - id = int(info[0]), - encounter_condition_id = int(info[1]), - name = info[2], - is_default = bool(int(info[3])) + id=int(info[0]), + encounter_condition_id=int(info[1]), + name=info[2], + is_default=bool(int(info[3])), ) + build_generic( - (EncounterConditionValue,), 'encounter_condition_values.csv', csv_record_to_objects + (EncounterConditionValue,), + "encounter_condition_values.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield EncounterConditionValueName( - encounter_condition_value_id = int(info[0]), - language_id = int(info[1]), - name = info[2], + encounter_condition_value_id=int(info[0]), + language_id=int(info[1]), + name=info[2], ) + build_generic( - (EncounterConditionValueName,), 'encounter_condition_value_prose.csv', csv_record_to_objects + (EncounterConditionValueName,), + "encounter_condition_value_prose.csv", + csv_record_to_objects, ) def csv_record_to_objects(info): yield EncounterConditionValueMap( - encounter_id = int(info[0]), - encounter_condition_value_id = int(info[1]) + encounter_id=int(info[0]), encounter_condition_value_id=int(info[1]) ) - build_generic( - (EncounterConditionValueMap,), 'encounter_condition_value_map.csv', csv_record_to_objects - ) + build_generic( + (EncounterConditionValueMap,), + "encounter_condition_value_map.csv", + csv_record_to_objects, + ) ############## # PAL PARK # ############## -def _build_pal_parks(): +def _build_pal_parks(): def csv_record_to_objects(info): - yield PalParkArea( - id = int(info[0]), - name = info[1] - ) - build_generic((PalParkArea,), 'pal_park_areas.csv', csv_record_to_objects) + yield PalParkArea(id=int(info[0]), name=info[1]) + + build_generic((PalParkArea,), "pal_park_areas.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PalParkAreaName( - pal_park_area_id = int(info[0]), - language_id = int(info[1]), - name = info[2] + pal_park_area_id=int(info[0]), language_id=int(info[1]), name=info[2] ) - build_generic((PalParkAreaName,), 'pal_park_area_names.csv', csv_record_to_objects) + + build_generic((PalParkAreaName,), "pal_park_area_names.csv", csv_record_to_objects) def csv_record_to_objects(info): yield PalPark( - pokemon_species_id = int(info[0]), - pal_park_area_id = int(info[1]), - base_score = int(info[2]), - rate = int(info[3]) + pokemon_species_id=int(info[0]), + pal_park_area_id=int(info[1]), + base_score=int(info[2]), + rate=int(info[3]), ) - build_generic((PalPark,), 'pal_park.csv', csv_record_to_objects) + + build_generic((PalPark,), "pal_park.csv", csv_record_to_objects) def build_all(): @@ -1713,5 +1718,6 @@ def build_all(): _build_encounters() _build_pal_parks() -if __name__ == '__main__': + +if __name__ == "__main__": build_all() diff --git a/pokemon_v2/api.py b/pokemon_v2/api.py index e63727b5..46c5bc11 100644 --- a/pokemon_v2/api.py +++ b/pokemon_v2/api.py @@ -1,13 +1,14 @@ +import re from rest_framework import viewsets from rest_framework.response import Response from rest_framework.views import APIView from django.shortcuts import get_object_or_404 from django.http import Http404 -import re -from .models import * # NOQA -from .serializers import * # NOQA +from .models import * +from .serializers import * +# pylint: disable=no-member, attribute-defined-outside-init ########################### # BEHAVIOR ABSTRACTIONS # @@ -33,8 +34,8 @@ class NameOrIdRetrieval(): pk (in this case ID) or by name """ - idPattern = re.compile("^-?[0-9]+$") - namePattern = re.compile("^[0-9A-Za-z\-\+]+$") + idPattern = re.compile(r"^-?[0-9]+$") + namePattern = re.compile(r"^[0-9A-Za-z\-\+]+$") def get_object(self): queryset = self.get_queryset() diff --git a/pokemon_v2/models.py b/pokemon_v2/models.py index 1a86f8c2..9496b151 100755 --- a/pokemon_v2/models.py +++ b/pokemon_v2/models.py @@ -782,13 +782,12 @@ class Berry(HasName, HasItem): smoothness = models.IntegerField() -""" -Berry Flavors are a bit of a hack because their relationship -in terms of flavors to contest types is really awkward the -way it was handled in the veekun data set. Berry Flavor here -does not match the csv table. Berry Flavor Map -is a table fabricated just to suit this project. -""" + +# Berry Flavors are a bit of a hack because their relationship +# in terms of flavors to contest types is really awkward the +# way it was handled in the veekun data set. Berry Flavor here +# does not match the csv table. Berry Flavor Map +# is a table fabricated just to suit this project. class BerryFlavor(HasName): diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index 01f2e2ca..64cb9313 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -1,13 +1,13 @@ -from django.urls import reverse -from rest_framework import serializers from collections import OrderedDict import json +from django.urls import reverse +from rest_framework import serializers -""" -PokeAPI v2 serializers in order of dependency -""" +# pylint: disable=redefined-builtin -from .models import * # NOQA +# PokeAPI v2 serializers in order of dependency + +from .models import * ######################### @@ -497,7 +497,7 @@ class CharacteristicDetailSerializer(serializers.ModelSerializer): mod = obj.gene_mod_5 values = [] - while (mod <= 30): + while mod <= 30: values.append(mod) mod += 5 @@ -1402,7 +1402,7 @@ class ItemDetailSerializer(serializers.ModelSerializer): sprites_data = json.loads(sprites_data['sprites']) host = 'raw.githubusercontent.com/PokeAPI/sprites/master/' - for key, val in sprites_data.items(): + for key in sprites_data: if sprites_data[key]: sprites_data[key] = 'https://' + host + sprites_data[key].replace('/media/', '') @@ -2305,7 +2305,7 @@ class PokemonFormDetailSerializer(serializers.ModelSerializer): host = 'raw.githubusercontent.com/PokeAPI/sprites/master/' - for key, val in sprites_data.items(): + for key in sprites_data: if sprites_data[key]: sprites_data[key] = 'https://' + host + sprites_data[key].replace('/media/', '') @@ -2523,7 +2523,7 @@ class PokemonDetailSerializer(serializers.ModelSerializer): sprites_data = json.loads(sprites_data['sprites']) host = 'raw.githubusercontent.com/PokeAPI/sprites/master/' - for key, val in sprites_data.items(): + for key in sprites_data: if sprites_data[key]: sprites_data[key] = 'https://' + host + sprites_data[key].replace('/media/', '') @@ -2538,12 +2538,11 @@ class PokemonDetailSerializer(serializers.ModelSerializer): method_data = MoveLearnMethodSummarySerializer( method_objects, many=True, context=self.context).data - ''' - Get moves related to this pokemon and pull out unique Move IDs. - Note that it's important to order by the same column we're using to - determine if the entries are unique. Otherwise distinct() will - return apparent duplicates. - ''' + # Get moves related to this pokemon and pull out unique Move IDs. + # Note that it's important to order by the same column we're using to + # determine if the entries are unique. Otherwise distinct() will + # return apparent duplicates. + pokemon_moves = PokemonMove.objects.filter(pokemon_id=obj).order_by('move_id') move_ids = pokemon_moves.values('move_id').distinct() move_list = [] diff --git a/pokemon_v2/test_models.py b/pokemon_v2/test_models.py index 4eb1a44f..8b4a7c00 100644 --- a/pokemon_v2/test_models.py +++ b/pokemon_v2/test_models.py @@ -1,5 +1,5 @@ from django.test import TestCase -from pokemon_v2.models import * # NOQA +from pokemon_v2.models import * class AbilityTestCase(TestCase): diff --git a/pokemon_v2/tests.py b/pokemon_v2/tests.py index 3fb1b129..d3e6417c 100644 --- a/pokemon_v2/tests.py +++ b/pokemon_v2/tests.py @@ -1,26 +1,21 @@ +import json from rest_framework import status from rest_framework.test import APITestCase -from pokemon_v2.models import * # NOQA -import json +from pokemon_v2.models import * -test_host = 'http://testserver' -media_host = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/' -api_v2 = '/api/v2' +# pylint: disable=redefined-builtin - -""" -Data Initializers -""" +TEST_HOST = 'http://testserver' +MEDIA_HOST = 'https://raw.githubusercontent.com/PokeAPI/sprites/master/' +API_V2 = '/api/v2' class APIData(): + """ Data Initializers""" - """ - Gender Data - """ - + # Gender Data @classmethod - def setup_gender_data(self, name='gndr'): + def setup_gender_data(cls, name='gndr'): gender = Gender.objects.create( name=name, @@ -31,7 +26,7 @@ class APIData(): # Language Data @classmethod - def setup_language_data(self, name='lang'): + def setup_language_data(cls, name='lang'): language = Language.objects.create( iso639='ts', @@ -45,9 +40,9 @@ class APIData(): return language @classmethod - def setup_language_name_data(self, language, name='lang nm'): + def setup_language_name_data(cls, language, name='lang nm'): - local_language = self.setup_language_data( + local_language = cls.setup_language_data( name='lang for ' + name) language_name = LanguageName.objects.create( @@ -61,7 +56,7 @@ class APIData(): # Region Data @classmethod - def setup_region_data(self, name='reg'): + def setup_region_data(cls, name='reg'): region = Region.objects.create( name=name @@ -71,9 +66,9 @@ class APIData(): return region @classmethod - def setup_region_name_data(self, region, name='reg nm'): + def setup_region_name_data(cls, region, name='reg nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) region_name = RegionName.objects.create( @@ -87,9 +82,9 @@ class APIData(): # Generation Data @classmethod - def setup_generation_data(self, region=None, name='gen'): + def setup_generation_data(cls, region=None, name='gen'): - region = region or self.setup_region_data( + region = region or cls.setup_region_data( name='reg for ' + name) generation = Generation.objects.create( @@ -101,9 +96,9 @@ class APIData(): return generation @classmethod - def setup_generation_name_data(self, generation, name='gen nm'): + def setup_generation_name_data(cls, generation, name='gen nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) generation_name = GenerationName.objects.create( @@ -117,9 +112,9 @@ class APIData(): # Version Data @classmethod - def setup_version_group_data(self, name='ver grp', generation=None): + def setup_version_group_data(cls, name='ver grp', generation=None): - generation = generation or self.setup_generation_data( + generation = generation or cls.setup_generation_data( name='gen for ' + name) version_group = VersionGroup.objects.create( @@ -132,7 +127,7 @@ class APIData(): return version_group @classmethod - def setup_version_group_region_data(self, version_group=None, region=None): + def setup_version_group_region_data(cls, version_group=None, region=None): version_group_region = VersionGroupRegion.objects.create( version_group=version_group, @@ -143,7 +138,7 @@ class APIData(): return version_group_region @classmethod - def setup_version_data(self, version_group=None, name='ver'): + def setup_version_data(cls, version_group=None, name='ver'): version = Version.objects.create( name=name, @@ -154,9 +149,9 @@ class APIData(): return version @classmethod - def setup_version_name_data(self, version, name='ver nm'): + def setup_version_name_data(cls, version, name='ver nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) version_name = VersionName.objects.create( @@ -170,9 +165,9 @@ class APIData(): # Ability Data @classmethod - def setup_ability_data(self, name='ablty', generation=None): + def setup_ability_data(cls, name='ablty', generation=None): - generation = generation or self.setup_generation_data( + generation = generation or cls.setup_generation_data( name='gen for ' + name) ability = Ability.objects.create( @@ -185,9 +180,9 @@ class APIData(): return ability @classmethod - def setup_ability_name_data(self, ability, name='ablty nm'): + def setup_ability_name_data(cls, ability, name='ablty nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) ability_name = AbilityName.objects.create( @@ -200,10 +195,10 @@ class APIData(): return ability_name @classmethod - def setup_ability_effect_text_data(self, ability, + def setup_ability_effect_text_data(cls, ability, short_effect='ablty shrt efct', effect='ablty efct'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) ability_effect_text = AbilityEffectText.objects.create( @@ -217,9 +212,9 @@ class APIData(): return ability_effect_text @classmethod - def setup_ability_change_data(self, ability): + def setup_ability_change_data(cls, ability): - version_group = self.setup_version_group_data( + version_group = cls.setup_version_group_data( name='ver grp for ablty chng') ability_change = AbilityChange.objects.create( @@ -231,9 +226,9 @@ class APIData(): return ability_change @classmethod - def setup_ability_change_effect_text_data(self, ability_change, effect='ablty change efct'): + def setup_ability_change_effect_text_data(cls, ability_change, effect='ablty change efct'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) ability_change_effect_text = AbilityChangeEffectText.objects.create( @@ -246,12 +241,12 @@ class APIData(): return ability_change_effect_text @classmethod - def setup_ability_flavor_text_data(self, ability, flavor_text='ablty flvr txt'): + def setup_ability_flavor_text_data(cls, ability, flavor_text='ablty flvr txt'): - version_group = self.setup_version_group_data( + version_group = cls.setup_version_group_data( name='ver grp for ' + flavor_text) - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + flavor_text) ability_flavor_text = AbilityFlavorText.objects.create( @@ -266,7 +261,7 @@ class APIData(): # Item Data @classmethod - def setup_item_attribute_data(self, name="itm attr"): + def setup_item_attribute_data(cls, name="itm attr"): item_attribute = ItemAttribute.objects.create( name=name, @@ -276,9 +271,9 @@ class APIData(): return item_attribute @classmethod - def setup_item_attribute_name_data(self, item_attribute, name='itm attr nm'): + def setup_item_attribute_name_data(cls, item_attribute, name='itm attr nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) item_attribute_name = ItemAttributeName.objects.create( @@ -291,9 +286,9 @@ class APIData(): return item_attribute_name @classmethod - def setup_item_attribute_description_data(self, item_attribute, description='itm attr desc'): + def setup_item_attribute_description_data(cls, item_attribute, description='itm attr desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) item_attribute_description = ItemAttributeDescription.objects.create( @@ -306,7 +301,7 @@ class APIData(): return item_attribute_description @classmethod - def setup_item_attribute_map_data(self, item, item_attribute): + def setup_item_attribute_map_data(cls, item, item_attribute): item_attribute_map = ItemAttributeMap( item=item, @@ -317,7 +312,7 @@ class APIData(): return item_attribute_map @classmethod - def setup_item_fling_effect_data(self, name="itm flng efct"): + def setup_item_fling_effect_data(cls, name="itm flng efct"): item_fling_effect = ItemFlingEffect.objects.create( name=name, @@ -326,10 +321,11 @@ class APIData(): return item_fling_effect - def setup_item_fling_effect_effect_text_data(self, item_fling_effect, + @classmethod + def setup_item_fling_effect_effect_text_data(cls, item_fling_effect, effect='itm flng efct efct txt'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) item_fling_effect_effect_text = ItemFlingEffectEffectText.objects.create( @@ -342,7 +338,7 @@ class APIData(): return item_fling_effect_effect_text @classmethod - def setup_item_pocket_data(self, name='itm pkt'): + def setup_item_pocket_data(cls, name='itm pkt'): item_pocket = ItemPocket.objects.create( name=name, @@ -352,9 +348,9 @@ class APIData(): return item_pocket @classmethod - def setup_item_pocket_name_data(self, item_pocket, name='itm pkt nm'): + def setup_item_pocket_name_data(cls, item_pocket, name='itm pkt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) item_pocket_name = ItemPocketName.objects.create( @@ -367,9 +363,9 @@ class APIData(): return item_pocket_name @classmethod - def setup_item_category_data(self, name="itm ctgry", item_pocket=None): + def setup_item_category_data(cls, name="itm ctgry", item_pocket=None): - item_pocket = item_pocket or self.setup_item_pocket_data( + item_pocket = item_pocket or cls.setup_item_pocket_data( name='itm pkt for ' + name) item_category = ItemCategory.objects.create( @@ -380,9 +376,10 @@ class APIData(): return item_category - def setup_item_category_name_data(self, item_category, name='itm ctgry nm'): + @classmethod + def setup_item_category_name_data(cls, item_category, name='itm ctgry nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) item_category_name = ItemCategoryName.objects.create( @@ -395,7 +392,7 @@ class APIData(): return item_category_name @classmethod - def setup_item_sprites_data(self, item, default=True): + def setup_item_sprites_data(cls, item, default=True): sprite_path = '/media/sprites/items/%s.png' @@ -412,14 +409,14 @@ class APIData(): return item_sprites @classmethod - def setup_item_data(self, item_category=None, item_fling_effect=None, + def setup_item_data(cls, item_category=None, item_fling_effect=None, name='itm', cost=100, fling_power=100): item = Item.objects.create( name=name, item_category=item_category, - cost=300, - fling_power=100, + cost=cost, + fling_power=fling_power, item_fling_effect=item_fling_effect ) item.save() @@ -427,9 +424,9 @@ class APIData(): return item @classmethod - def setup_item_name_data(self, item, name='itm nm'): + def setup_item_name_data(cls, item, name='itm nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) item_name = ItemName.objects.create( @@ -442,10 +439,10 @@ class APIData(): return item_name @classmethod - def setup_item_effect_text_data(self, item, + def setup_item_effect_text_data(cls, item, short_effect='ablty shrt efct', effect='ablty efct'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) item_effect_text = ItemEffectText.objects.create( @@ -459,12 +456,12 @@ class APIData(): return item_effect_text @classmethod - def setup_item_flavor_text_data(self, item, flavor_text='itm flvr txt'): + def setup_item_flavor_text_data(cls, item, flavor_text='itm flvr txt'): - version_group = self.setup_version_group_data( + version_group = cls.setup_version_group_data( name='ver grp for ' + flavor_text) - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + flavor_text) item_flavor_text = ItemFlavorText.objects.create( @@ -478,9 +475,9 @@ class APIData(): return item_flavor_text @classmethod - def setup_item_game_index_data(self, item, game_index=0): + def setup_item_game_index_data(cls, item, game_index=0): - generation = self.setup_generation_data( + generation = cls.setup_generation_data( name='gen for itm gm indx') item_game_index = ItemGameIndex.objects.create( @@ -494,7 +491,7 @@ class APIData(): # Contest Data @classmethod - def setup_contest_type_data(self, name='cntst tp'): + def setup_contest_type_data(cls, name='cntst tp'): contest_type = ContestType.objects.create( name=name, @@ -504,9 +501,9 @@ class APIData(): return contest_type @classmethod - def setup_contest_type_name_data(self, contest_type, name='cntst tp nm'): + def setup_contest_type_name_data(cls, contest_type, name='cntst tp nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) contest_type_name = ContestTypeName.objects.create( @@ -519,7 +516,7 @@ class APIData(): return contest_type_name @classmethod - def setup_contest_effect_data(self, appeal=2, jam=0): + def setup_contest_effect_data(cls, appeal=2, jam=0): contest_effect = ContestEffect.objects.create( appeal=appeal, @@ -530,10 +527,10 @@ class APIData(): return contest_effect @classmethod - def setup_contest_effect_flavor_text_data(self, + def setup_contest_effect_flavor_text_data(cls, contest_effect, flavor_text='cntst efct flvr txt'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + flavor_text) contest_effect_flavor_text = ContestEffectFlavorText.objects.create( @@ -546,9 +543,9 @@ class APIData(): return contest_effect_flavor_text @classmethod - def setup_contest_effect_effect_text_data(self, contest_effect, effect='cntst efct efct txt'): + def setup_contest_effect_effect_text_data(cls, contest_effect, effect='cntst efct efct txt'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) contest_effect_effect_text = ContestEffectEffectText.objects.create( @@ -561,7 +558,7 @@ class APIData(): return contest_effect_effect_text @classmethod - def setup_super_contest_effect_data(self, appeal=2): + def setup_super_contest_effect_data(cls, appeal=2): super_contest_effect = SuperContestEffect.objects.create( appeal=appeal, @@ -571,10 +568,10 @@ class APIData(): return super_contest_effect @classmethod - def setup_super_contest_effect_flavor_text_data(self, super_contest_effect, + def setup_super_contest_effect_flavor_text_data(cls, super_contest_effect, flavor_text='spr cntst efct flvr txt'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + flavor_text) super_contest_effect_flavor_text = SuperContestEffectFlavorText.objects.create( @@ -588,9 +585,9 @@ class APIData(): # Berry Data @classmethod - def setup_berry_flavor_data(self, contest_type=None, name="bry flvr"): + def setup_berry_flavor_data(cls, contest_type=None, name="bry flvr"): - contest_type = contest_type or self.setup_contest_type_data( + contest_type = contest_type or cls.setup_contest_type_data( name='cntst tp for bry flvr') berry_flavor = BerryFlavor.objects.create( @@ -602,9 +599,9 @@ class APIData(): return berry_flavor @classmethod - def setup_berry_flavor_name_data(self, berry_flavor, name='bry flvr nm'): + def setup_berry_flavor_name_data(cls, berry_flavor, name='bry flvr nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) berry_flavor_name = BerryFlavorName.objects.create( @@ -617,7 +614,7 @@ class APIData(): return berry_flavor_name @classmethod - def setup_berry_firmness_data(self, name='bry frmns'): + def setup_berry_firmness_data(cls, name='bry frmns'): berry_firmness = BerryFirmness.objects.create( name=name, @@ -627,9 +624,9 @@ class APIData(): return berry_firmness @classmethod - def setup_berry_firmness_name_data(self, berry_firmness, name='bry frmns nm'): + def setup_berry_firmness_name_data(cls, berry_firmness, name='bry frmns nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) berry_firmness_name = BerryFirmnessName.objects.create( @@ -642,7 +639,7 @@ class APIData(): return berry_firmness_name @classmethod - def setup_berry_flavor_map_data(self, berry, berry_flavor, potency=20): + def setup_berry_flavor_map_data(cls, berry, berry_flavor, potency=20): berry_flavor_map = BerryFlavorMap( berry=berry, @@ -654,14 +651,14 @@ class APIData(): return berry_flavor_map @classmethod - def setup_berry_data(self, berry_firmness=None, item=None, natural_gift_type=None, + 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 self.setup_item_data( + item = item or cls.setup_item_data( name='itm for ' + name) - berry_firmness = berry_firmness or self.setup_berry_firmness_data( + berry_firmness = berry_firmness or cls.setup_berry_firmness_data( name='bry frmns for ' + name) berry = Berry.objects.create( @@ -682,7 +679,7 @@ class APIData(): # Egg Group Data @classmethod - def setup_egg_group_data(self, name='egg grp'): + def setup_egg_group_data(cls, name='egg grp'): egg_group = EggGroup.objects.create( name=name, @@ -692,9 +689,9 @@ class APIData(): return egg_group @classmethod - def setup_egg_group_name_data(self, egg_group, name='ntr nm'): + def setup_egg_group_name_data(cls, egg_group, name='ntr nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) egg_group_name = EggGroupName.objects.create( @@ -708,7 +705,7 @@ class APIData(): # Growth Rate Data @classmethod - def setup_growth_rate_data(self, name='grth rt', formula="pie*1000"): + def setup_growth_rate_data(cls, name='grth rt', formula="pie*1000"): growth_rate = GrowthRate( name=name, @@ -718,9 +715,10 @@ class APIData(): return growth_rate - def setup_growth_rate_description_data(self, growth_rate, description='grth rt desc'): + @classmethod + def setup_growth_rate_description_data(cls, growth_rate, description='grth rt desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) growth_rate_description = GrowthRateDescription.objects.create( @@ -734,9 +732,9 @@ class APIData(): # Location Data @classmethod - def setup_location_data(self, region=None, name='lctn'): + def setup_location_data(cls, region=None, name='lctn'): - region = region or self.setup_region_data( + region = region or cls.setup_region_data( name='rgn for ' + name) location = Location( @@ -748,9 +746,9 @@ class APIData(): return location @classmethod - def setup_location_game_index_data(self, location, game_index=0): + def setup_location_game_index_data(cls, location, game_index=0): - generation = self.setup_generation_data( + generation = cls.setup_generation_data( name='gen for itm gm indx') location_game_index = LocationGameIndex.objects.create( @@ -763,9 +761,9 @@ class APIData(): return location_game_index @classmethod - def setup_location_name_data(self, location, name='lctn nm'): + def setup_location_name_data(cls, location, name='lctn nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) location_name = LocationName.objects.create( @@ -778,9 +776,9 @@ class APIData(): return location_name @classmethod - def setup_location_area_data(self, location=None, name='lctn area', game_index=0): + def setup_location_area_data(cls, location=None, name='lctn area', game_index=0): - location = location or self.setup_location_data( + location = location or cls.setup_location_data( name='lctn for ' + name) location_area = LocationArea( @@ -793,9 +791,9 @@ class APIData(): return location_area @classmethod - def setup_location_area_name_data(self, location_area, name='lctn area nm'): + def setup_location_area_name_data(cls, location_area, name='lctn area nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) location_area_name = LocationAreaName.objects.create( @@ -809,12 +807,12 @@ class APIData(): # Type Data @classmethod - def setup_type_data(self, name='tp', move_damage_class=None, generation=None): + def setup_type_data(cls, name='tp', move_damage_class=None, generation=None): - move_damage_class = move_damage_class or self.setup_move_damage_class_data( + move_damage_class = move_damage_class or cls.setup_move_damage_class_data( name="mv dmg cls for " + name) - generation = generation or self.setup_generation_data( + generation = generation or cls.setup_generation_data( name='rgn for ' + name) type = Type( @@ -827,9 +825,9 @@ class APIData(): return type @classmethod - def setup_type_name_data(self, type, name='tp nm'): + def setup_type_name_data(cls, type, name='tp nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) type_name = TypeName.objects.create( @@ -842,9 +840,9 @@ class APIData(): return type_name @classmethod - def setup_type_game_index_data(self, type, game_index=0): + def setup_type_game_index_data(cls, type, game_index=0): - generation = self.setup_generation_data( + generation = cls.setup_generation_data( name='gen for tp gm indx') type_game_index = TypeGameIndex.objects.create( @@ -858,7 +856,7 @@ class APIData(): # Move Data @classmethod - def setup_move_ailment_data(self, name='mv almnt'): + def setup_move_ailment_data(cls, name='mv almnt'): move_ailment = MoveMetaAilment.objects.create( name=name @@ -868,9 +866,9 @@ class APIData(): return move_ailment @classmethod - def setup_move_ailment_name_data(self, move_ailment, name='mv almnt nm'): + def setup_move_ailment_name_data(cls, move_ailment, name='mv almnt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) move_ailment_name = MoveMetaAilmentName.objects.create( @@ -883,7 +881,7 @@ class APIData(): return move_ailment_name @classmethod - def setup_move_battle_style_data(self, name='mv btl stl'): + def setup_move_battle_style_data(cls, name='mv btl stl'): move_battle_style = MoveBattleStyle.objects.create( name=name @@ -893,9 +891,9 @@ class APIData(): return move_battle_style @classmethod - def setup_move_battle_style_name_data(self, move_battle_style, name='mv almnt nm'): + def setup_move_battle_style_name_data(cls, move_battle_style, name='mv almnt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) move_battle_style_name = MoveBattleStyleName.objects.create( @@ -908,7 +906,7 @@ class APIData(): return move_battle_style_name @classmethod - def setup_move_category_data(self, name='mv ctgry'): + def setup_move_category_data(cls, name='mv ctgry'): move_category = MoveMetaCategory.objects.create( name=name @@ -918,9 +916,9 @@ class APIData(): return move_category @classmethod - def setup_move_category_description_data(self, move_category, description='mv ctgry desc'): + def setup_move_category_description_data(cls, move_category, description='mv ctgry desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) move_category_description = MoveMetaCategoryDescription.objects.create( @@ -933,7 +931,7 @@ class APIData(): return move_category_description @classmethod - def setup_move_effect_data(self): + def setup_move_effect_data(cls): move_effect = MoveEffect.objects.create() move_effect.save() @@ -941,10 +939,10 @@ class APIData(): return move_effect @classmethod - def setup_move_effect_effect_text_data(self, move_effect, effect='mv efct efct txt', + def setup_move_effect_effect_text_data(cls, move_effect, effect='mv efct efct txt', short_effect='mv efct shrt efct txt'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) effect_effect_text = MoveEffectEffectText.objects.create( @@ -958,7 +956,7 @@ class APIData(): return effect_effect_text @classmethod - def setup_move_damage_class_data(self, name='mv dmg cls'): + def setup_move_damage_class_data(cls, name='mv dmg cls'): move_damage_class = MoveDamageClass.objects.create( name=name @@ -968,9 +966,9 @@ class APIData(): return move_damage_class @classmethod - def setup_move_damage_class_name_data(self, move_damage_class, name='mv dmg cls nm'): + def setup_move_damage_class_name_data(cls, move_damage_class, name='mv dmg cls nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) move_damage_class_name = MoveDamageClassName.objects.create( @@ -983,10 +981,10 @@ class APIData(): return move_damage_class_name @classmethod - def setup_move_damage_class_description_data(self, move_damage_class, + def setup_move_damage_class_description_data(cls, move_damage_class, description='mv dmg cls desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) move_damage_class_description = MoveDamageClassDescription.objects.create( @@ -999,7 +997,7 @@ class APIData(): return move_damage_class_description @classmethod - def setup_move_learn_method_data(self, name='mv lrn mthd'): + def setup_move_learn_method_data(cls, name='mv lrn mthd'): move_learn_method = MoveLearnMethod.objects.create( name=name @@ -1009,9 +1007,9 @@ class APIData(): return move_learn_method @classmethod - def setup_move_learn_method_name_data(self, move_learn_method, name='mv lrn mthd nm'): + def setup_move_learn_method_name_data(cls, move_learn_method, name='mv lrn mthd nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) move_learn_method_name = MoveLearnMethodName.objects.create( @@ -1024,10 +1022,10 @@ class APIData(): return move_learn_method_name @classmethod - def setup_move_learn_method_description_data(self, move_learn_method, + def setup_move_learn_method_description_data(cls, move_learn_method, description='mv lrn mthd desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) move_learn_method_description = MoveLearnMethodDescription.objects.create( @@ -1040,7 +1038,7 @@ class APIData(): return move_learn_method_description @classmethod - def setup_move_target_data(self, name='mv trgt'): + def setup_move_target_data(cls, name='mv trgt'): move_target = MoveTarget.objects.create( name=name @@ -1050,9 +1048,9 @@ class APIData(): return move_target @classmethod - def setup_move_target_name_data(self, move_target, name='mv trgt nm'): + def setup_move_target_name_data(cls, move_target, name='mv trgt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) move_target_name = MoveTargetName.objects.create( @@ -1065,9 +1063,9 @@ class APIData(): return move_target_name @classmethod - def setup_move_target_description_data(self, move_target, description='mv trgt desc'): + def setup_move_target_description_data(cls, move_target, description='mv trgt desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) move_target_description = MoveTargetDescription.objects.create( @@ -1080,7 +1078,7 @@ class APIData(): return move_target_description @classmethod - def setup_contest_combo_data(self, first_move, second_move): + def setup_contest_combo_data(cls, first_move, second_move): contest_combo = ContestCombo.objects.create( first_move=first_move, @@ -1091,7 +1089,7 @@ class APIData(): return contest_combo @classmethod - def setup_version_group_move_learn_method_data(self, version_group=None, + def setup_version_group_move_learn_method_data(cls, version_group=None, move_learn_method=None): version_group_move_learn_method = VersionGroupMoveLearnMethod.objects.create( @@ -1103,7 +1101,7 @@ class APIData(): return version_group_move_learn_method @classmethod - def setup_super_contest_combo_data(self, first_move, second_move): + def setup_super_contest_combo_data(cls, first_move, second_move): super_contest_combo = SuperContestCombo.objects.create( first_move=first_move, @@ -1114,11 +1112,11 @@ class APIData(): return super_contest_combo @classmethod - def setup_move_flavor_text_data(self, move, flavor_text='move flvr txt'): - version_group = self.setup_version_group_data( + def setup_move_flavor_text_data(cls, move, flavor_text='move flvr txt'): + version_group = cls.setup_version_group_data( name='ver grp for ' + flavor_text) - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + flavor_text) move_flavor_text = MoveFlavorText.objects.create( @@ -1132,28 +1130,28 @@ class APIData(): return move_flavor_text @classmethod - def setup_move_data(self, contest_type=None, contest_effect=None, super_contest_effect=None, + 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): - contest_type = contest_type or self.setup_contest_type_data( + contest_type = contest_type or cls.setup_contest_type_data( name='cntst tp for ' + name) - contest_effect = contest_effect or self.setup_contest_effect_data() + contest_effect = contest_effect or cls.setup_contest_effect_data() - super_contest_effect = super_contest_effect or self.setup_super_contest_effect_data() + super_contest_effect = super_contest_effect or cls.setup_super_contest_effect_data() - generation = generation or self.setup_generation_data( + generation = generation or cls.setup_generation_data( name='gen for ' + name) - type = type or self.setup_type_data( + type = type or cls.setup_type_data( name='tp for ' + name) - move_target = move_target or self.setup_move_target_data( + move_target = move_target or cls.setup_move_target_data( name='mv trgt for ' + name) - move_damage_class = move_damage_class or self.setup_move_damage_class_data( + move_damage_class = move_damage_class or cls.setup_move_damage_class_data( name='mv dmg cls for ' + name) move = Move.objects.create( @@ -1177,9 +1175,9 @@ class APIData(): return move @classmethod - def setup_move_name_data(self, move, name='mv nm'): + def setup_move_name_data(cls, move, name='mv nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) move_name = MoveName.objects.create( @@ -1192,14 +1190,14 @@ class APIData(): return move_name @classmethod - def setup_move_meta_data(self, move, move_ailment=None, move_category=None, + 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): - move_ailment = move_ailment or self.setup_move_ailment_data() + move_ailment = move_ailment or cls.setup_move_ailment_data() - move_category = move_category or self.setup_move_category_data() + move_category = move_category or cls.setup_move_category_data() move_meta = MoveMeta( move=move, @@ -1221,11 +1219,11 @@ class APIData(): return move_meta @classmethod - def setup_move_change_data(self, move=None, type=None, move_effect=None, + def setup_move_change_data(cls, move=None, type=None, move_effect=None, version_group=None, power=20, pp=20, accuracy=80, - priority=0, effect_chance=50): + effect_chance=50): - version_group = version_group or self.setup_version_group_data( + version_group = version_group or cls.setup_version_group_data( name='ver grp for mv chng') move_change = MoveChange.objects.create( @@ -1243,9 +1241,9 @@ class APIData(): return move_change @classmethod - def setup_move_effect_change_data(self, move_effect=None): + def setup_move_effect_change_data(cls, move_effect=None): - version_group = self.setup_version_group_data( + version_group = cls.setup_version_group_data( name='ver grp for mv chng') move_effect_change = MoveEffectChange.objects.create( @@ -1257,10 +1255,10 @@ class APIData(): return move_effect_change @classmethod - def setup_move_effect_change_effect_text_data(self, move_effect_change=None, + def setup_move_effect_change_effect_text_data(cls, move_effect_change=None, effect='mv efct chng efct txt'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + effect) move_effect_change_effect_text = MoveEffectChangeEffectText.objects.create( @@ -1274,9 +1272,9 @@ class APIData(): # Stat Data @classmethod - def setup_stat_data(self, name='stt', is_battle_only=True, game_index=1): + def setup_stat_data(cls, name='stt', is_battle_only=True, game_index=1): - move_damage_class = self.setup_move_damage_class_data( + move_damage_class = cls.setup_move_damage_class_data( name='mv dmg cls for ' + name) stat = Stat.objects.create( @@ -1290,9 +1288,9 @@ class APIData(): return stat @classmethod - def setup_stat_name_data(self, stat, name='stt nm'): + def setup_stat_name_data(cls, stat, name='stt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) stat_name = StatName.objects.create( @@ -1305,9 +1303,9 @@ class APIData(): return stat_name @classmethod - def setup_move_stat_change_data(self, move, stat=None, change=1): + def setup_move_stat_change_data(cls, move, stat=None, change=1): - stat = stat or self.setup_stat_data( + stat = stat or cls.setup_stat_data( name='stt for mv') move_stat_change = MoveMetaStatChange.objects.create( @@ -1320,7 +1318,7 @@ class APIData(): return move_stat_change @classmethod - def setup_pokeathlon_stat_data(self, name='pkathln stt'): + def setup_pokeathlon_stat_data(cls, name='pkathln stt'): pokeathlon_stat = PokeathlonStat.objects.create( name=name @@ -1330,9 +1328,9 @@ class APIData(): return pokeathlon_stat @classmethod - def setup_pokeathlon_stat_name_data(self, pokeathlon_stat, name='pkathln stt nm'): + def setup_pokeathlon_stat_name_data(cls, pokeathlon_stat, name='pkathln stt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pokeathlon_stat_name = PokeathlonStatName.objects.create( @@ -1346,9 +1344,9 @@ class APIData(): # Characteristic Data @classmethod - def setup_characteristic_data(self, gene_mod_5=0, stat=None): + def setup_characteristic_data(cls, gene_mod_5=0, stat=None): - stat = stat or self.setup_stat_data( + stat = stat or cls.setup_stat_data( name='stt for char') characteristic = Characteristic.objects.create( @@ -1360,9 +1358,9 @@ class APIData(): return characteristic @classmethod - def setup_characteristic_description_data(self, characteristic, description='char desc'): + def setup_characteristic_description_data(cls, characteristic, description='char desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) characteristic_description = CharacteristicDescription.objects.create( @@ -1376,7 +1374,7 @@ class APIData(): # Nature Data @classmethod - def setup_nature_data(self, decreased_stat=None, increased_stat=None, + def setup_nature_data(cls, decreased_stat=None, increased_stat=None, likes_flavor=None, hates_flavor=None, name='ntr', game_index=1): nature = Nature.objects.create( @@ -1392,9 +1390,9 @@ class APIData(): return nature @classmethod - def setup_nature_name_data(self, nature, name='ntr nm'): + def setup_nature_name_data(cls, nature, name='ntr nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) nature_name = NatureName.objects.create( @@ -1407,7 +1405,7 @@ class APIData(): return nature_name @classmethod - def setup_nature_pokeathlon_stat_data(self, nature=None, pokeathlon_stat=None, max_change=1): + def setup_nature_pokeathlon_stat_data(cls, nature=None, pokeathlon_stat=None, max_change=1): nature_pokeathlon_stat = NaturePokeathlonStat.objects.create( nature=nature, @@ -1419,7 +1417,7 @@ class APIData(): return nature_pokeathlon_stat @classmethod - def setup_nature_battle_style_preference_data(self, nature=None, move_battle_style=None, + def setup_nature_battle_style_preference_data(cls, nature=None, move_battle_style=None, low_hp_preference=10, high_hp_preference=20): nature_battle_style_preference = NatureBattleStylePreference.objects.create( @@ -1434,9 +1432,9 @@ class APIData(): # Pokedex Data @classmethod - def setup_pokedex_data(self, region=None, name='pkdx'): + def setup_pokedex_data(cls, region=None, name='pkdx'): - region = region or self.setup_region_data( + region = region or cls.setup_region_data( name='rgn for ' + name) pokedex = Pokedex.objects.create( @@ -1448,9 +1446,9 @@ class APIData(): return pokedex @classmethod - def setup_pokedex_name_data(self, pokedex, name='pkdx nm'): + def setup_pokedex_name_data(cls, pokedex, name='pkdx nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pokedex_name = PokedexName.objects.create( @@ -1463,9 +1461,9 @@ class APIData(): return pokedex_name @classmethod - def setup_pokedex_description_data(self, pokedex, description='pkdx desc'): + def setup_pokedex_description_data(cls, pokedex, description='pkdx desc'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) pokedex_description = PokedexDescription.objects.create( @@ -1478,9 +1476,9 @@ class APIData(): return pokedex_description @classmethod - def setup_pokedex_version_group_data(self, pokedex, version_group=None): + def setup_pokedex_version_group_data(cls, pokedex, version_group=None): - version_group = version_group or self.setup_language_data( + version_group = version_group or cls.setup_language_data( name='ver grp for pkdx') pokedex_version_group = PokedexVersionGroup.objects.create( @@ -1493,7 +1491,7 @@ class APIData(): # Pokemon Data @classmethod - def setup_pokemon_habitat_data(self, name='pkm hbtt'): + def setup_pokemon_habitat_data(cls, name='pkm hbtt'): pokemon_habitat = PokemonHabitat.objects.create( name=name, @@ -1503,9 +1501,9 @@ class APIData(): return pokemon_habitat @classmethod - def setup_pokemon_habitat_name_data(self, pokemon_habitat, name='pkm hbtt nm'): + def setup_pokemon_habitat_name_data(cls, pokemon_habitat, name='pkm hbtt nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pokemon_habitat_name = PokemonHabitatName.objects.create( @@ -1518,7 +1516,7 @@ class APIData(): return pokemon_habitat_name @classmethod - def setup_pokemon_color_data(self, name='pkm clr'): + def setup_pokemon_color_data(cls, name='pkm clr'): pokemon_color = PokemonColor.objects.create( name=name, @@ -1528,9 +1526,9 @@ class APIData(): return pokemon_color @classmethod - def setup_pokemon_color_name_data(self, pokemon_color, name='pkm clr nm'): + def setup_pokemon_color_name_data(cls, pokemon_color, name='pkm clr nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pokemon_color_name = PokemonColorName.objects.create( @@ -1543,7 +1541,7 @@ class APIData(): return pokemon_color_name @classmethod - def setup_pokemon_shape_data(self, name='pkm shp'): + def setup_pokemon_shape_data(cls, name='pkm shp'): pokemon_shape = PokemonShape.objects.create( name=name, @@ -1553,10 +1551,10 @@ class APIData(): return pokemon_shape @classmethod - def setup_pokemon_shape_name_data(self, pokemon_shape, name='pkm shp nm', + def setup_pokemon_shape_name_data(cls, pokemon_shape, name='pkm shp nm', awesome_name='pkm shp awsm nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pokemon_shape_name = PokemonShapeName.objects.create( @@ -1570,10 +1568,10 @@ class APIData(): return pokemon_shape_name @classmethod - def setup_pokemon_species_form_description_data(self, pokemon_species=None, + def setup_pokemon_species_form_description_data(cls, pokemon_species=None, description='pkm spcs frm dscr'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + description) pokemon_species_form_description = PokemonSpeciesDescription.objects.create( @@ -1586,13 +1584,13 @@ class APIData(): return pokemon_species_form_description @classmethod - def setup_pokemon_species_flavor_text_data(self, pokemon_species, + def setup_pokemon_species_flavor_text_data(cls, pokemon_species, flavor_text='pkmn spcs flvr txt'): - version = self.setup_version_data( + version = cls.setup_version_data( name='ver for ' + flavor_text) - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + flavor_text) pokemon_species_flavor_text = PokemonSpeciesFlavorText.objects.create( @@ -1606,26 +1604,26 @@ class APIData(): return pokemon_species_flavor_text @classmethod - def setup_pokemon_species_data(self, generation=None, evolves_from_species=None, + 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, order=1): - generation = generation or self.setup_generation_data( + generation = generation or cls.setup_generation_data( name='gen for ' + name) - growth_rate = growth_rate or self.setup_growth_rate_data( + growth_rate = growth_rate or cls.setup_growth_rate_data( name='grth rt for ' + name) - pokemon_shape = pokemon_shape or self.setup_pokemon_shape_data( + pokemon_shape = pokemon_shape or cls.setup_pokemon_shape_data( name='pkmn shp for ' + name) - pokemon_color = pokemon_color or self.setup_pokemon_color_data( + pokemon_color = pokemon_color or cls.setup_pokemon_color_data( name='pkmn clr for ' + name) - pokemon_habitat = pokemon_habitat or self.setup_pokemon_habitat_data( + pokemon_habitat = pokemon_habitat or cls.setup_pokemon_habitat_data( name='pkm hbtt for ' + name) pokemon_species = PokemonSpecies.objects.create( @@ -1644,17 +1642,17 @@ class APIData(): has_gender_differences=has_gender_differences, growth_rate=growth_rate, forms_switchable=forms_switchable, - order=forms_switchable + order=order ) pokemon_species.save() return pokemon_species @classmethod - def setup_pokemon_species_name_data(self, pokemon_species, name='pkmn spcs nm', + def setup_pokemon_species_name_data(cls, pokemon_species, name='pkmn spcs nm', genus='pkmn spcs gns'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pokemon_species_name = PokemonSpeciesName.objects.create( @@ -1668,7 +1666,7 @@ class APIData(): return pokemon_species_name @classmethod - def setup_pokemon_dex_entry_data(self, pokemon_species, pokedex, entry_number=100): + def setup_pokemon_dex_entry_data(cls, pokemon_species, pokedex, entry_number=100): dex_number = PokemonDexNumber( pokemon_species=pokemon_species, @@ -1680,7 +1678,7 @@ class APIData(): return dex_number @classmethod - def setup_pokemon_egg_group_data(self, pokemon_species, egg_group): + def setup_pokemon_egg_group_data(cls, pokemon_species, egg_group): pokemon_egg_group = PokemonEggGroup( pokemon_species=pokemon_species, @@ -1691,10 +1689,10 @@ class APIData(): return pokemon_egg_group @classmethod - def setup_pokemon_data(self, pokemon_species=None, name='pkmn', + def setup_pokemon_data(cls, pokemon_species=None, name='pkmn', height=100, weight=100, base_experience=0, order=1, is_default=False): - pokemon_species = pokemon_species or self.setup_pokemon_species_data( + pokemon_species = pokemon_species or cls.setup_pokemon_species_data( name='pkmn spcs for ' + name) pokemon = Pokemon.objects.create( @@ -1711,9 +1709,9 @@ class APIData(): return pokemon @classmethod - def setup_pokemon_game_index_data(self, pokemon, game_index=0): + def setup_pokemon_game_index_data(cls, pokemon, game_index=0): - version = self.setup_version_data( + version = cls.setup_version_data( name='ver for pkmn gm indx') pokemon_game_index = PokemonGameIndex.objects.create( @@ -1727,7 +1725,7 @@ class APIData(): @classmethod def setup_pokemon_form_sprites_data( - self, pokemon_form, + cls, pokemon_form, front_default=True, front_shiny=False, back_default=False, back_shiny=False): @@ -1749,11 +1747,11 @@ class APIData(): return pokemon_form_sprites @classmethod - def setup_pokemon_form_data(self, pokemon, name='pkmn nrml frm', + 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 = self.setup_version_group_data( + version_group = cls.setup_version_group_data( name='ver grp for ' + name) pokemon_form = PokemonForm( @@ -1772,9 +1770,9 @@ class APIData(): return pokemon_form @classmethod - def setup_pokemon_ability_data(self, pokemon, ability=None, is_hidden=False, slot=1): + def setup_pokemon_ability_data(cls, pokemon, ability=None, is_hidden=False, slot=1): - ability = ability or self.setup_ability_data(name='ablty for pkmn') + ability = ability or cls.setup_ability_data(name='ablty for pkmn') pokemon_ability = PokemonAbility( pokemon=pokemon, @@ -1787,9 +1785,9 @@ class APIData(): return pokemon_ability @classmethod - def setup_pokemon_stat_data(self, pokemon, base_stat=10, effort=10): + def setup_pokemon_stat_data(cls, pokemon, base_stat=10, effort=10): - stat = self.setup_stat_data( + stat = cls.setup_stat_data( name='stt for pkmn') pokemon_stat = PokemonStat( @@ -1803,9 +1801,9 @@ class APIData(): return pokemon_stat @classmethod - def setup_pokemon_type_data(self, pokemon, type=None, slot=1): + def setup_pokemon_type_data(cls, pokemon, type=None, slot=1): - type = type or self.setup_type_data( + type = type or cls.setup_type_data( name='tp for pkmn') pokemon_type = PokemonType( @@ -1818,15 +1816,15 @@ class APIData(): return pokemon_type @classmethod - def setup_pokemon_item_data(self, pokemon=None, item=None, version=None, rarity=50): + def setup_pokemon_item_data(cls, pokemon=None, item=None, version=None, rarity=50): - item = item or self.setup_item_data( + item = item or cls.setup_item_data( name='itm for pkmn') - pokemon = pokemon or self.setup_pokemon_data( + pokemon = pokemon or cls.setup_pokemon_data( name='pkmn for pkmn') - version = version or self.setup_version_data( + version = version or cls.setup_version_data( name='ver grp for pkmn itm') pokemon_item = PokemonItem( @@ -1840,9 +1838,9 @@ class APIData(): return pokemon_item @classmethod - def setup_pokemon_move_data(self, pokemon, move, version_group, level=0, order=1): + def setup_pokemon_move_data(cls, pokemon, move, version_group, level=0, order=1): - move_learn_method = self.setup_move_learn_method_data( + move_learn_method = cls.setup_move_learn_method_data( name='mv lrn mthd for pkmn') pokemon_move = PokemonMove.objects.create( @@ -1859,7 +1857,7 @@ class APIData(): @classmethod def setup_pokemon_sprites_data( - self, pokemon, front_default=True, + cls, pokemon, front_default=True, front_female=False, front_shiny=False, front_shiny_female=False, back_default=False, back_female=False, back_shiny=False, @@ -1888,7 +1886,7 @@ class APIData(): # Evolution Data @classmethod - def setup_evolution_trigger_data(self, name='evltn trgr'): + def setup_evolution_trigger_data(cls, name='evltn trgr'): evolution_trigger = EvolutionTrigger.objects.create( name=name, @@ -1898,9 +1896,9 @@ class APIData(): return evolution_trigger @classmethod - def setup_evolution_trigger_name_data(self, evolution_trigger, name='evltn trgr nm'): + def setup_evolution_trigger_name_data(cls, evolution_trigger, name='evltn trgr nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) evolution_trigger_name = EvolutionTriggerName.objects.create( @@ -1913,7 +1911,7 @@ class APIData(): return evolution_trigger_name @classmethod - def setup_evolution_chain_data(self, baby_trigger_item=None): + def setup_evolution_chain_data(cls, baby_trigger_item=None): evolution_chain = EvolutionChain.objects.create( baby_trigger_item=baby_trigger_item, @@ -1923,7 +1921,7 @@ class APIData(): return evolution_chain @classmethod - def setup_pokemon_evolution_data(self, evolved_species=None, evolution_trigger=None, + 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, @@ -1931,10 +1929,10 @@ class APIData(): min_affection=0, relative_physical_stats=0, needs_overworld_rain=False, turn_upside_down=False): - evolved_species = evolved_species or self.setup_pokemon_species_data( + evolved_species = evolved_species or cls.setup_pokemon_species_data( name='pkmn spcs for pkmn evltn') - evolution_trigger = evolution_trigger or self.setup_evolution_trigger_data( + evolution_trigger = evolution_trigger or cls.setup_evolution_trigger_data( name='evltn trgr for pkmn evltn') pokemon_evolution = PokemonEvolution.objects.create( @@ -1964,7 +1962,7 @@ class APIData(): # Encounter Data @classmethod - def setup_encounter_method_data(self, name='encntr mthd', order=0): + def setup_encounter_method_data(cls, name='encntr mthd', order=0): encounter_method = EncounterMethod.objects.create( name=name, @@ -1975,9 +1973,9 @@ class APIData(): return encounter_method @classmethod - def setup_encounter_method_name_data(self, encounter_method, name='encntr mthd nm'): + def setup_encounter_method_name_data(cls, encounter_method, name='encntr mthd nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) encounter_method_name = EncounterMethodName.objects.create( @@ -1990,7 +1988,7 @@ class APIData(): return encounter_method_name @classmethod - def setup_encounter_condition_data(self, name='encntr cndtn', order=0): + def setup_encounter_condition_data(cls, name='encntr cndtn'): encounter_condition = EncounterCondition.objects.create( name=name @@ -2000,9 +1998,9 @@ class APIData(): return encounter_condition @classmethod - def setup_encounter_condition_name_data(self, encounter_condition, name='encntr cndtn nm'): + def setup_encounter_condition_name_data(cls, encounter_condition, name='encntr cndtn nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) encounter_condition_name = EncounterConditionName.objects.create( @@ -2015,7 +2013,7 @@ class APIData(): return encounter_condition_name @classmethod - def setup_encounter_condition_value_data(self, encounter_condition, + def setup_encounter_condition_value_data(cls, encounter_condition, name='encntr cndtn vlu', is_default=False): encounter_condition_value = EncounterConditionValue.objects.create( @@ -2028,10 +2026,10 @@ class APIData(): return encounter_condition_value @classmethod - def setup_encounter_condition_value_name_data(self, encounter_condition_value, + def setup_encounter_condition_value_name_data(cls, encounter_condition_value, name='encntr cndtn vlu nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) encounter_condition_value_name = EncounterConditionValueName.objects.create( @@ -2044,7 +2042,7 @@ class APIData(): return encounter_condition_value_name @classmethod - def setup_encounter_condition_value_map_data(self, encounter, encounter_condition_value): + def setup_encounter_condition_value_map_data(cls, encounter, encounter_condition_value): encounter_condition_value_map = EncounterConditionValue.objects.create( encounter=encounter, @@ -2055,12 +2053,12 @@ class APIData(): return encounter_condition_value_map @classmethod - def setup_encounter_slot_data(self, encounter_method=None, slot=0, rarity=0): + def setup_encounter_slot_data(cls, encounter_method=None, slot=0, rarity=0): - encounter_method = encounter_method or self.setup_encounter_method_data( + encounter_method = encounter_method or cls.setup_encounter_method_data( name='encntr mthd for encntr slt') - version_group = self.setup_version_group_data( + version_group = cls.setup_version_group_data( name='ver grp for encntr slt') encounter_slot = EncounterSlot.objects.create( @@ -2074,9 +2072,9 @@ class APIData(): return encounter_slot @classmethod - def setup_location_area_encounter_rate_data(self, location_area, encounter_method, rate=0): + def setup_location_area_encounter_rate_data(cls, location_area, encounter_method, rate=0): - version = self.setup_version_data( + version = cls.setup_version_data( name='ver for lctn area') location_area_encounter_rate = LocationAreaEncounterRate.objects.create( @@ -2090,18 +2088,18 @@ class APIData(): return location_area_encounter_rate @classmethod - def setup_encounter_data(self, location_area=None, encounter_slot=None, + def setup_encounter_data(cls, location_area=None, encounter_slot=None, pokemon=None, version=None, min_level=10, max_level=15): - location_area = location_area or self.setup_location_area_data( + location_area = location_area or cls.setup_location_area_data( name='ver for encntr') - encounter_slot = encounter_slot or self.setup_encounter_slot_data() + encounter_slot = encounter_slot or cls.setup_encounter_slot_data() - pokemon = pokemon or self.setup_pokemon_data( + pokemon = pokemon or cls.setup_pokemon_data( name='pkmn for encntr') - version = version or self.setup_version_data( + version = version or cls.setup_version_data( name='ver for encntr') encounter = Encounter.objects.create( @@ -2118,7 +2116,7 @@ class APIData(): # Pal Park Data @classmethod - def setup_pal_park_area_data(self, name='pl prk area'): + def setup_pal_park_area_data(cls, name='pl prk area'): pal_park_area = PalParkArea.objects.create( name=name @@ -2128,9 +2126,9 @@ class APIData(): return pal_park_area @classmethod - def setup_pal_park_area_name_data(self, pal_park_area, name='pl prk area nm'): + def setup_pal_park_area_name_data(cls, pal_park_area, name='pl prk area nm'): - language = self.setup_language_data( + language = cls.setup_language_data( name='lang for ' + name) pal_park_area_name = PalParkAreaName.objects.create( @@ -2143,9 +2141,9 @@ class APIData(): return pal_park_area_name @classmethod - def setup_pal_park_data(self, pokemon_species=None, pal_park_area=None, base_score=10, rate=10): + def setup_pal_park_data(cls, pokemon_species=None, pal_park_area=None, base_score=10, rate=10): - pal_park_area = pal_park_area or self.setup_pal_park_area_data( + pal_park_area = pal_park_area or cls.setup_pal_park_area_data( name='pl prk area') pal_park = PalPark.objects.create( @@ -2161,11 +2159,7 @@ class APIData(): # Tests class APITests(APIData, APITestCase): - - """ - Gender Tests - """ - + # Gender Tests def test_gender_api(self): gender = self.setup_gender_data(name='female') @@ -2173,7 +2167,7 @@ class APITests(APIData, APITestCase): evolved_species = self.setup_pokemon_species_data(name='evlvd pkmn spcs for gndr') self.setup_pokemon_evolution_data(evolved_species=evolved_species, gender=gender) - response = self.client.get('{}/gender/{}/'.format(api_v2, gender.pk)) + response = self.client.get('{}/gender/{}/'.format(API_V2, gender.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2188,12 +2182,12 @@ class APITests(APIData, APITestCase): pokemon_species.name) self.assertEqual( response.data['pokemon_species_details'][0]['pokemon_species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, pokemon_species.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) self.assertEqual( response.data['required_for_evolution'][0]['name'], evolved_species.name) self.assertEqual( response.data['required_for_evolution'][0]['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, evolved_species.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, evolved_species.pk)) # Language Tests def test_language_api(self): @@ -2201,7 +2195,7 @@ class APITests(APIData, APITestCase): language = self.setup_language_data(name='base lang') language_name = self.setup_language_name_data(language, name='base lang name') - response = self.client.get('{}/language/{}/'.format(api_v2, language.pk)) + response = self.client.get('{}/language/{}/'.format(API_V2, language.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2217,7 +2211,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], language_name.local_language.name) self.assertEqual( response.data['names'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, language_name.local_language.pk)) + TEST_HOST, API_V2, language_name.local_language.pk)) # Region Tests def test_region_api(self): @@ -2230,7 +2224,7 @@ class APITests(APIData, APITestCase): version_group = self.setup_version_group_data(name="ver grp for base rgn") self.setup_version_group_region_data(region=region, version_group=version_group) - response = self.client.get('{}/region/{}/'.format(api_v2, region.pk)) + response = self.client.get('{}/region/{}/'.format(API_V2, region.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2242,27 +2236,27 @@ class APITests(APIData, APITestCase): self.assertEqual(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)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, region_name.language.pk)) # location params self.assertEqual(response.data['locations'][0]['name'], location.name) self.assertEqual( response.data['locations'][0]['url'], - '{}{}/location/{}/'.format(test_host, api_v2, location.pk)) + '{}{}/location/{}/'.format(TEST_HOST, API_V2, location.pk)) # generation params self.assertEqual(response.data['main_generation']['name'], generation.name) self.assertEqual( response.data['main_generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, generation.pk)) # pokedex params self.assertEqual(response.data['pokedexes'][0]['name'], pokedex.name) self.assertEqual( response.data['pokedexes'][0]['url'], - '{}{}/pokedex/{}/'.format(test_host, api_v2, pokedex.pk)) + '{}{}/pokedex/{}/'.format(TEST_HOST, API_V2, pokedex.pk)) # version group params self.assertEqual(response.data['version_groups'][0]['name'], version_group.name) self.assertEqual( response.data['version_groups'][0]['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version_group.pk)) # Generation Tests def test_generation_api(self): @@ -2277,7 +2271,7 @@ class APITests(APIData, APITestCase): version_group = self.setup_version_group_data( name='ver grp for base gen', generation=generation) - response = self.client.get('{}/generation/{}/'.format(api_v2, generation.pk)) + response = self.client.get('{}/generation/{}/'.format(API_V2, generation.pk)) # base params self.assertEqual(response.data['id'], generation.pk) @@ -2288,37 +2282,37 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], generation_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, generation_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, generation_name.language.pk)) # region params self.assertEqual(response.data['main_region']['name'], generation.region.name) self.assertEqual( response.data['main_region']['url'], - '{}{}/region/{}/'.format(test_host, api_v2, generation.region.pk)) + '{}{}/region/{}/'.format(TEST_HOST, API_V2, generation.region.pk)) # ability params self.assertEqual(response.data['abilities'][0]['name'], ability.name) self.assertEqual( response.data['abilities'][0]['url'], - '{}{}/ability/{}/'.format(test_host, api_v2, ability.pk)) + '{}{}/ability/{}/'.format(TEST_HOST, API_V2, ability.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( response.data['moves'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) # type params self.assertEqual(response.data['types'][0]['name'], type.name) self.assertEqual( response.data['types'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, type.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, type.pk)) # species params self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) # version group params self.assertEqual(response.data['version_groups'][0]['name'], version_group.name) self.assertEqual( response.data['version_groups'][0]['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version_group.pk)) # Version Tests def test_version_api(self): @@ -2327,7 +2321,7 @@ class APITests(APIData, APITestCase): version = self.setup_version_data(name='base ver', version_group=version_group) version_name = self.setup_version_name_data(version, name='base ver name') - response = self.client.get('{}/version/{}/'.format(api_v2, version.pk)) + response = self.client.get('{}/version/{}/'.format(API_V2, version.pk)) # base params self.assertEqual(response.data['id'], version.pk) @@ -2337,12 +2331,12 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], version_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, version_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, version_name.language.pk)) # version group params self.assertEqual(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)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version.version_group.pk)) def test_version_group_api(self): @@ -2356,7 +2350,7 @@ class APITests(APIData, APITestCase): pokedex = self.setup_pokedex_data(name='pkdx for base ver group') self.setup_pokedex_version_group_data(pokedex=pokedex, version_group=version_group) - response = self.client.get('{}/version-group/{}/'.format(api_v2, version_group.pk)) + response = self.client.get('{}/version-group/{}/'.format(API_V2, version_group.pk)) # base params self.assertEqual(response.data['id'], version_group.pk) @@ -2366,27 +2360,27 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['versions'][0]['name'], version.name) self.assertEqual( response.data['versions'][0]['url'], - '{}{}/version/{}/'.format(test_host, api_v2, version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, version.pk)) # generation params self.assertEqual(response.data['generation']['name'], version_group.generation.name) self.assertEqual( response.data['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, version_group.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, version_group.generation.pk)) # region params self.assertEqual(response.data['regions'][0]['name'], region.name) self.assertEqual( response.data['regions'][0]['url'], - '{}{}/region/{}/'.format(test_host, api_v2, region.pk)) + '{}{}/region/{}/'.format(TEST_HOST, API_V2, region.pk)) # move learn method params self.assertEqual(response.data['move_learn_methods'][0]['name'], move_learn_method.name) self.assertEqual( response.data['move_learn_methods'][0]['url'], - '{}{}/move-learn-method/{}/'.format(test_host, api_v2, move_learn_method.pk)) + '{}{}/move-learn-method/{}/'.format(TEST_HOST, API_V2, move_learn_method.pk)) # pokedex group self.assertEqual(response.data['pokedexes'][0]['name'], pokedex.name) self.assertEqual( response.data['pokedexes'][0]['url'], - '{}{}/pokedex/{}/'.format(test_host, api_v2, pokedex.pk)) + '{}{}/pokedex/{}/'.format(TEST_HOST, API_V2, pokedex.pk)) # Egg Group Tests def test_egg_group_api(self): @@ -2396,7 +2390,7 @@ class APITests(APIData, APITestCase): pokemon_species = self.setup_pokemon_species_data() self.setup_pokemon_egg_group_data(pokemon_species=pokemon_species, egg_group=egg_group) - response = self.client.get('{}/egg-group/{}/'.format(api_v2, egg_group.pk)) + response = self.client.get('{}/egg-group/{}/'.format(API_V2, egg_group.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2409,12 +2403,12 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], egg_group_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, egg_group_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, egg_group_name.language.pk)) # species params self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) # Ability Tests def test_ability_api(self): @@ -2430,7 +2424,7 @@ class APITests(APIData, APITestCase): pokemon = self.setup_pokemon_data(name='pkmn for ablty') pokemon_ability = self.setup_pokemon_ability_data(ability=ability, pokemon=pokemon) - response = self.client.get('{}/ability/{}/'.format(api_v2, ability.pk)) + response = self.client.get('{}/ability/{}/'.format(API_V2, ability.pk)) # base params self.assertEqual(response.data['id'], ability.pk) @@ -2441,7 +2435,7 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], ability_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, ability_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_name.language.pk)) # description params self.assertEqual(response.data['effect_entries'][0]['effect'], ability_effect_text.effect) self.assertEqual( @@ -2451,7 +2445,7 @@ class APITests(APIData, APITestCase): ability_effect_text.language.name) self.assertEqual( response.data['effect_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, ability_effect_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_effect_text.language.pk)) # flavor text params self.assertEqual( response.data['flavor_text_entries'][0]['flavor_text'], ability_flavor_text.flavor_text) @@ -2464,19 +2458,19 @@ class APITests(APIData, APITestCase): ability_flavor_text.language.name) self.assertEqual( response.data['flavor_text_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, ability_flavor_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_flavor_text.language.pk)) # generation params self.assertEqual(response.data['generation']['name'], ability.generation.name) self.assertEqual( response.data['generation']['url'], '{}{}/generation/{}/'.format( - test_host, api_v2, ability.generation.pk)) + TEST_HOST, API_V2, ability.generation.pk)) # change params self.assertEqual( response.data['effect_changes'][0]['version_group']['name'], ability_change.version_group.name) self.assertEqual( response.data['effect_changes'][0]['version_group']['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, ability_change.version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, ability_change.version_group.pk)) self.assertEqual( response.data['effect_changes'][0]['effect_entries'][0]['effect'], ability_change_effect_text.effect) @@ -2485,14 +2479,14 @@ class APITests(APIData, APITestCase): ability_change_effect_text.language.name) self.assertEqual( response.data['effect_changes'][0]['effect_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, ability_change_effect_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, ability_change_effect_text.language.pk)) # pokemon params self.assertEqual(response.data['pokemon'][0]['is_hidden'], pokemon_ability.is_hidden) self.assertEqual(response.data['pokemon'][0]['slot'], pokemon_ability.slot) self.assertEqual(response.data['pokemon'][0]['pokemon']['name'], pokemon.name) self.assertEqual( response.data['pokemon'][0]['pokemon']['url'], - '{}{}/pokemon/{}/'.format(test_host, api_v2, pokemon.pk)) + '{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk)) # Item Tests def test_item_attribute_api(self): @@ -2506,7 +2500,7 @@ class APITests(APIData, APITestCase): item = self.setup_item_data(name='itm fr base itm attr') self.setup_item_attribute_map_data(item_attribute=item_attribute, item=item) - response = self.client.get('{}/item-attribute/{}/'.format(api_v2, item_attribute.pk)) + response = self.client.get('{}/item-attribute/{}/'.format(API_V2, item_attribute.pk)) # base params self.assertEqual(response.data['id'], item_attribute.pk) @@ -2517,7 +2511,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], item_attribute_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_attribute_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_attribute_name.language.pk)) # description params self.assertEqual( response.data['descriptions'][0]['description'], item_attribute_description.description) @@ -2526,11 +2520,11 @@ class APITests(APIData, APITestCase): item_attribute_description.language.name) self.assertEqual( response.data['descriptions'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_attribute_description.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_attribute_description.language.pk)) # item params self.assertEqual(response.data['items'][0]['name'], item.name) self.assertEqual( - response.data['items'][0]['url'], '{}{}/item/{}/'.format(test_host, api_v2, item.pk)) + response.data['items'][0]['url'], '{}{}/item/{}/'.format(TEST_HOST, API_V2, item.pk)) def test_item_category_api(self): @@ -2540,7 +2534,7 @@ class APITests(APIData, APITestCase): item_category, name='base itm ctgry nm') item = self.setup_item_data(item_category=item_category, name='itm fr base itm ctgry') - response = self.client.get('{}/item-category/{}/'.format(api_v2, item_category.pk)) + response = self.client.get('{}/item-category/{}/'.format(API_V2, item_category.pk)) # base params self.assertEqual(response.data['id'], item_category.pk) @@ -2551,16 +2545,16 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], item_category_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_category_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_category_name.language.pk)) # pocket params self.assertEqual(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)) + '{}{}/item-pocket/{}/'.format(TEST_HOST, API_V2, item_category.item_pocket.pk)) # item params self.assertEqual(response.data['items'][0]['name'], item.name) self.assertEqual( - response.data['items'][0]['url'], '{}{}/item/{}/'.format(test_host, api_v2, item.pk)) + response.data['items'][0]['url'], '{}{}/item/{}/'.format(TEST_HOST, API_V2, item.pk)) def test_item_fling_effect_api(self): @@ -2571,7 +2565,7 @@ class APITests(APIData, APITestCase): item = self.setup_item_data( item_fling_effect=item_fling_effect, name='itm fr base itm attr') - response = self.client.get('{}/item-fling-effect/{}/'.format(api_v2, item_fling_effect.pk)) + response = self.client.get('{}/item-fling-effect/{}/'.format(API_V2, item_fling_effect.pk)) # base params self.assertEqual(response.data['id'], item_fling_effect.pk) @@ -2584,12 +2578,12 @@ class APITests(APIData, APITestCase): item_fling_effect_effect_text.language.name) self.assertEqual( response.data['effect_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_fling_effect_effect_text.language.pk) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_fling_effect_effect_text.language.pk) ) # item params self.assertEqual(response.data['items'][0]['name'], item.name) self.assertEqual( - response.data['items'][0]['url'], '{}{}/item/{}/'.format(test_host, api_v2, item.pk)) + response.data['items'][0]['url'], '{}{}/item/{}/'.format(TEST_HOST, API_V2, item.pk)) def test_item_pocket_api(self): @@ -2597,7 +2591,7 @@ class APITests(APIData, APITestCase): item_pocket = self.setup_item_pocket_data(name='base itm pkt') item_pocket_name = self.setup_item_pocket_name_data(item_pocket, name='base itm pkt nm') - response = self.client.get('{}/item-pocket/{}/'.format(api_v2, item_pocket.pk)) + response = self.client.get('{}/item-pocket/{}/'.format(API_V2, item_pocket.pk)) # base params self.assertEqual(response.data['id'], item_pocket.pk) @@ -2608,7 +2602,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], item_pocket_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_pocket_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_pocket_name.language.pk)) def test_item_api(self): @@ -2635,7 +2629,7 @@ class APITests(APIData, APITestCase): sprites_data = json.loads(item_sprites.sprites) - response = self.client.get('{}/item/{}/'.format(api_v2, item.pk), HTTP_HOST='testserver') + response = self.client.get('{}/item/{}/'.format(API_V2, item.pk), HTTP_HOST='testserver') # base params self.assertEqual(response.data['id'], item.pk) @@ -2647,7 +2641,7 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], item_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_name.language.pk)) # flavor text params self.assertEqual( response.data['flavor_text_entries'][0]['text'], item_flavor_text.flavor_text) @@ -2656,13 +2650,13 @@ class APITests(APIData, APITestCase): item_flavor_text.version_group.name) self.assertEqual( response.data['flavor_text_entries'][0]['version_group']['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, item_flavor_text.version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, item_flavor_text.version_group.pk)) self.assertEqual( response.data['flavor_text_entries'][0]['language']['name'], item_flavor_text.language.name) self.assertEqual( response.data['flavor_text_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_flavor_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_flavor_text.language.pk)) # effect text params self.assertEqual(response.data['effect_entries'][0]['effect'], item_effect_text.effect) self.assertEqual( @@ -2671,34 +2665,34 @@ class APITests(APIData, APITestCase): response.data['effect_entries'][0]['language']['name'], item_effect_text.language.name) self.assertEqual( response.data['effect_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, item_effect_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, item_effect_text.language.pk)) # category params self.assertEqual(response.data['category']['name'], item_category.name) self.assertEqual( response.data['category']['url'], - '{}{}/item-category/{}/'.format(test_host, api_v2, item_category.pk)) + '{}{}/item-category/{}/'.format(TEST_HOST, API_V2, item_category.pk)) # fling effect params self.assertEqual(response.data['fling_effect']['name'], item_fling_effect.name) self.assertEqual( response.data['fling_effect']['url'], - '{}{}/item-fling-effect/{}/'.format(test_host, api_v2, item_fling_effect.pk)) + '{}{}/item-fling-effect/{}/'.format(TEST_HOST, API_V2, item_fling_effect.pk)) # attribute params self.assertEqual(response.data['attributes'][0]['name'], item_attribute.name) self.assertEqual( response.data['attributes'][0]['url'], - '{}{}/item-attribute/{}/'.format(test_host, api_v2, item_attribute.pk)) + '{}{}/item-attribute/{}/'.format(TEST_HOST, API_V2, item_attribute.pk)) # game indices params self.assertEqual(response.data['game_indices'][0]['game_index'], item_game_index.game_index) self.assertEqual( response.data['game_indices'][0]['generation']['name'], item_game_index.generation.name) self.assertEqual( response.data['game_indices'][0]['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, item_game_index.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, item_game_index.generation.pk)) # held by params self.assertEqual(response.data['held_by_pokemon'][0]['pokemon']['name'], pokemon.name) self.assertEqual( response.data['held_by_pokemon'][0]['pokemon']['url'], - '{}{}/pokemon/{}/'.format(test_host, api_v2, pokemon.pk)) + '{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk)) self.assertEqual( response.data['held_by_pokemon'][0]['version_details'][0]['rarity'], pokemon_item.rarity) @@ -2707,15 +2701,15 @@ class APITests(APIData, APITestCase): pokemon_item.version.name) self.assertEqual( response.data['held_by_pokemon'][0]['version_details'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, pokemon_item.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_item.version.pk)) # baby trigger params self.assertEqual( response.data['baby_trigger_for']['url'], - '{}{}/evolution-chain/{}/'.format(test_host, api_v2, evolution_chain.pk)) + '{}{}/evolution-chain/{}/'.format(TEST_HOST, API_V2, evolution_chain.pk)) # sprites self.assertEqual( response.data['sprites']['default'], - '{}{}'.format(media_host, sprites_data['default'].replace('/media/', ''))) + '{}{}'.format(MEDIA_HOST, sprites_data['default'].replace('/media/', ''))) # Berry Tests def test_berry_firmness_api(self): @@ -2725,7 +2719,7 @@ class APITests(APIData, APITestCase): berry_firmness, name='base bry frmns nm') berry = self.setup_berry_data(berry_firmness=berry_firmness, name='bry for base frmns') - response = self.client.get('{}/berry-firmness/{}/'.format(api_v2, berry_firmness.pk)) + response = self.client.get('{}/berry-firmness/{}/'.format(API_V2, berry_firmness.pk)) # base params self.assertEqual(response.data['id'], berry_firmness.pk) @@ -2736,12 +2730,12 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], berry_firmness_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, berry_firmness_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, berry_firmness_name.language.pk)) # berry params self.assertEqual(response.data['berries'][0]['name'], berry.name) self.assertEqual( response.data['berries'][0]['url'], - '{}{}/berry/{}/'.format(test_host, api_v2, berry.pk)) + '{}{}/berry/{}/'.format(TEST_HOST, API_V2, berry.pk)) def test_berry_flavor_api(self): @@ -2751,7 +2745,7 @@ class APITests(APIData, APITestCase): berry_flavor_map = self.setup_berry_flavor_map_data( berry=berry, berry_flavor=berry_flavor, potency=50) - response = self.client.get('{}/berry-flavor/{}/'.format(api_v2, berry_flavor.pk)) + response = self.client.get('{}/berry-flavor/{}/'.format(API_V2, berry_flavor.pk)) # base params self.assertEqual(response.data['id'], berry_flavor.pk) @@ -2762,18 +2756,18 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], berry_flavor_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, berry_flavor_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, berry_flavor_name.language.pk)) # contest type params self.assertEqual(response.data['contest_type']['name'], berry_flavor.contest_type.name) self.assertEqual( response.data['contest_type']['url'], - '{}{}/contest-type/{}/'.format(test_host, api_v2, berry_flavor.contest_type.pk)) + '{}{}/contest-type/{}/'.format(TEST_HOST, API_V2, berry_flavor.contest_type.pk)) # berry params self.assertEqual(response.data['berries'][0]['potency'], berry_flavor_map.potency) self.assertEqual(response.data['berries'][0]['berry']['name'], berry.name) self.assertEqual( response.data['berries'][0]['berry']['url'], - '{}{}/berry/{}/'.format(test_host, api_v2, berry.pk)) + '{}{}/berry/{}/'.format(TEST_HOST, API_V2, berry.pk)) def test_berry_api(self): @@ -2782,7 +2776,7 @@ class APITests(APIData, APITestCase): 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) - response = self.client.get('{}/berry/{}/'.format(api_v2, berry.pk)) + response = self.client.get('{}/berry/{}/'.format(API_V2, berry.pk)) # base params self.assertEqual(response.data['id'], berry.pk) @@ -2797,23 +2791,23 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['firmness']['name'], berry.berry_firmness.name) self.assertEqual( response.data['firmness']['url'], - '{}{}/berry-firmness/{}/'.format(test_host, api_v2, berry.berry_firmness.pk)) + '{}{}/berry-firmness/{}/'.format(TEST_HOST, API_V2, berry.berry_firmness.pk)) # item params self.assertEqual(response.data['item']['name'], berry.item.name) self.assertEqual( response.data['item']['url'], - '{}{}/item/{}/'.format(test_host, api_v2, berry.item.pk)) + '{}{}/item/{}/'.format(TEST_HOST, API_V2, berry.item.pk)) # flavor params self.assertEqual(response.data['flavors'][0]['potency'], berry_flavor_map.potency) self.assertEqual(response.data['flavors'][0]['flavor']['name'], berry_flavor.name) self.assertEqual( response.data['flavors'][0]['flavor']['url'], - '{}{}/berry-flavor/{}/'.format(test_host, api_v2, berry_flavor.pk)) + '{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, berry_flavor.pk)) # natural gift type self.assertEqual(response.data['natural_gift_type']['name'], type.name) self.assertEqual( response.data['natural_gift_type']['url'], - '{}{}/type/{}/'.format(test_host, api_v2, type.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, type.pk)) # Growth Rate Tests def test_growth_rate_api(self): @@ -2833,7 +2827,7 @@ class APITests(APIData, APITestCase): ) experience.save() - response = self.client.get('{}/growth-rate/{}/'.format(api_v2, growth_rate.pk)) + response = self.client.get('{}/growth-rate/{}/'.format(API_V2, growth_rate.pk)) # base params self.assertEqual(response.data['id'], growth_rate.pk) @@ -2847,7 +2841,7 @@ class APITests(APIData, APITestCase): growth_rate_description.language.name) self.assertEqual( response.data['descriptions'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, growth_rate_description.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, growth_rate_description.language.pk)) # experience params self.assertEqual(response.data['levels'][0]['level'], experience.level) self.assertEqual(response.data['levels'][0]['experience'], experience.experience) @@ -2855,7 +2849,7 @@ class APITests(APIData, APITestCase): self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) # Location Tests def test_location_api(self): @@ -2864,7 +2858,7 @@ class APITests(APIData, APITestCase): 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) - response = self.client.get('{}/location/{}/'.format(api_v2, location.pk)) + response = self.client.get('{}/location/{}/'.format(API_V2, location.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2876,12 +2870,12 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], location_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, location_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, location_name.language.pk)) # region params self.assertEqual(response.data['region']['name'], location.region.name) self.assertEqual( response.data['region']['url'], - '{}{}/region/{}/'.format(test_host, api_v2, location.region.pk)) + '{}{}/region/{}/'.format(TEST_HOST, API_V2, location.region.pk)) # game indices params self.assertEqual( response.data['game_indices'][0]['game_index'], location_game_index.game_index) @@ -2890,7 +2884,7 @@ class APITests(APIData, APITestCase): location_game_index.generation.name) self.assertEqual( response.data['game_indices'][0]['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, location_game_index.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, location_game_index.generation.pk)) def test_location_area_api(self): @@ -2919,7 +2913,7 @@ class APITests(APIData, APITestCase): pokemon=pokemon2, location_area=location_area, encounter_slot=encounter_slot2, min_level=32, max_level=36) - response = self.client.get('{}/location-area/{}/'.format(api_v2, location_area.pk)) + response = self.client.get('{}/location-area/{}/'.format(API_V2, location_area.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -2933,19 +2927,19 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], location_area_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, location_area_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, location_area_name.language.pk)) # location params self.assertEqual(response.data['location']['name'], location.name) self.assertEqual( response.data['location']['url'], - '{}{}/location/{}/'.format(test_host, api_v2, location.pk)) + '{}{}/location/{}/'.format(TEST_HOST, API_V2, location.pk)) # encounter method params self.assertEqual( response.data['encounter_method_rates'][0]['encounter_method']['name'], encounter_method.name) self.assertEqual( response.data['encounter_method_rates'][0]['encounter_method']['url'], - '{}{}/encounter-method/{}/'.format(test_host, api_v2, encounter_method.pk)) + '{}{}/encounter-method/{}/'.format(TEST_HOST, API_V2, encounter_method.pk)) self.assertEqual( response.data['encounter_method_rates'][0]['version_details'][0]['rate'], location_area_encounter_rate.rate) @@ -2954,12 +2948,12 @@ class APITests(APIData, APITestCase): location_area_encounter_rate.version.name) self.assertEqual( response.data['encounter_method_rates'][0]['version_details'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, location_area_encounter_rate.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, location_area_encounter_rate.version.pk)) # encounter params self.assertEqual(response.data['pokemon_encounters'][0]['pokemon']['name'], pokemon1.name) self.assertEqual( response.data['pokemon_encounters'][0]['pokemon']['url'], - '{}{}/pokemon/{}/'.format(test_host, api_v2, pokemon1.pk)) + '{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon1.pk)) self.assertEqual( response.data['pokemon_encounters'][0]['version_details'][0]['max_chance'], encounter_slot1.rarity) @@ -2968,7 +2962,7 @@ class APITests(APIData, APITestCase): encounter1.version.name) self.assertEqual( response.data['pokemon_encounters'][0]['version_details'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, encounter1.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, encounter1.version.pk)) self.assertEqual( response.data['pokemon_encounters'][0].get( 'version_details')[0]['encounter_details'][0]['chance'], @@ -2981,12 +2975,12 @@ class APITests(APIData, APITestCase): 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)) + TEST_HOST, API_V2, encounter_slot1.encounter_method.pk)) self.assertEqual(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)) + '{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon2.pk)) self.assertEqual( response.data['pokemon_encounters'][1]['version_details'][0]['max_chance'], encounter_slot2.rarity) @@ -2995,7 +2989,7 @@ class APITests(APIData, APITestCase): encounter2.version.name) self.assertEqual( response.data['pokemon_encounters'][1]['version_details'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, encounter2.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, encounter2.version.pk)) self.assertEqual( response.data['pokemon_encounters'][1].get( 'version_details')[0]['encounter_details'][0]['chance'], @@ -3008,7 +3002,7 @@ class APITests(APIData, APITestCase): 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)) + TEST_HOST, API_V2, encounter_slot2.encounter_method.pk)) # Contest Tests def test_contest_type_api(self): @@ -3019,7 +3013,7 @@ class APITests(APIData, APITestCase): berry_flavor = self.setup_berry_flavor_data( name="bry for base cntst tp", contest_type=contest_type) - response = self.client.get('{}/contest-type/{}/'.format(api_v2, contest_type.pk)) + response = self.client.get('{}/contest-type/{}/'.format(API_V2, contest_type.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3032,12 +3026,12 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], contest_type_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, contest_type_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, contest_type_name.language.pk)) # berry params self.assertEqual(response.data['berry_flavor']['name'], berry_flavor.name) self.assertEqual( response.data['berry_flavor']['url'], - '{}{}/berry-flavor/{}/'.format(test_host, api_v2, berry_flavor.pk)) + '{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, berry_flavor.pk)) def test_contest_effect_api(self): @@ -3047,7 +3041,7 @@ class APITests(APIData, APITestCase): contest_effect_effect_text = self.setup_contest_effect_effect_text_data( contest_effect, effect='base cntst efct eftc txt') - response = self.client.get('{}/contest-effect/{}/'.format(api_v2, contest_effect.pk)) + response = self.client.get('{}/contest-effect/{}/'.format(API_V2, contest_effect.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3063,7 +3057,7 @@ class APITests(APIData, APITestCase): contest_effect_effect_text.language.name) self.assertEqual( response.data['effect_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, contest_effect_effect_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, contest_effect_effect_text.language.pk)) # flavor text params self.assertEqual( response.data['flavor_text_entries'][0]['flavor_text'], @@ -3073,7 +3067,7 @@ class APITests(APIData, APITestCase): contest_effect_flavor_text.language.name) self.assertEqual( response.data['flavor_text_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, contest_effect_flavor_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, contest_effect_flavor_text.language.pk)) def test_super_contest_effect_api(self): @@ -3084,7 +3078,7 @@ class APITests(APIData, APITestCase): name="mv for base spr cntst efct", super_contest_effect=super_contest_effect) response = self.client.get( - '{}/super-contest-effect/{}/'.format(api_v2, super_contest_effect.pk)) + '{}/super-contest-effect/{}/'.format(API_V2, super_contest_effect.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3101,12 +3095,12 @@ class APITests(APIData, APITestCase): self.assertEqual( response.data['flavor_text_entries'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, super_contest_effect_flavor_text.language.pk)) + TEST_HOST, API_V2, super_contest_effect_flavor_text.language.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( response.data['moves'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) # Type Tests def test_type_api(self): @@ -3168,7 +3162,7 @@ class APITests(APIData, APITestCase): ) double_damage_from_type_relation.save() - response = self.client.get('{}/type/{}/'.format(api_v2, type.pk)) + response = self.client.get('{}/type/{}/'.format(API_V2, type.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3180,67 +3174,67 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], type_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, type_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, type_name.language.pk)) # generation params self.assertEqual(response.data['generation']['name'], type.generation.name) self.assertEqual( response.data['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, type.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, type.generation.pk)) # damage class params self.assertEqual(response.data['move_damage_class']['name'], type.move_damage_class.name) self.assertEqual( response.data['move_damage_class']['url'], - '{}{}/move-damage-class/{}/'.format(test_host, api_v2, type.move_damage_class.pk)) + '{}{}/move-damage-class/{}/'.format(TEST_HOST, API_V2, type.move_damage_class.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( response.data['moves'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) # pokemon params self.assertEqual(response.data['pokemon'][0]['slot'], pokemon_type.slot) self.assertEqual(response.data['pokemon'][0]['pokemon']['name'], pokemon.name) self.assertEqual( response.data['pokemon'][0]['pokemon']['url'], - '{}{}/pokemon/{}/'.format(test_host, api_v2, pokemon.pk)) + '{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk)) # damage relations params self.assertEqual( response.data['damage_relations']['no_damage_to'][0]['name'], no_damage_to.name) self.assertEqual( response.data['damage_relations']['no_damage_to'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, no_damage_to.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, no_damage_to.pk)) self.assertEqual( response.data['damage_relations']['half_damage_to'][0]['name'], half_damage_to.name) self.assertEqual( response.data['damage_relations']['half_damage_to'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, half_damage_to.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, half_damage_to.pk)) self.assertEqual( response.data['damage_relations']['double_damage_to'][0]['name'], double_damage_to.name) self.assertEqual( response.data['damage_relations']['double_damage_to'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, double_damage_to.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, double_damage_to.pk)) self.assertEqual( response.data['damage_relations']['no_damage_from'][0]['name'], no_damage_from.name) self.assertEqual( response.data['damage_relations']['no_damage_from'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, no_damage_from.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, no_damage_from.pk)) self.assertEqual( response.data['damage_relations']['half_damage_from'][0]['name'], half_damage_from.name) self.assertEqual( response.data['damage_relations']['half_damage_from'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, half_damage_from.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, half_damage_from.pk)) self.assertEqual( response.data['damage_relations']['double_damage_from'][0]['name'], double_damage_from.name) self.assertEqual( response.data['damage_relations']['double_damage_from'][0]['url'], - '{}{}/type/{}/'.format(test_host, api_v2, double_damage_from.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, double_damage_from.pk)) # game indices params self.assertEqual(response.data['game_indices'][0]['game_index'], type_game_index.game_index) self.assertEqual( response.data['game_indices'][0]['generation']['name'], type_game_index.generation.name) self.assertEqual( response.data['game_indices'][0]['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, type_game_index.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, type_game_index.generation.pk)) # Pokedex Tests def test_pokedex_api(self): @@ -3253,7 +3247,7 @@ class APITests(APIData, APITestCase): dex_entry = self.setup_pokemon_dex_entry_data( pokedex=pokedex, pokemon_species=pokemon_species) - response = self.client.get('{}/pokedex/{}/'.format(api_v2, pokedex.pk)) + response = self.client.get('{}/pokedex/{}/'.format(API_V2, pokedex.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3266,7 +3260,7 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], pokedex_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokedex_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokedex_name.language.pk)) # descriptions params self.assertEqual( response.data['descriptions'][0]['description'], pokedex_description.description) @@ -3274,12 +3268,12 @@ class APITests(APIData, APITestCase): response.data['descriptions'][0]['language']['name'], pokedex_description.language.name) self.assertEqual( response.data['descriptions'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokedex_description.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokedex_description.language.pk)) # region params self.assertEqual(response.data['region']['name'], pokedex.region.name) self.assertEqual( response.data['region']['url'], - '{}{}/region/{}/'.format(test_host, api_v2, pokedex.region.pk)) + '{}{}/region/{}/'.format(TEST_HOST, API_V2, pokedex.region.pk)) # species params self.assertEqual( response.data['pokemon_entries'][0]['entry_number'], dex_entry.pokedex_number) @@ -3287,7 +3281,7 @@ class APITests(APIData, APITestCase): response.data['pokemon_entries'][0]['pokemon_species']['name'], pokemon_species.name) self.assertEqual( response.data['pokemon_entries'][0]['pokemon_species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, pokemon_species.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) # Move Tests def test_move_ailment_api(self): @@ -3298,7 +3292,7 @@ class APITests(APIData, APITestCase): move = self.setup_move_data(name='mv for base mv almnt') self.setup_move_meta_data(move=move, move_ailment=move_ailment) - response = self.client.get('{}/move-ailment/{}/'.format(api_v2, move_ailment.pk)) + response = self.client.get('{}/move-ailment/{}/'.format(API_V2, move_ailment.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3311,11 +3305,11 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], move_ailment_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_ailment_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_ailment_name.language.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( - response.data['moves'][0]['url'], '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) def test_move_battle_style_api(self): @@ -3323,7 +3317,7 @@ class APITests(APIData, APITestCase): move_battle_style_name = self.setup_move_battle_style_name_data( move_battle_style, name='base mv btl stl name') - response = self.client.get('{}/move-battle-style/{}/'.format(api_v2, move_battle_style.pk)) + response = self.client.get('{}/move-battle-style/{}/'.format(API_V2, move_battle_style.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3336,7 +3330,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], move_battle_style_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_battle_style_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_battle_style_name.language.pk)) def test_move_category_api(self): @@ -3346,7 +3340,7 @@ class APITests(APIData, APITestCase): move = self.setup_move_data(name='mv for base mv ctgry') self.setup_move_meta_data(move=move, move_category=move_category) - response = self.client.get('{}/move-category/{}/'.format(api_v2, move_category.pk)) + response = self.client.get('{}/move-category/{}/'.format(API_V2, move_category.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3361,11 +3355,11 @@ class APITests(APIData, APITestCase): move_category_description.language.name) self.assertEqual( response.data['descriptions'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_category_description.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_category_description.language.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( - response.data['moves'][0]['url'], '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) def test_move_damage_class_api(self): @@ -3377,7 +3371,7 @@ class APITests(APIData, APITestCase): move = self.setup_move_data( name='mv for base mv dmg cls', move_damage_class=move_damage_class) - response = self.client.get('{}/move-damage-class/{}/'.format(api_v2, move_damage_class.pk)) + response = self.client.get('{}/move-damage-class/{}/'.format(API_V2, move_damage_class.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3390,7 +3384,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], move_damage_class_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_damage_class_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_damage_class_name.language.pk)) # description params self.assertEqual( response.data['descriptions'][0]['description'], @@ -3401,11 +3395,11 @@ class APITests(APIData, APITestCase): self.assertEqual( response.data['descriptions'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, move_damage_class_description.language.pk)) + TEST_HOST, API_V2, move_damage_class_description.language.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( - response.data['moves'][0]['url'], '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) def test_move_learn_method_api(self): @@ -3418,7 +3412,7 @@ class APITests(APIData, APITestCase): self.setup_version_group_move_learn_method_data( version_group=version_group, move_learn_method=move_learn_method) - response = self.client.get('{}/move-learn-method/{}/'.format(api_v2, move_learn_method.pk)) + response = self.client.get('{}/move-learn-method/{}/'.format(API_V2, move_learn_method.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3431,7 +3425,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], move_learn_method_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_learn_method_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_learn_method_name.language.pk)) # description params self.assertEqual( response.data['descriptions'][0]['description'], @@ -3442,12 +3436,12 @@ class APITests(APIData, APITestCase): self.assertEqual( response.data['descriptions'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, move_learn_method_description.language.pk)) + TEST_HOST, API_V2, move_learn_method_description.language.pk)) # version group params self.assertEqual(response.data['version_groups'][0]['name'], version_group.name) self.assertEqual( response.data['version_groups'][0]['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, version_group.pk)) def test_move_target_api(self): @@ -3457,7 +3451,7 @@ class APITests(APIData, APITestCase): move_target, description='base mv trgt desc') move = self.setup_move_data(name='mv for base mv trgt', move_target=move_target) - response = self.client.get('{}/move-target/{}/'.format(api_v2, move_target.pk)) + response = self.client.get('{}/move-target/{}/'.format(API_V2, move_target.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3470,7 +3464,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], move_target_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_target_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_target_name.language.pk)) # description params self.assertEqual( response.data['descriptions'][0]['description'], move_target_description.description) @@ -3479,11 +3473,11 @@ class APITests(APIData, APITestCase): move_target_description.language.name) self.assertEqual( response.data['descriptions'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_target_description.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_target_description.language.pk)) # move params self.assertEqual(response.data['moves'][0]['name'], move.name) self.assertEqual( - response.data['moves'][0]['url'], '{}{}/move/{}/'.format(test_host, api_v2, move.pk)) + response.data['moves'][0]['url'], '{}{}/move/{}/'.format(TEST_HOST, API_V2, move.pk)) def test_move_api(self): @@ -3507,7 +3501,7 @@ class APITests(APIData, APITestCase): self.setup_super_contest_combo_data(before_move, move) move_flavor_text = self.setup_move_flavor_text_data(move, flavor_text='flvr text for move') - response = self.client.get('{}/move/{}/'.format(api_v2, move.pk)) + response = self.client.get('{}/move/{}/'.format(API_V2, move.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3524,47 +3518,47 @@ class APITests(APIData, APITestCase): self.assertEqual(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)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_name.language.pk)) # damage class params self.assertEqual(response.data['damage_class']['name'], move.move_damage_class.name) self.assertEqual( response.data['damage_class']['url'], - '{}{}/move-damage-class/{}/'.format(test_host, api_v2, move.move_damage_class.pk)) + '{}{}/move-damage-class/{}/'.format(TEST_HOST, API_V2, move.move_damage_class.pk)) # contest type params self.assertEqual(response.data['contest_type']['name'], move.contest_type.name) self.assertEqual( response.data['contest_type']['url'], - '{}{}/contest-type/{}/'.format(test_host, api_v2, move.contest_type.pk)) + '{}{}/contest-type/{}/'.format(TEST_HOST, API_V2, move.contest_type.pk)) # contest effect params self.assertEqual( response.data['contest_effect']['url'], - '{}{}/contest-effect/{}/'.format(test_host, api_v2, move.contest_effect.pk)) + '{}{}/contest-effect/{}/'.format(TEST_HOST, API_V2, move.contest_effect.pk)) # super contest effect params self.assertEqual( response.data['super_contest_effect']['url'], - '{}{}/super-contest-effect/{}/'.format(test_host, api_v2, move.super_contest_effect.pk)) + '{}{}/super-contest-effect/{}/'.format(TEST_HOST, API_V2, move.super_contest_effect.pk)) # generation params self.assertEqual(response.data['generation']['name'], move.generation.name) self.assertEqual( response.data['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, move.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, move.generation.pk)) # target params self.assertEqual(response.data['target']['name'], move.move_target.name) self.assertEqual( response.data['target']['url'], - '{}{}/move-target/{}/'.format(test_host, api_v2, move.move_target.pk)) + '{}{}/move-target/{}/'.format(TEST_HOST, API_V2, move.move_target.pk)) # type params self.assertEqual(response.data['type']['name'], move.type.name) self.assertEqual( response.data['type']['url'], - '{}{}/type/{}/'.format(test_host, api_v2, move.type.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, move.type.pk)) # stat change params self.assertEqual(response.data['stat_changes'][0]['change'], move_stat_change.change) self.assertEqual( response.data['stat_changes'][0]['stat']['name'], move_stat_change.stat.name) self.assertEqual( response.data['stat_changes'][0]['stat']['url'], - '{}{}/stat/{}/'.format(test_host, api_v2, move_stat_change.stat.pk)) + '{}{}/stat/{}/'.format(TEST_HOST, API_V2, move_stat_change.stat.pk)) # effect entries params self.assertEqual( response.data['effect_entries'][0]['effect'], move_effect_effect_text.effect) @@ -3576,7 +3570,7 @@ class APITests(APIData, APITestCase): move_effect_effect_text.language.name) self.assertEqual( response.data['effect_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_effect_effect_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_effect_effect_text.language.pk)) # meta data self.assertEqual(response.data['meta']['min_hits'], move_meta.min_hits) self.assertEqual(response.data['meta']['max_hits'], move_meta.max_hits) @@ -3592,34 +3586,34 @@ class APITests(APIData, APITestCase): self.assertEqual(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)) + '{}{}/move-ailment/{}/'.format(TEST_HOST, API_V2, move_meta.move_meta_ailment.pk)) # category params self.assertEqual( response.data['meta']['category']['name'], move_meta.move_meta_category.name) self.assertEqual( response.data['meta']['category']['url'], - '{}{}/move-category/{}/'.format(test_host, api_v2, move_meta.move_meta_category.pk)) + '{}{}/move-category/{}/'.format(TEST_HOST, API_V2, move_meta.move_meta_category.pk)) # combo params self.assertEqual( response.data['contest_combos']['normal']['use_before'][0]['name'], after_move.name) self.assertEqual( response.data['contest_combos']['normal']['use_before'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, after_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, after_move.pk)) self.assertEqual( response.data['contest_combos']['normal']['use_after'][0]['name'], before_move.name) self.assertEqual( response.data['contest_combos']['normal']['use_after'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, before_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, before_move.pk)) self.assertEqual( response.data['contest_combos']['super']['use_before'][0]['name'], after_move.name) self.assertEqual( response.data['contest_combos']['super']['use_before'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, after_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, after_move.pk)) self.assertEqual( response.data['contest_combos']['super']['use_after'][0]['name'], before_move.name) self.assertEqual( response.data['contest_combos']['super']['use_after'][0]['url'], - '{}{}/move/{}/'.format(test_host, api_v2, before_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, before_move.pk)) # change params self.assertEqual(response.data['past_values'][0]['accuracy'], move_change.accuracy) self.assertEqual(response.data['past_values'][0]['power'], move_change.power) @@ -3631,14 +3625,14 @@ class APITests(APIData, APITestCase): move_change.version_group.name) self.assertEqual( response.data['past_values'][0]['version_group']['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, move_change.version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, move_change.version_group.pk)) # effect changes self.assertEqual( response.data['effect_changes'][0]['version_group']['name'], move_effect_change.version_group.name) self.assertEqual( response.data['effect_changes'][0]['version_group']['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, move_effect_change.version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, move_effect_change.version_group.pk)) self.assertEqual( response.data['effect_changes'][0]['effect_entries'][0]['effect'], move_effect_change_effect_text.effect) @@ -3648,7 +3642,7 @@ class APITests(APIData, APITestCase): self.assertEqual( response.data['effect_changes'][0]['effect_entries'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, move_effect_change_effect_text.language.pk)) + TEST_HOST, API_V2, move_effect_change_effect_text.language.pk)) # flavor text params self.assertEqual( response.data['flavor_text_entries'][0]['flavor_text'], move_flavor_text.flavor_text) @@ -3657,13 +3651,13 @@ class APITests(APIData, APITestCase): move_flavor_text.language.name) self.assertEqual( response.data['flavor_text_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, move_flavor_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, move_flavor_text.language.pk)) self.assertEqual( response.data['flavor_text_entries'][0]['version_group']['name'], move_flavor_text.version_group.name) self.assertEqual( response.data['flavor_text_entries'][0]['version_group']['url'], - '{}{}/version-group/{}/'.format(test_host, api_v2, move_flavor_text.version_group.pk)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, move_flavor_text.version_group.pk)) # Stat Tests def test_stat_api(self): @@ -3680,7 +3674,7 @@ class APITests(APIData, APITestCase): decrease_nature = self.setup_nature_data(name="dcrs ntr for base stt", decreased_stat=stat) characteristic = self.setup_characteristic_data(stat=stat) - response = self.client.get('{}/stat/{}/'.format(api_v2, stat.pk)) + response = self.client.get('{}/stat/{}/'.format(API_V2, stat.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3694,23 +3688,23 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], stat_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, stat_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, stat_name.language.pk)) # move damage class params self.assertEqual(response.data['move_damage_class']['name'], stat.move_damage_class.name) self.assertEqual( response.data['move_damage_class']['url'], - '{}{}/move-damage-class/{}/'.format(test_host, api_v2, stat.move_damage_class.pk)) + '{}{}/move-damage-class/{}/'.format(TEST_HOST, API_V2, stat.move_damage_class.pk)) # nature params self.assertEqual( response.data['affecting_natures']['increase'][0]['name'], increase_nature.name) self.assertEqual( response.data['affecting_natures']['increase'][0]['url'], - '{}{}/nature/{}/'.format(test_host, api_v2, increase_nature.pk)) + '{}{}/nature/{}/'.format(TEST_HOST, API_V2, increase_nature.pk)) self.assertEqual( response.data['affecting_natures']['decrease'][0]['name'], decrease_nature.name) self.assertEqual( response.data['affecting_natures']['decrease'][0]['url'], - '{}{}/nature/{}/'.format(test_host, api_v2, decrease_nature.pk)) + '{}{}/nature/{}/'.format(TEST_HOST, API_V2, decrease_nature.pk)) # move params self.assertEqual( response.data['affecting_moves']['increase'][0]['change'], @@ -3719,7 +3713,7 @@ class APITests(APIData, APITestCase): response.data['affecting_moves']['increase'][0]['move']['name'], increase_move.name) self.assertEqual( response.data['affecting_moves']['increase'][0]['move']['url'], - '{}{}/move/{}/'.format(test_host, api_v2, increase_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, increase_move.pk)) self.assertEqual( response.data['affecting_moves']['decrease'][0]['change'], decrease_move_stat_change.change) @@ -3727,11 +3721,11 @@ class APITests(APIData, APITestCase): response.data['affecting_moves']['decrease'][0]['move']['name'], decrease_move.name) self.assertEqual( response.data['affecting_moves']['decrease'][0]['move']['url'], - '{}{}/move/{}/'.format(test_host, api_v2, decrease_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, decrease_move.pk)) # characteristics params self.assertEqual( response.data['characteristics'][0]['url'], - '{}{}/characteristic/{}/'.format(test_host, api_v2, characteristic.pk)) + '{}{}/characteristic/{}/'.format(TEST_HOST, API_V2, characteristic.pk)) def test_pokeathlon_stat_api(self): @@ -3739,7 +3733,7 @@ class APITests(APIData, APITestCase): pokeathlon_stat_name = self.setup_pokeathlon_stat_name_data( pokeathlon_stat, name='base pkathln stt name') - response = self.client.get('{}/pokeathlon-stat/{}/'.format(api_v2, pokeathlon_stat.pk)) + response = self.client.get('{}/pokeathlon-stat/{}/'.format(API_V2, pokeathlon_stat.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3752,7 +3746,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], pokeathlon_stat_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokeathlon_stat_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokeathlon_stat_name.language.pk)) # Characteristic Tests def test_characteristic_api(self): @@ -3761,7 +3755,7 @@ class APITests(APIData, APITestCase): characteristic_description = self.setup_characteristic_description_data( characteristic, description='base char desc') - response = self.client.get('{}/characteristic/{}/'.format(api_v2, characteristic.pk)) + response = self.client.get('{}/characteristic/{}/'.format(API_V2, characteristic.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3777,12 +3771,12 @@ class APITests(APIData, APITestCase): characteristic_description.language.name) self.assertEqual( response.data['descriptions'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, characteristic_description.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, characteristic_description.language.pk)) # stat params self.assertEqual(response.data['highest_stat']['name'], characteristic.stat.name) self.assertEqual( response.data['highest_stat']['url'], - '{}{}/stat/{}/'.format(test_host, api_v2, characteristic.stat.pk)) + '{}{}/stat/{}/'.format(TEST_HOST, API_V2, characteristic.stat.pk)) # Nature Tests def test_nature_api(self): @@ -3804,7 +3798,7 @@ class APITests(APIData, APITestCase): nature_battle_style_preference = self.setup_nature_battle_style_preference_data( nature=nature, move_battle_style=move_battle_style) - response = self.client.get('{}/nature/{}/'.format(api_v2, nature.pk)) + response = self.client.get('{}/nature/{}/'.format(API_V2, nature.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3816,25 +3810,25 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['names'][0]['language']['name'], nature_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, nature_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, nature_name.language.pk)) # stat params self.assertEqual(response.data['decreased_stat']['name'], decreased_stat.name) self.assertEqual( response.data['decreased_stat']['url'], - '{}{}/stat/{}/'.format(test_host, api_v2, decreased_stat.pk)) + '{}{}/stat/{}/'.format(TEST_HOST, API_V2, decreased_stat.pk)) self.assertEqual(response.data['increased_stat']['name'], increased_stat.name) self.assertEqual( response.data['increased_stat']['url'], - '{}{}/stat/{}/'.format(test_host, api_v2, increased_stat.pk)) + '{}{}/stat/{}/'.format(TEST_HOST, API_V2, increased_stat.pk)) # flavor params self.assertEqual(response.data['hates_flavor']['name'], hates_flavor.name) self.assertEqual( response.data['hates_flavor']['url'], - '{}{}/berry-flavor/{}/'.format(test_host, api_v2, hates_flavor.pk)) + '{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, hates_flavor.pk)) self.assertEqual(response.data['likes_flavor']['name'], likes_flavor.name) self.assertEqual( response.data['likes_flavor']['url'], - '{}{}/berry-flavor/{}/'.format(test_host, api_v2, likes_flavor.pk)) + '{}{}/berry-flavor/{}/'.format(TEST_HOST, API_V2, likes_flavor.pk)) # pokeathlon stat params self.assertEqual( response.data['pokeathlon_stat_changes'][0]['max_change'], @@ -3844,7 +3838,7 @@ class APITests(APIData, APITestCase): pokeathlon_stat.name) self.assertEqual( response.data['pokeathlon_stat_changes'][0]['pokeathlon_stat']['url'], - '{}{}/pokeathlon-stat/{}/'.format(test_host, api_v2, pokeathlon_stat.pk)) + '{}{}/pokeathlon-stat/{}/'.format(TEST_HOST, API_V2, pokeathlon_stat.pk)) # pokeathlon stat params self.assertEqual( response.data['move_battle_style_preferences'][0]['low_hp_preference'], @@ -3857,7 +3851,7 @@ class APITests(APIData, APITestCase): move_battle_style.name) self.assertEqual( response.data['move_battle_style_preferences'][0]['move_battle_style']['url'], - '{}{}/move-battle-style/{}/'.format(test_host, api_v2, move_battle_style.pk)) + '{}{}/move-battle-style/{}/'.format(TEST_HOST, API_V2, move_battle_style.pk)) # Pokemon Tests def test_pokemon_habitat_api(self): @@ -3868,7 +3862,7 @@ class APITests(APIData, APITestCase): pokemon_species = self.setup_pokemon_species_data( pokemon_habitat=pokemon_habitat, name='pkmn spcs for pkmn hbtt') - response = self.client.get('{}/pokemon-habitat/{}/'.format(api_v2, pokemon_habitat.pk)) + response = self.client.get('{}/pokemon-habitat/{}/'.format(API_V2, pokemon_habitat.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3881,12 +3875,12 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], pokemon_habitat_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_habitat_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_habitat_name.language.pk)) # species params self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) def test_pokemon_color_api(self): @@ -3896,7 +3890,7 @@ class APITests(APIData, APITestCase): pokemon_species = self.setup_pokemon_species_data( pokemon_color=pokemon_color, name='pkmn spcs for pkmn clr') - response = self.client.get('{}/pokemon-color/{}/'.format(api_v2, pokemon_color.pk)) + response = self.client.get('{}/pokemon-color/{}/'.format(API_V2, pokemon_color.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3909,12 +3903,12 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], pokemon_color_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_color_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_color_name.language.pk)) # species params self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) def test_pokemon_shape_api(self): @@ -3924,7 +3918,7 @@ class APITests(APIData, APITestCase): pokemon_species = self.setup_pokemon_species_data( pokemon_shape=pokemon_shape, name='pkmn spcs for pkmn shp') - response = self.client.get('{}/pokemon-shape/{}/'.format(api_v2, pokemon_shape.pk)) + response = self.client.get('{}/pokemon-shape/{}/'.format(API_V2, pokemon_shape.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -3937,7 +3931,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], pokemon_shape_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_shape_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_shape_name.language.pk)) # awesome name params self.assertEqual( response.data['awesome_names'][0]['awesome_name'], pokemon_shape_name.awesome_name) @@ -3945,12 +3939,12 @@ class APITests(APIData, APITestCase): response.data['awesome_names'][0]['language']['name'], pokemon_shape_name.language.name) self.assertEqual( response.data['awesome_names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_shape_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_shape_name.language.pk)) # species params self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) def test_pokemon_species_api(self): @@ -3978,7 +3972,7 @@ class APITests(APIData, APITestCase): self.setup_pokemon_sprites_data(pokemon) response = self.client.get( - '{}/pokemon-species/{}/'.format(api_v2, pokemon_species.pk), HTTP_HOST='testserver') + '{}/pokemon-species/{}/'.format(API_V2, pokemon_species.pk), HTTP_HOST='testserver') self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4000,63 +3994,63 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], pokemon_species_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_species_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_species_name.language.pk)) # growth rate params self.assertEqual(response.data['growth_rate']['name'], pokemon_species.growth_rate.name) self.assertEqual( response.data['growth_rate']['url'], - '{}{}/growth-rate/{}/'.format(test_host, api_v2, pokemon_species.growth_rate.pk)) + '{}{}/growth-rate/{}/'.format(TEST_HOST, API_V2, pokemon_species.growth_rate.pk)) # dex number params self.assertEqual( response.data['pokedex_numbers'][0]['entry_number'], dex_number.pokedex_number) self.assertEqual(response.data['pokedex_numbers'][0]['pokedex']['name'], pokedex.name) self.assertEqual( response.data['pokedex_numbers'][0]['pokedex']['url'], - '{}{}/pokedex/{}/'.format(test_host, api_v2, pokedex.pk)) + '{}{}/pokedex/{}/'.format(TEST_HOST, API_V2, pokedex.pk)) # egg group params self.assertEqual(response.data['egg_groups'][0]['name'], egg_group.name) self.assertEqual( response.data['egg_groups'][0]['url'], - '{}{}/egg-group/{}/'.format(test_host, api_v2, egg_group.pk)) + '{}{}/egg-group/{}/'.format(TEST_HOST, API_V2, egg_group.pk)) # generation params self.assertEqual(response.data['generation']['name'], pokemon_species.generation.name) self.assertEqual( response.data['generation']['url'], - '{}{}/generation/{}/'.format(test_host, api_v2, pokemon_species.generation.pk)) + '{}{}/generation/{}/'.format(TEST_HOST, API_V2, pokemon_species.generation.pk)) # color params self.assertEqual(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)) + '{}{}/pokemon-color/{}/'.format(TEST_HOST, API_V2, pokemon_species.pokemon_color.pk)) # shape params self.assertEqual(response.data['shape']['name'], pokemon_species.pokemon_shape.name) self.assertEqual( response.data['shape']['url'], - '{}{}/pokemon-shape/{}/'.format(test_host, api_v2, pokemon_species.pokemon_shape.pk)) + '{}{}/pokemon-shape/{}/'.format(TEST_HOST, API_V2, pokemon_species.pokemon_shape.pk)) # habitat params self.assertEqual(response.data['habitat']['name'], pokemon_species.pokemon_habitat.name) self.assertEqual( response.data['habitat']['url'], '{}{}/pokemon-habitat/{}/'.format( - test_host, api_v2, pokemon_species.pokemon_habitat.pk)) + TEST_HOST, API_V2, pokemon_species.pokemon_habitat.pk)) # evolves from params self.assertEqual(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)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, evolves_from_species.pk)) # genus params self.assertEqual(response.data['genera'][0]['genus'], pokemon_species_name.genus) self.assertEqual( response.data['genera'][0]['language']['name'], pokemon_species_name.language.name) self.assertEqual( response.data['genera'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_species_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_species_name.language.pk)) # pokemon varieties params self.assertEqual(response.data['varieties'][0]['is_default'], pokemon.is_default) self.assertEqual(response.data['varieties'][0]['pokemon']['name'], pokemon.name) self.assertEqual( response.data['varieties'][0]['pokemon']['url'], - '{}{}/pokemon/{}/'.format(test_host, api_v2, pokemon.pk)) + '{}{}/pokemon/{}/'.format(TEST_HOST, API_V2, pokemon.pk)) # form descriptions params self.assertEqual( response.data['form_descriptions'][0]['description'], @@ -4067,7 +4061,7 @@ class APITests(APIData, APITestCase): self.assertEqual( response.data['form_descriptions'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, pokemon_species_form_description.language.pk)) + TEST_HOST, API_V2, pokemon_species_form_description.language.pk)) # flavor text params self.assertEqual( response.data['flavor_text_entries'][0]['flavor_text'], @@ -4077,13 +4071,13 @@ class APITests(APIData, APITestCase): pokemon_species_flavor_text.language.name) self.assertEqual( response.data['flavor_text_entries'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pokemon_species_flavor_text.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pokemon_species_flavor_text.language.pk)) self.assertEqual( response.data['flavor_text_entries'][0]['version']['name'], pokemon_species_flavor_text.version.name) self.assertEqual( response.data['flavor_text_entries'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, pokemon_species_flavor_text.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_species_flavor_text.version.pk)) # pal park params self.assertEqual(response.data['pal_park_encounters'][0]['base_score'], pal_park.base_score) self.assertEqual(response.data['pal_park_encounters'][0]['rate'], pal_park.rate) @@ -4091,7 +4085,7 @@ class APITests(APIData, APITestCase): response.data['pal_park_encounters'][0]['area']['name'], pal_park.pal_park_area.name) self.assertEqual( response.data['pal_park_encounters'][0]['area']['url'], - '{}{}/pal-park-area/{}/'.format(test_host, api_v2, pal_park.pal_park_area.pk)) + '{}{}/pal-park-area/{}/'.format(TEST_HOST, API_V2, pal_park.pal_park_area.pk)) def test_pokemon_api(self): @@ -4131,7 +4125,7 @@ class APITests(APIData, APITestCase): location_area=location_area2, pokemon=pokemon, encounter_slot=encounter_slot2, min_level=32, max_level=36) response = self.client.get( - '{}/pokemon/{}/'.format(api_v2, pokemon.pk), HTTP_HOST='testserver') + '{}/pokemon/{}/'.format(API_V2, pokemon.pk), HTTP_HOST='testserver') sprites_data = json.loads(pokemon_sprites.sprites) @@ -4149,7 +4143,7 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['species']['name'], pokemon_species.name) self.assertEqual( response.data['species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, pokemon_species.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) # abilities params self.assertEqual(response.data['abilities'][0]['is_hidden'], pokemon_ability.is_hidden) self.assertEqual(response.data['abilities'][0]['slot'], pokemon_ability.slot) @@ -4157,25 +4151,25 @@ class APITests(APIData, APITestCase): response.data['abilities'][0]['ability']['name'], pokemon_ability.ability.name) self.assertEqual( response.data['abilities'][0]['ability']['url'], - '{}{}/ability/{}/'.format(test_host, api_v2, pokemon_ability.ability.pk)) + '{}{}/ability/{}/'.format(TEST_HOST, API_V2, pokemon_ability.ability.pk)) # stat params self.assertEqual(response.data['stats'][0]['base_stat'], pokemon_stat.base_stat) self.assertEqual(response.data['stats'][0]['effort'], pokemon_stat.effort) self.assertEqual(response.data['stats'][0]['stat']['name'], pokemon_stat.stat.name) self.assertEqual( response.data['stats'][0]['stat']['url'], - '{}{}/stat/{}/'.format(test_host, api_v2, pokemon_stat.stat.pk)) + '{}{}/stat/{}/'.format(TEST_HOST, API_V2, pokemon_stat.stat.pk)) # stat params self.assertEqual(response.data['types'][0]['slot'], pokemon_type.slot) self.assertEqual(response.data['types'][0]['type']['name'], pokemon_type.type.name) self.assertEqual( response.data['types'][0]['type']['url'], - '{}{}/type/{}/'.format(test_host, api_v2, pokemon_type.type.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, pokemon_type.type.pk)) # items params self.assertEqual(response.data['held_items'][0]['item']['name'], pokemon_item.item.name) self.assertEqual( response.data['held_items'][0]['item']['url'], - '{}{}/item/{}/'.format(test_host, api_v2, pokemon_item.item.pk)) + '{}{}/item/{}/'.format(TEST_HOST, API_V2, pokemon_item.item.pk)) self.assertEqual( response.data['held_items'][0]['version_details'][0]['rarity'], pokemon_item.rarity) self.assertEqual( @@ -4183,7 +4177,7 @@ class APITests(APIData, APITestCase): pokemon_item.version.name) self.assertEqual( response.data['held_items'][0]['version_details'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, pokemon_item.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_item.version.pk)) # 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) @@ -4197,8 +4191,8 @@ class APITests(APIData, APITestCase): self.assertEqual(expected, actual) # Move URL expected = '{}{}/move/{}/'.format( - test_host, - api_v2, + TEST_HOST, + API_V2, pokemon_moves[0].move.pk) actual = response.data['moves'][0]['move']['url'] self.assertEqual(expected, actual) @@ -4206,7 +4200,8 @@ class APITests(APIData, APITestCase): expected = len(pokemon_moves) actual = len(response.data['moves'][0]['version_group_details']) self.assertEqual(expected, actual) - for i in range(0, len(pokemon_moves)): + + for i, val in enumerate(pokemon_moves): #pylint: disable=unused-variable version = response.data['moves'][0]['version_group_details'][i] # Learn Level expected = pokemon_moves[i].level @@ -4218,8 +4213,8 @@ class APITests(APIData, APITestCase): self.assertEqual(expected, actual) # Version Group URL expected = '{}{}/version-group/{}/'.format( - test_host, - api_v2, + TEST_HOST, + API_V2, pokemon_moves[i].version_group.pk) actual = version['version_group']['url'] self.assertEqual(expected, actual) @@ -4229,8 +4224,8 @@ class APITests(APIData, APITestCase): self.assertEqual(expected, actual) # Learn Method URL expected = '{}{}/move-learn-method/{}/'.format( - test_host, - api_v2, + TEST_HOST, + API_V2, pokemon_moves[i].move_learn_method.pk) actual = version['move_learn_method']['url'] self.assertEqual(expected, actual) @@ -4243,16 +4238,16 @@ class APITests(APIData, APITestCase): pokemon_game_index.version.name) self.assertEqual( response.data['game_indices'][0]['version']['url'], - '{}{}/version/{}/'.format(test_host, api_v2, pokemon_game_index.version.pk)) + '{}{}/version/{}/'.format(TEST_HOST, API_V2, pokemon_game_index.version.pk)) # form params self.assertEqual(response.data['forms'][0]['name'], pokemon_form.name) self.assertEqual( response.data['forms'][0]['url'], - '{}{}/pokemon-form/{}/'.format(test_host, api_v2, pokemon_form.pk)) + '{}{}/pokemon-form/{}/'.format(TEST_HOST, API_V2, pokemon_form.pk)) # sprite params self.assertEqual( response.data['sprites']['front_default'], - '{}{}'.format(media_host, sprites_data['front_default'].replace('/media/', ''))) + '{}{}'.format(MEDIA_HOST, sprites_data['front_default'].replace('/media/', ''))) self.assertEqual(response.data['sprites']['back_default'], None) def test_pokemon_form_api(self): @@ -4265,7 +4260,7 @@ class APITests(APIData, APITestCase): sprites_data = json.loads(pokemon_form_sprites.sprites) response = self.client.get( - '{}/pokemon-form/{}/'.format(api_v2, pokemon_form.pk), HTTP_HOST='testserver') + '{}/pokemon-form/{}/'.format(API_V2, pokemon_form.pk), HTTP_HOST='testserver') self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4282,16 +4277,16 @@ class APITests(APIData, APITestCase): self.assertEqual(response.data['pokemon']['name'], pokemon.name) self.assertEqual( response.data['pokemon']['url'], '{}{}/pokemon/{}/'.format( - test_host, api_v2, pokemon.pk)) + TEST_HOST, API_V2, pokemon.pk)) # version group params self.assertEqual(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)) + '{}{}/version-group/{}/'.format(TEST_HOST, API_V2, pokemon_form.version_group.pk)) # sprite params self.assertEqual( response.data['sprites']['front_default'], - '{}{}'.format(media_host, sprites_data['front_default'].replace('/media/', ''))) + '{}{}'.format(MEDIA_HOST, sprites_data['front_default'].replace('/media/', ''))) self.assertEqual(response.data['sprites']['back_default'], None) # Evolution test @@ -4305,7 +4300,7 @@ class APITests(APIData, APITestCase): self.setup_pokemon_evolution_data( evolved_species=pokemon_species, evolution_trigger=evolution_trigger) - response = self.client.get('{}/evolution-trigger/{}/'.format(api_v2, evolution_trigger.pk)) + response = self.client.get('{}/evolution-trigger/{}/'.format(API_V2, evolution_trigger.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4318,12 +4313,12 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], evolution_trigger_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, evolution_trigger_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, evolution_trigger_name.language.pk)) # pokemon species params self.assertEqual(response.data['pokemon_species'][0]['name'], pokemon_species.name) self.assertEqual( response.data['pokemon_species'][0]['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, pokemon_species.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) def test_evolution_chain_api(self): @@ -4360,7 +4355,7 @@ class APITests(APIData, APITestCase): stage_two_second_evolution = self.setup_pokemon_evolution_data( evolved_species=stage_two_second, min_level=32, party_type=stage_two_second_party_type) - response = self.client.get('{}/evolution-chain/{}/'.format(api_v2, evolution_chain.pk)) + response = self.client.get('{}/evolution-chain/{}/'.format(API_V2, evolution_chain.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4376,44 +4371,44 @@ class APITests(APIData, APITestCase): self.assertEqual(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)) + '{}{}/item/{}/'.format(TEST_HOST, API_V2, baby_trigger_item.pk)) # baby params self.assertEqual(baby_data['is_baby'], baby.is_baby) self.assertEqual(baby_data['species']['name'], baby.name) self.assertEqual( baby_data['species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, baby.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, baby.pk)) # basic params self.assertEqual(basic_data['is_baby'], basic.is_baby) self.assertEqual(basic_data['species']['name'], basic.name) self.assertEqual( basic_data['species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, basic.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, basic.pk)) self.assertEqual(basic_data['evolution_details'][0]['min_level'], basic_evolution.min_level) self.assertEqual( basic_data['evolution_details'][0]['location']['name'], basic_location.name) self.assertEqual( basic_data['evolution_details'][0]['location']['url'], - '{}{}/location/{}/'.format(test_host, api_v2, basic_location.pk)) + '{}{}/location/{}/'.format(TEST_HOST, API_V2, basic_location.pk)) # stage one params self.assertEqual(stage_one_data['is_baby'], stage_one.is_baby) self.assertEqual(stage_one_data['species']['name'], stage_one.name) self.assertEqual( stage_one_data['species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, stage_one.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, stage_one.pk)) self.assertEqual( stage_one_data['evolution_details'][0]['min_level'], stage_one_evolution.min_level) self.assertEqual( stage_one_data['evolution_details'][0]['held_item']['name'], stage_one_held_item.name) self.assertEqual( stage_one_data['evolution_details'][0]['held_item']['url'], - '{}{}/item/{}/'.format(test_host, api_v2, stage_one_held_item.pk)) + '{}{}/item/{}/'.format(TEST_HOST, API_V2, stage_one_held_item.pk)) # stage two first params self.assertEqual(stage_two_first_data['is_baby'], stage_two_first.is_baby) self.assertEqual(stage_two_first_data['species']['name'], stage_two_first.name) self.assertEqual( stage_two_first_data['species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, stage_two_first.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, stage_two_first.pk)) self.assertEqual( stage_two_first_data['evolution_details'][0]['min_level'], stage_two_first_evolution.min_level) @@ -4422,13 +4417,13 @@ class APITests(APIData, APITestCase): stage_two_first_known_move.name) self.assertEqual( stage_two_first_data['evolution_details'][0]['known_move']['url'], - '{}{}/move/{}/'.format(test_host, api_v2, stage_two_first_known_move.pk)) + '{}{}/move/{}/'.format(TEST_HOST, API_V2, stage_two_first_known_move.pk)) # stage two second params self.assertEqual(stage_two_second_data['is_baby'], stage_two_second.is_baby) self.assertEqual(stage_two_second_data['species']['name'], stage_two_second.name) self.assertEqual( stage_two_second_data['species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, stage_two_second.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, stage_two_second.pk)) self.assertEqual( stage_two_second_data['evolution_details'][0]['min_level'], stage_two_second_evolution.min_level) @@ -4437,7 +4432,7 @@ class APITests(APIData, APITestCase): stage_two_second_party_type.name) self.assertEqual( stage_two_second_data['evolution_details'][0]['party_type']['url'], - '{}{}/type/{}/'.format(test_host, api_v2, stage_two_second_party_type.pk)) + '{}{}/type/{}/'.format(TEST_HOST, API_V2, stage_two_second_party_type.pk)) # Encounter Tests def test_encounter_method_api(self): @@ -4446,7 +4441,7 @@ class APITests(APIData, APITestCase): encounter_method_name = self.setup_encounter_method_name_data( encounter_method, name='base encntr mthd name') - response = self.client.get('{}/encounter-method/{}/'.format(api_v2, encounter_method.pk)) + response = self.client.get('{}/encounter-method/{}/'.format(API_V2, encounter_method.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4460,7 +4455,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], encounter_method_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, encounter_method_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, encounter_method_name.language.pk)) def test_encounter_condition_value_api(self): @@ -4472,7 +4467,7 @@ class APITests(APIData, APITestCase): encounter_condition_value, name='base encntr cndtn vlu name') response = self.client.get('{}/encounter-condition-value/{}/'.format( - api_v2, encounter_condition_value.pk)) + API_V2, encounter_condition_value.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4487,12 +4482,12 @@ class APITests(APIData, APITestCase): self.assertEqual( response.data['names'][0]['language']['url'], '{}{}/language/{}/'.format( - test_host, api_v2, encounter_condition_value_name.language.pk)) + TEST_HOST, API_V2, encounter_condition_value_name.language.pk)) # condition params self.assertEqual(response.data['condition']['name'], encounter_condition.name) self.assertEqual( response.data['condition']['url'], - '{}{}/encounter-condition/{}/'.format(test_host, api_v2, encounter_condition.pk)) + '{}{}/encounter-condition/{}/'.format(TEST_HOST, API_V2, encounter_condition.pk)) def test_encounter_condition_api(self): @@ -4503,7 +4498,7 @@ class APITests(APIData, APITestCase): encounter_condition, name='encntr cndtn vlu for base encntr', is_default=True) response = self.client.get( - '{}/encounter-condition/{}/'.format(api_v2, encounter_condition.pk)) + '{}/encounter-condition/{}/'.format(API_V2, encounter_condition.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4516,13 +4511,13 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], encounter_condition_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, encounter_condition_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, encounter_condition_name.language.pk)) # value params self.assertEqual(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)) + TEST_HOST, API_V2, encounter_condition_value.pk)) # Pal Park Tests def test_pal_park_area_api(self): @@ -4534,7 +4529,7 @@ class APITests(APIData, APITestCase): pal_park = self.setup_pal_park_data( pal_park_area=pal_park_area, pokemon_species=pokemon_species, base_score=10, rate=20) - response = self.client.get('{}/pal-park-area/{}/'.format(api_v2, pal_park_area.pk)) + response = self.client.get('{}/pal-park-area/{}/'.format(API_V2, pal_park_area.pk)) self.assertEqual(response.status_code, status.HTTP_200_OK) @@ -4547,7 +4542,7 @@ class APITests(APIData, APITestCase): response.data['names'][0]['language']['name'], pal_park_area_name.language.name) self.assertEqual( response.data['names'][0]['language']['url'], - '{}{}/language/{}/'.format(test_host, api_v2, pal_park_area_name.language.pk)) + '{}{}/language/{}/'.format(TEST_HOST, API_V2, pal_park_area_name.language.pk)) # encounter params self.assertEqual(response.data['pokemon_encounters'][0]['base_score'], pal_park.base_score) self.assertEqual(response.data['pokemon_encounters'][0]['rate'], pal_park.rate) @@ -4555,4 +4550,4 @@ class APITests(APIData, APITestCase): response.data['pokemon_encounters'][0]['pokemon_species']['name'], pokemon_species.name) self.assertEqual( response.data['pokemon_encounters'][0]['pokemon_species']['url'], - '{}{}/pokemon-species/{}/'.format(test_host, api_v2, pokemon_species.pk)) + '{}{}/pokemon-species/{}/'.format(TEST_HOST, API_V2, pokemon_species.pk)) diff --git a/pokemon_v2/urls.py b/pokemon_v2/urls.py index 4116881f..4e6c71af 100644 --- a/pokemon_v2/urls.py +++ b/pokemon_v2/urls.py @@ -7,7 +7,9 @@ from django.conf.urls import include, url ##################################### from rest_framework import routers -from pokemon_v2.api import * # NOQA +from pokemon_v2.api import * + +# pylint: disable=invalid-name router = routers.DefaultRouter()