Skip to content

Commit

Permalink
Fix tests for sprites
Browse files Browse the repository at this point in the history
Moved the declaration of sprite_data variables closer to their actual
usage.
  • Loading branch information
simonorono committed Nov 26, 2023
1 parent 61c2185 commit b3d6608
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pokemon_v2/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,8 +2588,6 @@ def test_item_api(self):
item_attribute_map = ItemAttributeMap(item=item, item_attribute=item_attribute)
item_attribute_map.save()

sprites_data = json.loads(item_sprites.sprites)

response = self.client.get(
"{}/item/{}/".format(API_V2, item.pk), HTTP_HOST="testserver"
)
Expand Down Expand Up @@ -2708,9 +2706,12 @@ def test_item_api(self):
response.data["baby_trigger_for"]["url"],
"{}{}/evolution-chain/{}/".format(TEST_HOST, API_V2, evolution_chain.pk),
)

sprites_data = json.loads(response.data["sprites"])

# sprites
self.assertEqual(
response.data["sprites"]["default"],
sprites_data["default"],
"{}".format(sprites_data["default"]),
)

Expand Down Expand Up @@ -4837,8 +4838,6 @@ def test_pokemon_api(self):
"{}/pokemon/{}/".format(API_V2, pokemon.pk), HTTP_HOST="testserver"
)

sprites_data = json.loads(pokemon_sprites.sprites)

self.assertEqual(response.status_code, status.HTTP_200_OK)

# base params
Expand Down Expand Up @@ -5025,14 +5024,14 @@ def test_pokemon_api(self):
"{}{}/pokemon-form/{}/".format(TEST_HOST, API_V2, pokemon_form.pk),
)

sprite_response = json.loads(response.data["sprites"])
sprites_data = json.loads(pokemon_sprites.sprites)

# sprite params
self.assertEqual(
sprite_response["front_default"],
sprites_data["front_default"],
"{}".format(sprites_data["front_default"]),
)
self.assertEqual(sprite_response["back_default"], None)
self.assertEqual(sprites_data["back_default"], None)

def test_pokemon_form_api(self):
pokemon_species = self.setup_pokemon_species_data()
Expand All @@ -5043,8 +5042,6 @@ def test_pokemon_form_api(self):
pokemon_form_sprites = self.setup_pokemon_form_sprites_data(pokemon_form)
pokemon_form_type = self.setup_pokemon_form_type_data(pokemon_form)

sprites_data = json.loads(pokemon_form_sprites.sprites)

response = self.client.get(
"{}/pokemon-form/{}/".format(API_V2, pokemon_form.pk),
HTTP_HOST="testserver",
Expand Down Expand Up @@ -5077,12 +5074,15 @@ def test_pokemon_form_api(self):
TEST_HOST, API_V2, pokemon_form.version_group.pk
),
)

sprites_data = json.loads(pokemon_form_sprites.sprites)

# sprite params
self.assertEqual(
response.data["sprites"]["front_default"],
sprites_data["front_default"],
"{}".format(sprites_data["front_default"]),
)
self.assertEqual(response.data["sprites"]["back_default"], None)
self.assertEqual(sprites_data["back_default"], None)
# type params
self.assertEqual(response.data["types"][0]["slot"], pokemon_form_type.slot)
self.assertEqual(
Expand Down

0 comments on commit b3d6608

Please sign in to comment.