Use new JSON field in Django instead of Postgres custom one

This commit is contained in:
Simón Oroño 2023-11-23 06:59:12 -04:00 committed by Simón Oroño
parent 8f716cdbf0
commit d1e2d9c5b4
3 changed files with 24 additions and 4 deletions

View 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(),
),
]

View file

@ -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()

View file

@ -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()