mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +00:00
Use new JSON field in Django instead of Postgres custom one
This commit is contained in:
parent
8f716cdbf0
commit
d1e2d9c5b4
3 changed files with 24 additions and 4 deletions
18
pokemon_v2/migrations/0015_auto_20231121_1209.py
Normal file
18
pokemon_v2/migrations/0015_auto_20231121_1209.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.1.14 on 2023-11-21 12:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0014_auto_20231119_0303'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='pokemonsprites',
|
||||
name='sprites',
|
||||
field=models.JSONField(),
|
||||
),
|
||||
]
|
|
@ -1,5 +1,4 @@
|
|||
from django.db import models
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
|
||||
#####################
|
||||
# ABSTRACT MODELS #
|
||||
|
@ -1796,4 +1795,4 @@ class PokemonTypePast(HasPokemon, HasType, HasGeneration):
|
|||
|
||||
|
||||
class PokemonSprites(HasPokemon):
|
||||
sprites = JSONField()
|
||||
sprites = models.JSONField()
|
||||
|
|
|
@ -5024,12 +5024,15 @@ class APITests(APIData, APITestCase):
|
|||
response.data["forms"][0]["url"],
|
||||
"{}{}/pokemon-form/{}/".format(TEST_HOST, API_V2, pokemon_form.pk),
|
||||
)
|
||||
|
||||
sprite_response = json.loads(response.data["sprites"])
|
||||
|
||||
# sprite params
|
||||
self.assertEqual(
|
||||
response.data["sprites"]["front_default"],
|
||||
sprite_response["front_default"],
|
||||
"{}".format(sprites_data["front_default"]),
|
||||
)
|
||||
self.assertEqual(response.data["sprites"]["back_default"], None)
|
||||
self.assertEqual(sprite_response["back_default"], None)
|
||||
|
||||
def test_pokemon_form_api(self):
|
||||
pokemon_species = self.setup_pokemon_species_data()
|
||||
|
|
Loading…
Reference in a new issue