-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix serializer index errors issue #1313 #1314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ata in specific rows to ensure consistency.
Fix: Removed regional restrictions so Rattata can evolve into Raticate in any region
- Updated `LocationAreaDetailSerializer` and `PokemonDetailSerializer` to order version and method objects by ID. - Created mappings from version and method IDs to their serialized data for improved clarity and efficiency in data access.
|
@Naramsim This is simply to fix the issue with two tests and think it should go before the PR for the evolution chain metadata addition of locked regions. |
|
@Naramsim I'm sure you are busy, are there other maintainers? |
|
@Naramsim, this PR is now ready for merge. I have fast-forwarded the branch with the latest master changes, and all tests are passing. The two broken tests that were originally failing have been resolved. The changes are minimal and focused specifically on the serializer index error fixes. Could you please review and merge when convenient? |
|
Yes, @Naramsim there were issues with the regional pokemon evolutions, but that was my lack of understanding the build process and the limitations where regional variants aren't included in the evolution chain because they are not their own species. Those errors are on me. |
…ion IDs - Implemented `test_location_area_api_with_non_sequential_version_ids` to ensure the location area API handles non-sequential version IDs correctly, addressing the IndexError from issue PokeAPI#1313. - Added `test_pokemon_api_with_non_sequential_ids` to verify the pokemon API functions properly with non-sequential version group and method IDs, also related to issue PokeAPI#1313.
|
Closing due to a lack of interest |
Issue 1: IndexError in test_location_area_api
#1313
Problem
The
test_location_area_apitest was failing with anIndexError: list index out of rangeerror in theget_encountersmethod ofLocationAreaDetailSerializer.Root Cause
The serializer was trying to access version data using array indexing (
version_data[ver["version"] - 1]), but theversion_dataarray was not ordered by ID. The code assumed that version IDs were sequential and that array indexicorresponded to version IDi+1, but this wasn't guaranteed.Error Details
Solution
get_encountersmethod to order Version objects by IDversion_data_map[ver["version"]]Code Changes
Issue 2: IndexError in test_pokemon_api
Problem
The
test_pokemon_apitest was failing with anIndexError: list index out of rangeerror in theget_pokemon_movesmethod ofPokemonDetailSerializer.Root Cause
Similar to Issue 1, the serializer was trying to access version group and method data using array indexing (
version_data[move["version_group"] - 1]andmethod_data[move["move_learn_method"] - 1]), but the arrays were not ordered by ID.Error Details
Solution
get_pokemon_movesmethod to order VersionGroup and MoveLearnMethod objects by IDCode Changes
Impact
These fixes resolve two critical test failures that were preventing the test suite from passing. The changes ensure that:
Files Modified
pokemon_v2/serializers.py- Fixed array indexing issues inget_encountersandget_pokemon_movesmethods