Updating PokemonSpecies serializer, fields, tests

This commit is contained in:
Raghav Nair 2020-08-09 12:35:45 -07:00
parent 38b51c90fe
commit 99dabe387c
4 changed files with 22 additions and 1 deletions

View file

@ -1278,7 +1278,10 @@ def _build_pokemons():
has_gender_differences=bool(int(info[13])),
growth_rate_id=int(info[14]),
forms_switchable=bool(int(info[15])),
order=int(info[16]),
is_legendary=bool(int(info[16])),
is_mythical=bool(int(info[17])),
is_ultra_beast=bool(int(info[18])),
order=int(info[19]),
)
build_generic((PokemonSpecies,), "pokemon_species.csv", csv_record_to_objects)

View file

@ -1635,6 +1635,12 @@ class PokemonSpecies(
is_baby = models.BooleanField(default=False)
is_legendary = models.BooleanField(default=False)
is_mythical = models.BooleanField(default=False)
is_ultra_beast = models.BooleanField(default=False)
hatch_counter = models.IntegerField()
has_gender_differences = models.BooleanField(default=False)

View file

@ -2984,6 +2984,9 @@ class PokemonSpeciesDetailSerializer(serializers.ModelSerializer):
"capture_rate",
"base_happiness",
"is_baby",
"is_legendary",
"is_mythical",
"is_ultra_beast",
"hatch_counter",
"has_gender_differences",
"forms_switchable",

View file

@ -1462,6 +1462,9 @@ class APIData:
hatch_counter=10,
has_gender_differences=True,
forms_switchable=False,
is_legendary=False,
is_mythical=False,
is_ultra_beast=False,
order=1,
):
@ -1499,6 +1502,9 @@ class APIData:
has_gender_differences=has_gender_differences,
growth_rate=growth_rate,
forms_switchable=forms_switchable,
is_legendary=is_legendary,
is_mythical=is_mythical,
is_ultra_beast=is_ultra_beast,
order=order,
)
pokemon_species.save()
@ -4560,6 +4566,9 @@ class APITests(APIData, APITestCase):
response.data["base_happiness"], pokemon_species.base_happiness
)
self.assertEqual(response.data["is_baby"], pokemon_species.is_baby)
self.assertEqual(response.data["is_legendary"], pokemon_species.is_legendary)
self.assertEqual(response.data["is_mythical"], pokemon_species.is_mythical)
self.assertEqual(response.data["is_ultra_beast"], pokemon_species.is_ultra_beast)
self.assertEqual(response.data["hatch_counter"], pokemon_species.hatch_counter)
self.assertEqual(
response.data["has_gender_differences"],