From 21650a4b64354417b908dd43cae1c13988730faf Mon Sep 17 00:00:00 2001 From: Jonathan Rubin Date: Fri, 20 Apr 2018 22:55:56 -0400 Subject: [PATCH 1/2] dictionary from encounters subresource (#332) This makes it consistent with the every other resource Unfortunately this isn't tested or testable in the current framework, as distinct() is not supported by the sqlite3 backend --- pokemon_v2/api.py | 2 +- pokemon_v2/tests.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pokemon_v2/api.py b/pokemon_v2/api.py index 865792373..404d96fe8 100644 --- a/pokemon_v2/api.py +++ b/pokemon_v2/api.py @@ -487,4 +487,4 @@ def get(self, request, pokemon_id): 'version_details': version_details_list }) - return Response(encounters_list) + return Response({'results': encounters_list}) diff --git a/pokemon_v2/tests.py b/pokemon_v2/tests.py index 2c33f7937..24e17d1b9 100644 --- a/pokemon_v2/tests.py +++ b/pokemon_v2/tests.py @@ -4250,6 +4250,14 @@ def test_pokemon_api(self): self.assertEqual( response.data['forms'][0]['url'], '{}{}/pokemon-form/{}/'.format(test_host, api_v2, pokemon_form.pk)) + # encounters parameters + self.assertEqual( + response.data['location_area_encounters'], + '{}/pokemon/{}/encounters'.format(api_v2, response.data['id'])) + # Can't do this because sqlite doesn't support distinct() + # which is used by the API call + #encounters_response= self.client.get( + # '{}/pokemon/{}/encounters'.format(api_v2, pokemon.pk), HTTP_HOST='testserver') # sprite params self.assertEqual( response.data['sprites']['front_default'], From f882b5aa2c37649b76980bd0ac71c7703d20e8d7 Mon Sep 17 00:00:00 2001 From: Jonathan Rubin Date: Mon, 23 Apr 2018 21:31:37 -0400 Subject: [PATCH 2/2] Make lint happy --- pokemon_v2/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemon_v2/tests.py b/pokemon_v2/tests.py index 24e17d1b9..5ff94273c 100644 --- a/pokemon_v2/tests.py +++ b/pokemon_v2/tests.py @@ -4256,7 +4256,7 @@ def test_pokemon_api(self): '{}/pokemon/{}/encounters'.format(api_v2, response.data['id'])) # Can't do this because sqlite doesn't support distinct() # which is used by the API call - #encounters_response= self.client.get( + # encounters_response= self.client.get( # '{}/pokemon/{}/encounters'.format(api_v2, pokemon.pk), HTTP_HOST='testserver') # sprite params self.assertEqual(